Unable to sum CuArray with Julia 1.10.0

Hi all, I have just updated my julia from 1.8.3 to 1.10.1 an I struggle with summing a CuArray. Following lines

k_ssim = exp.(-(-5:1:5).^2/(2*1.5^2))
k_ssim = k_ssim |> gpu
sum(k_ssim)

returns

LoadError: MethodError: no method matching length(::Nothing)

Closest candidates are:
  length(::Base.MethodSpecializations)
   @ Base reflection.jl:1166
  length(::DataStructures.SparseIntSet)
   @ DataStructures ~/.julia/packages/DataStructures/59MD0/src/sparse_int_set.jl:61
  length(::HDF5.BlockRange) (method too new to be called from this world context.)
   @ HDF5 ~/.julia/packages/HDF5/HtnQZ/src/dataspaces.jl:186
  ...

Stacktrace:
  [1] #s594#121
    @ ~/.julia/packages/GPUCompiler/kb6yJ/src/cache.jl:18 [inlined]
  [2] var"#s594#121"(f::Any, tt::Any, ::Any, job::Any)
    @ GPUCompiler ./none:0
  [3] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:602
  [4] cached_compilation(cache::Dict{UInt64, Any}, job::GPUCompiler.CompilerJob, compiler::typeof(CUDA.cufunction_compile), linker::typeof(CUDA.cufunction_link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/kb6yJ/src/cache.jl:71
  [5] cufunction(f::typeof(CUDA.partial_mapreduce_grid), tt::Type{Tuple{typeof(identity), typeof(Base.add_sum), Float32, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, Val{true}, CuDeviceMatrix{Float32, 1}, CuDeviceVector{Float32, 1}}}; name::Nothing, always_inline::Bool, kwargs::@Kwargs{})
    @ CUDA ~/.julia/packages/CUDA/ZdCxS/src/compiler/execution.jl:306
  [6] cufunction
    @ ~/.julia/packages/CUDA/ZdCxS/src/compiler/execution.jl:299 [inlined]
  [7] macro expansion
    @ ~/.julia/packages/CUDA/ZdCxS/src/compiler/execution.jl:102 [inlined]
  [8] mapreducedim!(f::typeof(identity), op::typeof(Base.add_sum), R::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, A::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}; init::Float32)
    @ CUDA ~/.julia/packages/CUDA/ZdCxS/src/mapreduce.jl:234
  [9] mapreducedim!
    @ ~/.julia/packages/CUDA/ZdCxS/src/mapreduce.jl:169 [inlined]
 [10] _mapreduce(f::typeof(identity), op::typeof(Base.add_sum), As::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}; dims::Colon, init::Nothing)
    @ GPUArrays ~/.julia/packages/GPUArrays/6STCb/src/host/mapreduce.jl:69
 [11] _mapreduce
    @ GPUArrays ~/.julia/packages/GPUArrays/6STCb/src/host/mapreduce.jl:35 [inlined]
 [12] mapreduce
    @ GPUArrays ~/.julia/packages/GPUArrays/6STCb/src/host/mapreduce.jl:30 [inlined]
 [13] _sum
    @ Base ./reducedim.jl:1015 [inlined]
 [14] _sum
    @ Base ./reducedim.jl:1014 [inlined]
 [15] sum(a::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer})
    @ Base ./reducedim.jl:1010
 [16] top-level scope
    @ /disk/brozova/brozova/Documents/blindeblur/RegularizedSelfDeblur/src/SSIM.jl:33
 [17] eval
    @ ./boot.jl:385 [inlined]
 [18] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:2070
 [19] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:887
 [20] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:884
 [21] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
    @ VSCodeServer ~/.vscode-server/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/eval.jl:263
 [22] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode-server/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/eval.jl:181
 [23] withpath(f::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode-server/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/repl.jl:274
 [24] (::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode-server/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/eval.jl:179
 [25] hideprompt(f::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode-server/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/repl.jl:38
 [26] (::VSCodeServer.var"#65#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode-server/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/eval.jl:150
 [27] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:515
 [28] with_logger
    @ ./logging.jl:627 [inlined]
 [29] (::VSCodeServer.var"#64#69"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode-server/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/eval.jl:255
 [30] #invokelatest#2
    @ Base ./essentials.jl:887 [inlined]
 [31] invokelatest(::Any)
    @ Base ./essentials.jl:884
 [32] (::VSCodeServer.var"#62#63")()
    @ VSCodeServer ~/.vscode-server/extensions/julialang.language-julia-1.66.2/scripts/packages/VSCodeServer/src/eval.jl:34
in expression starting at /disk/brozova/brozova/Documents/blindeblur/RegularizedSelfDeblur/src/SSIM.jl:33

Any idea how to fix this?

Where the gpu function comes from?

This works:

julia> using CUDA

julia> k_ssim = exp.(-(-5:1:5).^2/(2*1.5^2));

julia> k2 = CuArray(k_ssim);

julia> sum(k2)
3.759232795169263

I honestly don’t know… it moves the array to gpu a changes Float64 to Float32. But your approach returns the same error in my case, so it appers that the problem is somewhere in my instalation/packages…

So I just updated all the packages and the problem is gone. Sorry for bothering you.