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

batched_mul causes a 'cannot take the CPU address of a CuArray' error on GPU #1090

Closed
nirmal-suthar opened this issue Mar 18, 2020 · 4 comments

Comments

@nirmal-suthar
Copy link

I think this issue is similar to #581 and JuliaGPU/CuArrays.jl#264

julia> using Flux , CuArrays
julia> batched_mul(gpu(rand(1024,3,32)), gpu(rand(3,3,32)))
ERROR: ArgumentError: cannot take the CPU address of a CuArray{Float32,3,Nothing}
Stacktrace:
 [1] unsafe_convert(::Type{Ptr{Float32}}, ::CuArray{Float32,3,Nothing}) at /home/nirmal/.julia/packages/CuArrays/A6GUx/src/array.jl:211
 [2] batched_mul!(::CuArray{Float32,3,Nothing}, ::CuArray{Float32,3,Nothing}, ::CuArray{Float32,3,Nothing}) at /home/nirmal/.julia/packages/NNlib/FAI3o/src/gemm.jl:82
 [3] batched_mul(::CuArray{Float32,3,Nothing}, ::CuArray{Float32,3,Nothing}) at /home/nirmal/.julia/packages/NNlib/FAI3o/src/batched/batchedmul.jl:16
 [4] top-level scope at REPL[2]:1
@mcabbott
Copy link
Member

mcabbott commented Mar 18, 2020

It looks like the CPU version is getting called on CuArrays.

What version of NNlib is this on? v0.6.5 https://github.com/FluxML/NNlib.jl/blob/v0.6.5/src/batched/batchedmul.jl calls batched_gemm! always, but after that it should only be called for StridedArray.
https://github.com/FluxML/NNlib.jl/blob/master/src/batched/batchedmul.jl#L40 which ought to exclude CuArray (but can you check that? gpu(rand(2,2,2)) isa StridedArray).

Edit: the code for CuArrays is in JuliaGPU/CuArrays.jl#619, which hasn't been released yet. So I think you will need CuArrays#master for this to work. (And for that to work, you'll need its friends to be on master too, IIRC.)

@nirmal-suthar
Copy link
Author

What version of NNlib is this on? v0.6.5

Yes, even tried on v0.6.6

(but can you check that? gpu(rand(2,2,2)) isa StridedArray).

julia> gpu(rand(2,2,2)) isa StridedArray
true

I tried using ] add CuArrays#master but it showed

ERROR: Unsatisfiable requirements detected for package CUDAdrv [c5f51814]:
CUDAdrv [c5f51814] log:
├─possible versions are: [0.8.0-0.8.6, 0.9.0, 1.0.0-1.0.1, 2.0.0, 3.0.0-3.0.1, 3.1.0, 4.0.0-4.0.4, 5.0.0-5.0.1, 5.1.0, 6.0.0-6.0.1, 6.1.0, 6.2.0] or uninstalled
├─restricted to versions 6.0.1-6 by CuArrays [3a865a2d], leaving only versions [6.0.1, 6.1.0, 6.2.0]
│ └─CuArrays [3a865a2d] log:
│ ├─possible versions are: 1.7.0 or uninstalled
│ └─CuArrays [3a865a2d] is fixed to version 1.7.0
└─restricted to versions 6.0.0 by an explicit requirement — no versions left

@mcabbott
Copy link
Member

OK, thanks, we should change that StridedArray.

There's a zoo of other packages which I think need to be on master, there's a list here: JuliaGPU/CuArrays.jl#619 (comment)

Or you could ask nicely for a release, not sure how much of a pain that is.

@nirmal-suthar
Copy link
Author

Yes, it worked after running
] add CUDAdrv#master CuArrays#master CUDAnative#master GPUArrays#master CUDAapi#master

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants