Skip to content

Commit 27c3b37

Browse files
authored
Take care not to spawn tasks during precompilation. (#2226)
1 parent 6e15ab6 commit 27c3b37

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

lib/cublas/CUBLAS.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -237,28 +237,28 @@ end
237237

238238
function __init__()
239239
precompiling = ccall(:jl_generating_output, Cint, ()) != 0
240-
precompiling && return
241240

242241
if !CUDA_Runtime.is_available()
243-
#@error "cuBLAS is not available"
242+
#precompiling || @error "cuBLAS is not available"
244243
return
245244
end
246245

247246
# register a log callback
248-
log_cond[] = Base.AsyncCondition() do async_cond
249-
blob = ""
250-
while true
251-
message_length = log_cursor[]
252-
blob = unsafe_string(pointer(log_buffer), message_length)
253-
if Threads.atomic_cas!(log_cursor, message_length, UInt(0)) == message_length
254-
break
247+
if !Sys.iswindows() && # NVIDIA bug #3321130 &&
248+
!precompiling && (isdebug(:init, CUBLAS) || Base.JLOptions().debug_level >= 2)
249+
log_cond[] = Base.AsyncCondition() do async_cond
250+
blob = ""
251+
while true
252+
message_length = log_cursor[]
253+
blob = unsafe_string(pointer(log_buffer), message_length)
254+
if Threads.atomic_cas!(log_cursor, message_length, UInt(0)) == message_length
255+
break
256+
end
255257
end
258+
_log_message(blob)
259+
return
256260
end
257-
_log_message(blob)
258-
return
259-
end
260-
if (isdebug(:init, CUBLAS) || Base.JLOptions().debug_level >= 2) &&
261-
!Sys.iswindows() # NVIDIA bug #3321130
261+
262262
callback = @cfunction(log_message, Nothing, (Cstring,))
263263
cublasSetLoggerCallback(callback)
264264
end

lib/cudnn/src/cuDNN.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function __init__()
176176
end
177177

178178
# register a log callback
179-
if isdebug(:init, cuDNN) || Base.JLOptions().debug_level >= 2
179+
if !precompiling && (isdebug(:init, cuDNN) || Base.JLOptions().debug_level >= 2)
180180
log_cond[] = Base.AsyncCondition() do async_cond
181181
message = Base.@lock log_lock popfirst!(log_messages)
182182
_log_message(message...)

lib/custatevec/src/cuStateVec.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function __init__()
128128
end
129129

130130
# register a log callback
131-
if isdebug(:init, cuStateVec) || Base.JLOptions().debug_level >= 2
131+
if !precompiling && (isdebug(:init, cuStateVec) || Base.JLOptions().debug_level >= 2)
132132
callback = @cfunction(log_message, Nothing, (Int32, Cstring, Cstring))
133133
custatevecLoggerSetCallback(callback)
134134
custatevecLoggerOpenFile(Sys.iswindows() ? "NUL" : "/dev/null")

lib/cutensor/src/cuTENSOR.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function __init__()
110110
end
111111

112112
# register a log callback
113-
if isdebug(:init, cuTENSOR) || Base.JLOptions().debug_level >= 2
113+
if !precompiling && (isdebug(:init, cuTENSOR) || Base.JLOptions().debug_level >= 2)
114114
callback = @cfunction(log_message, Nothing, (Int32, Cstring, Cstring))
115115
cutensorLoggerSetCallback(callback)
116116
cutensorLoggerOpenFile(Sys.iswindows() ? "NUL" : "/dev/null")

src/initialization.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,12 @@ function __init__()
168168

169169
# warn about old, deprecated environment variables
170170
if haskey(ENV, "JULIA_CUDA_USE_BINARYBUILDER") && !local_toolkit
171-
@error """JULIA_CUDA_USE_BINARYBUILDER is deprecated, and CUDA.jl always uses artifacts now.
172-
To use a local installation, use overrides or preferences to customize the artifact.
173-
Please check the CUDA.jl or Pkg.jl documentation for more details."""
171+
@error """JULIA_CUDA_USE_BINARYBUILDER is deprecated. Call `CUDA.jl.set_runtime_version!` to use a local toolkit."""
174172
# we do not warn about this when we're already using the new preference,
175173
# because during the transition clusters will be deploying both mechanisms.
176174
end
177175
if haskey(ENV, "JULIA_CUDA_VERSION")
178-
@error """JULIA_CUDA_VERSION is deprecated. Call `CUDA.jl.set_runtime_version!` to use a different version instead."""
176+
@error """JULIA_CUDA_VERSION is deprecated. Call `CUDA.jl.set_runtime_version!` to use a different version."""
179177
end
180178

181179
if !local_toolkit

0 commit comments

Comments
 (0)