-
Notifications
You must be signed in to change notification settings - Fork 421
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
rand! with Uniform distribution does not work with CUDA arrays #1815
Comments
I assume it is due to broadcasting over a
Distributions.jl/src/common.jl Lines 173 to 175 in 9e72f1f
Ref might cause problems with CUDA.
Can you check whether
|
Thanks a lot David. |
The issue in this PR was fixed by #1818 (by avoiding broadcasting over distributions completely in internal code), but of course users might still run into the same issue with code such as (untested since I didn't have access to a GPU): julia> using Distributions, CUDA
julia> x = CuArray([0.1, 0.5, 0.9]);
julia> x .= quantile.(Uniform(), x) To me this seems like a bug in CUDA since |
I guess this is FluxML/Zygote.jl#1473, which was fixed (by reverting the change) in JuliaGPU/CUDA.jl@a1a72c7. That's part of the latest CUDA.jl release. |
@gkantsidis can you confirm that the problem with the MWE in #1815 (comment) was fixed in the latest CUDA release? |
Yes, Distributions v0.25.106 works well with CUDA v5.1.2. |
And Distributions 0.25.105? |
Indeed, with CUDA v5.1.2, Distributions v0.25.105 works correctly. |
The following code to initialize an existing CUDA matrix results in memory corruption (and crashes):
(Note: run in CUDA's compute sanitizer to catch the bug.)
It results in a series of messages that include:
The problem seems to come from the following:
(which is called by
_rand!(rng::AbstractRNG, d::Uniform, A::AbstractArray{<:Real})
in src/univariate/continuous/uniform.jl:156.The following implementation (which is functionally equivalent to the existing) of
_rand!
seems to work ok:Any ideas of what may be going wrong?
Environment
I have tried mostly in Julia 1.10, but have observed the problem in 1.9 (1.9.4 and, I believe, 1.9.3).
I am using Windows and WSL.
I have the following packages:
The CUDA environment is:
The text was updated successfully, but these errors were encountered: