File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -306,18 +306,29 @@ handle properly.
306
306
"""
307
307
struct OutOfGPUMemoryError <: Exception
308
308
sz:: Int
309
- info:: MemoryInfo
309
+ info:: Union{Nothing, MemoryInfo}
310
310
311
- OutOfGPUMemoryError (sz:: Integer = 0 ) = new (sz, MemoryInfo ())
311
+ function OutOfGPUMemoryError (sz:: Integer = 0 )
312
+ info = if task_local_state () === nothing
313
+ # if this error was triggered before the TLS was initialized, we should not try to
314
+ # fetch memory info as those API calls will just trigger TLS initialization again.
315
+ nothing
316
+ else
317
+ MemoryInfo ()
318
+ end
319
+ new (sz, info)
320
+ end
312
321
end
313
322
314
323
function Base. showerror (io:: IO , err:: OutOfGPUMemoryError )
315
324
print (io, " Out of GPU memory" )
316
325
if err. sz > 0
317
326
print (io, " trying to allocate $(Base. format_bytes (err. sz)) " )
318
327
end
319
- println (io)
320
- memory_status (io, err. info)
328
+ if err. info != = nothing
329
+ println (io)
330
+ memory_status (io, err. info)
331
+ end
321
332
end
322
333
323
334
"""
You can’t perform that action at this time.
0 commit comments