Skip to content

Commit 75c0ba8

Browse files
authored
Detect and complain about loading system libraries. (#1935)
1 parent d28a92e commit 75c0ba8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/initialization.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ function __init__()
162162
@error """JULIA_CUDA_VERSION is deprecated. Call `CUDA.jl.set_runtime_version!` to use a different version instead."""
163163
end
164164

165+
# scan for CUDA libraries that may have been loaded from system paths
166+
if CUDA_Runtime == CUDA_Runtime_jll
167+
runtime_libraries = ["cudart",
168+
"nvperf", "nvvm", "nvrtc", "nvJitLink",
169+
"cublas", "cupti", "cusparse", "cufft", "curand", "cusolver"]
170+
for lib in Libdl.dllist()
171+
contains(lib, "artifacts") && continue
172+
if any(rtlib -> contains(lib, rtlib), runtime_libraries)
173+
@warn """CUDA runtime library $(basename(lib)) was loaded from a system path. This may cause errors.
174+
Ensure that you have not set the LD_LIBRARY_PATH environment variable, or that it does not contain paths to CUDA libraries."""
175+
end
176+
end
177+
end
178+
165179
_initialized[] = true
166180
end
167181

0 commit comments

Comments
 (0)