Skip to content

Commit 831c29b

Browse files
committed
Relax dependency on the toolkit version.
1 parent de9ab30 commit 831c29b

3 files changed

Lines changed: 15 additions & 19 deletions

File tree

CUDACore/src/CUDACore.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ using CUDA_Compiler_jll
3535

3636
import CUDA_Runtime_jll
3737
const local_toolkit = CUDA_Runtime_jll.host_platform["cuda_local"] == "true"
38-
const toolkit_version = if CUDA_Runtime_jll.host_platform["cuda"] == "none"
39-
nothing
40-
else
41-
parse(VersionNumber, CUDA_Runtime_jll.host_platform["cuda"])
42-
end
4338
if local_toolkit
4439
using CUDA_Runtime_Discovery
4540
const CUDA_Runtime = CUDA_Runtime_Discovery

CUDACore/src/initialization.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,21 @@ function __init__()
157157
@error "This version of CUDA.jl only supports CUDA 12 or higher (your toolkit provides CUDA $runtime)"
158158
end
159159

160-
# ensure the loaded runtime matches what we precompiled for.
161-
if toolkit_version == nothing
162-
@error """CUDA.jl was precompiled without knowing the CUDA toolkit version. This is unsupported.
163-
You should either precompile CUDA.jl in an environment where the CUDA toolkit is available,
164-
or call `CUDA.set_runtime_version!` to specify which CUDA version to use."""
165-
elseif Base.thisminor(runtime) != Base.thisminor(toolkit_version)
166-
# this can only happen with a local toolkit, but let's always check to be sure
167-
if local_toolkit
168-
@error """You are using a local CUDA $(Base.thisminor(runtime)) toolkit, but CUDA.jl was precompiled for CUDA $(Base.thisminor(toolkit_version)). This is unsupported.
169-
Call `CUDA.set_runtime_version!` to update the CUDA version to match your local installation."""
170-
else
171-
@error """You are using CUDA $(Base.thisminor(runtime)), but CUDA.jl was precompiled for CUDA $(Base.thisminor(toolkit_version)).
160+
# ensure the loaded runtime matches the artifact we were compiled against
161+
if !local_toolkit
162+
if CUDA_Runtime_jll.host_platform["cuda"] == "none"
163+
@error """CUDA.jl was precompiled without knowing the CUDA toolkit version. This is unsupported.
164+
You should either precompile CUDA.jl in an environment where the CUDA driver is available,
165+
or call `CUDA.set_runtime_version!` to specify which CUDA version to use at run time."""
166+
_initialization_error[] = "Precompiled without CUDA toolkit version"
167+
return
168+
end
169+
170+
artifact = parse(VersionNumber, CUDA_Runtime_jll.host_platform["cuda"])
171+
if Base.thisminor(runtime) != Base.thisminor(artifact)
172+
@error """You are using CUDA $runtime, but CUDA.jl was precompiled for CUDA $artifact.
172173
This is unexpected; please file an issue."""
174+
_initialization_error[] = "CUDA version mismatch"
173175
end
174176
end
175177

LocalPreferences.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# set this preference if you want to precompile CUDA.jl in an envirnonment without CUDA
44
#version = "11.8"
55

6-
# whether to use a local CUDA installation. if CUDA isn't available during precompilation,
7-
# you will also need to set the "version" preference, matching the local CUDA version.
6+
# whether to use a local CUDA installation.
87
#local = "false"
98

109
[CUDA]

0 commit comments

Comments
 (0)