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

linsolve on CUDA has an issue #45

Closed
RibeiroAndre opened this issue Mar 26, 2021 · 6 comments
Closed

linsolve on CUDA has an issue #45

RibeiroAndre opened this issue Mar 26, 2021 · 6 comments

Comments

@RibeiroAndre
Copy link

Hi!
Here's the issue:

using CUDA
using KrylovKit
linsolve(CuArray([1.0 2.0; 3.0 4.0]),CuArray([1.0,2.0]))
┌ Warning: Performing scalar operations on GPU arrays: This is very slow, consider disallowing these operations with `allowscalar(false)`
└ @ GPUArrays /pool/aerospace/Tools/julia-1.5.3/depot/packages/GPUArrays/WV76E/src/host/indexing.jl:43

This seems to fix it:

LinearAlgebra.mul!(x::CuArray{T,1},y::CuArray{T,1},α) where T = x .= α .* y;

Maybe something can be done about it in the code? I don't think this is an issue with LinearAlgebra as:

using LinearAlgebra
a=CuArray([1.0 2.0; 3.0 4.0]);
b=CuArray([1.0,2.0]);
c=CuArray([0.0,0.0]);
mul!(c,a,b)

works.

@Jutho
Copy link
Owner

Jutho commented Mar 26, 2021

Your second example is irrelevant right? There you are doing a matrix vector multiplication. What seems to be missing is a multiplication with a scalar using the mul! interface. This works for arrays in LinearAlgebra, but a method seems to be missing for CuArrays. I think this is a CUDA.jl issue.

@Jutho
Copy link
Owner

Jutho commented Mar 26, 2021

However, it would arguably be good to have dedicated tests for testing KrylovKit.jl - CUDA.jl interoperability.

@RibeiroAndre
Copy link
Author

I thought the second example was showing that mul! works on CuArrays in general, so I don't know why KrylovKit requires making changes to mul! in order to work.
I can file this under CUDA.jl if you think that's more appropriate, but I don't know how to reproduce the issue without using KrylovKit.

@Jutho
Copy link
Owner

Jutho commented Mar 26, 2021

Because it's another method signature, you are illustrating

mul!(::CuArray, ::CuArray, ::CuArray)

the error is from

mul!(::CuArray, ::CuArray, ::Number)

@RibeiroAndre
Copy link
Author

Ah, yes. Clearly. Thanks for pointing that out. I'll file a CUDA ticket and you can decide if you want to close this one.
Thanks!

@RibeiroAndre
Copy link
Author

Works on Julia Version 1.6.2, CUDA toolkit 11.1.1.

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

2 participants