Skip to content

Commit

Permalink
Merge pull request #1413 from JuliaGPU/backports-release-3.8
Browse files Browse the repository at this point in the history
Backports for 3.8.3
  • Loading branch information
maleadt authored Feb 25, 2022
2 parents 46db50d + 4ab2330 commit 2319b89
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "CUDA"
uuid = "052768ef-5323-5732-b1bb-66c8b64840ba"
version = "3.8.2"
version = "3.8.3"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
46 changes: 33 additions & 13 deletions deps/bindeps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,36 @@ function toolkit()

# CI runs in a well-defined environment, so prefer a local CUDA installation there
if getenv("CI", false) && !haskey(ENV, "JULIA_CUDA_USE_BINARYBUILDER")
toolkit = find_local_cuda()
try
toolkit = find_local_cuda()
catch err
isa(err, ErrorException) || rethrow()
# no need to report here, we'll do so below
end
end

if toolkit === nothing && getenv("JULIA_CUDA_USE_BINARYBUILDER", true)
toolkit = find_artifact_cuda()
try
toolkit = find_artifact_cuda()
catch err
isa(err, ErrorException) || rethrow()
@warn "Unable to use CUDA from artifacts: $(err.msg)"
end
end

# if the user didn't specifically request an artifact version, look for a local installation
if toolkit === nothing && !haskey(ENV, "JULIA_CUDA_VERSION")
toolkit = find_local_cuda()
try
toolkit = find_local_cuda()
catch err
isa(err, ErrorException) || rethrow()
@warn "Unable to use a local CUDA installation: $(err.msg)"
end
end

if toolkit === nothing
error("Could not find a suitable CUDA installation")
error("""No suitable CUDA installation available.
Please look at the warnings above for possible reasons.""")
end

toolkit
Expand Down Expand Up @@ -130,14 +146,16 @@ const cuda_toolkits = [
function find_artifact_cuda()
@debug "Trying to use artifacts..."

# select compatible artifacts
# select artifacts based on CUDA compatibility
if haskey(ENV, "JULIA_CUDA_VERSION")
wanted = VersionNumber(ENV["JULIA_CUDA_VERSION"]) # misnomer: actually the release
@debug "Selecting artifacts based on requested $wanted"
candidate_toolkits = filter(cuda_toolkits) do toolkit
toolkit.release == wanted
end
isempty(candidate_toolkits) && @debug "Requested CUDA release $wanted is not provided by any artifact"
isempty(candidate_toolkits) &&
error("""None of the available CUDA artifacts matches the requested release $wanted.
Please try again without setting the JULIA_CUDA_VERSION environment variable.""")
else
driver_release = CUDA.release()
@debug "Selecting artifacts based on driver compatibility $driver_release"
Expand All @@ -148,7 +166,9 @@ function find_artifact_cuda()
(driver_release >= v"11" &&
toolkit.release.major <= driver_release.major))
end
isempty(candidate_toolkits) && @debug "CUDA driver compatibility $driver_release is not compatible with any artifact"
isempty(candidate_toolkits) &&
error("""None of the available CUDA artifacts is compatible with your driver (for CUDA $driver_release).
Please try upgrading your NVIDIA driver.""")
end

# download and install
Expand All @@ -161,8 +181,8 @@ function find_artifact_cuda()
end
end
if artifact === nothing
@debug "Could not find a compatible artifact."
return nothing
error("""Could not find or download a compatible artifact for your platform ($(Base.BinaryPlatforms.host_triplet())).
If you think this is in error, please file an issue.""")
end

@debug "Using CUDA $(artifact.release) from an artifact at $(artifact.dir)"
Expand All @@ -176,17 +196,17 @@ function find_local_cuda()

let path = find_cuda_binary(dirs, "nvdisasm")
if path === nothing
@debug "Could not find nvdisasm"
return nothing
error("""Could not find the nvdisasm binary.
If CUDA is installed, please make sure this binary is in your PATH.""")
end
__nvdisasm[] = path
end

cudart_versions = cuda_library_versions("cudart")
let path = find_cuda_library(dirs, "cudart", cudart_versions)
if path === nothing
@debug "Could not find the CUDA runtime library"
return nothing
error("""Could not find the cudart library.
If CUDA is installed, please make sure this library is discoverable.""")
end
__libcudart[] = path
end
Expand Down
8 changes: 4 additions & 4 deletions lib/cudadrv/CUDAdrv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ include("libcuda_deprecated.jl")
end
if system_driver == ""
if Sys.iswindows()
error("""Could not find the CUDA driver library. Please make sure you have installed the NVIDIA driver for your GPU.
If you're sure it's installed, look for `libcuda.so` in your system and make sure it's discoverable by the linker.
Typically, that involves an entry in '/etc/ld.so.conf', or setting LD_LIBRARY_PATH.""")
else
error("""Could not find the CUDA driver library. Please make sure you have installed the NVIDIA driver for your GPU.
If you're sure it's installed, look for `nvcuda.dll` in your system and make sure it's discoverable by the linker.
Typically, that involves adding an entry to PATH.""")
else
error("""Could not find the CUDA driver library. Please make sure you have installed the NVIDIA driver for your GPU.
If you're sure it's installed, look for `libcuda.so` in your system and make sure it's discoverable by the linker.
Typically, that involves an entry in '/etc/ld.so.conf', or setting LD_LIBRARY_PATH.""")
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cudadrv/state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function math_mode!(mode::MathMode; precision=nothing)
default_math_mode[] = mode

if precision !== nothing
state.math_precision = math_precision
state.math_precision = precision
default_math_precision[] = precision
end

Expand Down
5 changes: 4 additions & 1 deletion src/device/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ end
for var in [:ki, :wi, :fi, :ke, :we, :fe]
val = getfield(Random, var)
gpu_var = Symbol("gpu_$var")
@eval @inline $gpu_var() = CuDeviceArray($(size(val)), $(emit_constant_array(var, val)))
@eval @inline @generated function $gpu_var()
ptr = emit_constant_array($(QuoteNode(var)), $val)
Expr(:call, :CuDeviceArray, $(size(val)), ptr)
end
end

## randn
Expand Down
2 changes: 1 addition & 1 deletion src/pool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ end
pool_mark(state.device) # mark the pool as active
@retry_reclaim isnothing actual_alloc(sz; async=true, stream)
else
@retry_reclaim isnothing actual_alloc(sz; async=true, stream)
@retry_reclaim isnothing actual_alloc(sz; async=false, stream)
end
buf === nothing && throw(OutOfGPUMemoryError(sz))
end
Expand Down
6 changes: 6 additions & 0 deletions test/initialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ if length(devices()) > 1
# math_mode
old_mm = CUDA.math_mode()
CUDA.math_mode!(CUDA.PEDANTIC_MATH)
@test CUDA.math_mode() == CUDA.PEDANTIC_MATH
CUDA.math_mode!(CUDA.PEDANTIC_MATH; precision=:Float16)
@test CUDA.math_precision() == :Float16
CUDA.math_mode!(old_mm)
# ensure the values we tested here aren't the defaults
@test CUDA.math_mode() != CUDA.PEDANTIC_MATH
@test CUDA.math_precision() != :Float16

# tasks on multiple threads
Threads.@threads for d in 0:1
Expand Down

2 comments on commit 2319b89

@maleadt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/55471

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.8.3 -m "<description of version>" 2319b890f1ad807bfa674d75ac14c5a2697a7f51
git push origin v3.8.3

Please sign in to comment.