Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sum(CUDA.rand(3,3)) broken #480

Closed
denizyuret opened this issue Oct 9, 2020 · 7 comments
Closed

sum(CUDA.rand(3,3)) broken #480

denizyuret opened this issue Oct 9, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@denizyuret
Copy link
Contributor

In latest master CUDA.rand returns a ReshapedArray and sum doesn't seem to like this.

@denizyuret denizyuret added the bug Something isn't working label Oct 9, 2020
@maleadt
Copy link
Member

maleadt commented Oct 9, 2020

Works for me.

julia> using CUDA

julia> sum(CUDA.rand(3,3))
4.0282273f0

julia> CUDA.rand(3,3)
3×3 CuArray{Float32,2}:
 0.280607  0.476438    0.71696
 0.960326  0.103435    0.878106
 0.201858  0.00404511  0.880829

julia> typeof(ans)
CuArray{Float32,2}

@denizyuret
Copy link
Contributor Author

Do you have the latest master for both CUDA and GPUArrays? I have CUDA at 0f1496e GPUArrays at f5272f9

julia> using Pkg

julia> pkg"dev CUDA GPUArrays"
Path `/userfiles/dyuret/.julia/dev/CUDA` exists and looks like the correct package. Using existing path.
Path `/userfiles/dyuret/.julia/dev/GPUArrays` exists and looks like the correct package. Using existing path.
  Resolving package versions...
Updating `/dev/shm/dyuret/.julia/environments/v1.5/Project.toml`
  [052768ef] ~ CUDA v2.0.1 ⇒ v2.0.0 `/userfiles/dyuret/.julia/dev/CUDA`
  [0c68f7d7] ~ GPUArrays v6.0.1 ⇒ v6.0.1 `/userfiles/dyuret/.julia/dev/GPUArrays`
Updating `/dev/shm/dyuret/.julia/environments/v1.5/Manifest.toml`
  [b99e7846] - BinaryProvider v0.5.10
  [052768ef] ~ CUDA v2.0.1 ⇒ v2.0.0 `/userfiles/dyuret/.julia/dev/CUDA`
  [0c68f7d7] ~ GPUArrays v6.0.1 ⇒ v6.0.1 `/userfiles/dyuret/.julia/dev/GPUArrays`

julia> using CUDA
[ Info: Precompiling CUDA [052768ef-5323-5732-b1bb-66c8b64840ba]

julia> sum(CUDA.rand(3,3))
ERROR: MethodError: no method matching cached_compilation(::Dict{UInt64,Any}, ::typeof(CUDA.cufunction_compile), ::typeof(CUDA.cufu\
nction_link), ::GPUCompiler.FunctionSpec{typeof(CUDA.partial_mapreduce_grid),Tuple{typeof(identity),typeof(Base.add_sum),Float32,Ca\
rtesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},Val{tru\
e},CuDeviceArray{Float32,3,1},CuDeviceArray{Float32,2,1}}})
Stacktrace:
 [1] cufunction(::typeof(CUDA.partial_mapreduce_grid), ::Type{Tuple{typeof(identity),typeof(Base.add_sum),Float32,CartesianIndices{\
2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},Val{true},CuDeviceArra\
y{Float32,3,1},CuDeviceArray{Float32,2,1}}}; name::Nothing, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tupl\
e{}}}) at /userfiles/dyuret/.julia/dev/CUDA/src/compiler/execution.jl:297
 [2] cufunction(::typeof(CUDA.partial_mapreduce_grid), ::Type{Tuple{typeof(identity),typeof(Base.add_sum),Float32,CartesianIndices{\
2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},Val{true},CuDeviceArra\
y{Float32,3,1},CuDeviceArray{Float32,2,1}}}) at /userfiles/dyuret/.julia/dev/CUDA/src/compiler/execution.jl:294
 [3] mapreducedim!(::typeof(identity), ::typeof(Base.add_sum), ::CuArray{Float32,2}, ::CuArray{Float32,2}; init::Float32) at /userf\
iles/dyuret/.julia/dev/CUDA/src/mapreduce.jl:196
 [4] _mapreduce(::typeof(identity), ::typeof(Base.add_sum), ::CuArray{Float32,2}; dims::Colon, init::Nothing) at /userfiles/dyuret/\
.julia/dev/GPUArrays/src/host/mapreduce.jl:62
 [5] #mapreduce#15 at /userfiles/dyuret/.julia/dev/GPUArrays/src/host/mapreduce.jl:28 [inlined]
 [6] mapreduce at /userfiles/dyuret/.julia/dev/GPUArrays/src/host/mapreduce.jl:28 [inlined]
 [7] _sum at ./reducedim.jl:727 [inlined]
 [8] _sum at ./reducedim.jl:726 [inlined]
 [9] #sum#627 at ./reducedim.jl:722 [inlined]
 [10] sum(::CuArray{Float32,2}) at ./reducedim.jl:722
 [11] top-level scope at none:1

julia> pkg"st"
Status `/dev/shm/dyuret/.julia/environments/v1.5/Project.toml`
  [6710c13c] AutoGrad v1.2.3
  [fbb218c0] BSON v0.2.6
  [6e4b80f9] BenchmarkTools v0.5.0
  [052768ef] CUDA v2.0.0 `/userfiles/dyuret/.julia/dev/CUDA`
  [864edb3b] DataStructures v0.18.7
  [5789e2e9] FileIO v1.4.3
  [0c68f7d7] GPUArrays v6.0.1 `/userfiles/dyuret/.julia/dev/GPUArrays`
  [7073ff75] IJulia v1.21.4
  [6218d12a] ImageMagick v1.1.6
  [916415d5] Images v0.23.0
  [c8e1da08] IterTools v1.3.0
  [4138dd39] JLD v0.10.0
  [033835bb] JLD2 v0.2.3
  [682c06a0] JSON v0.21.1
  [1902f260] Knet v1.4.3 `/userfiles/dyuret/.julia/dev/Knet`
  [eb30cadb] MLDatasets v0.5.2
  [0db19996] NBInclude v2.2.0
  [872c559c] NNlib v0.7.5
  [91a5bcdd] Plots v1.6.10
  [438e738f] PyCall v1.92.1
  [295af30f] Revise v3.1.4
  [276daf66] SpecialFunctions v0.10.3
  [b8865327] UnicodePlots v1.3.0
  [a5390f91] ZipFile v0.9.2


@maleadt
Copy link
Member

maleadt commented Oct 9, 2020

Yes, I am. The error you post here now is different, and because you're not using the Manifest or otherwise correctly matching up dependencies.

@denizyuret
Copy link
Contributor Author

denizyuret commented Oct 9, 2020 via email

@maleadt
Copy link
Member

maleadt commented Oct 9, 2020

You also need GPUCompiler#master currently.

@denizyuret
Copy link
Contributor Author

Thanks! I will take a look at the Manifest files from now on ;)

@maleadt
Copy link
Member

maleadt commented Oct 9, 2020

Glad it's working again :-) I try not to have to rely on Manifests too much, but some times there's a breaking change in e.g. GPUCompiler that I don't immediately want to tag, so it can be tested a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants