File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -334,12 +334,25 @@ struct OutOfGPUMemoryError <: Exception
334
334
# if this error was triggered before the TLS was initialized, we should not try to
335
335
# fetch memory info as those API calls will just trigger TLS initialization again.
336
336
nothing
337
+ elseif in_oom_ctor[]
338
+ # if we triggered an OOM while trying to construct an OOM object, break the cycle
339
+ nothing
337
340
else
338
- MemoryInfo ()
341
+ in_oom_ctor[] = true
342
+ try
343
+ MemoryInfo ()
344
+ catch err
345
+ # when extremely close to OOM, just inspecting `Mem.info()` may trigger an OOM again
346
+ isa (err, OutOfGPUMemoryError) || rethrow ()
347
+ nothing
348
+ finally
349
+ in_oom_ctor[] = false
350
+ end
339
351
end
340
352
new (sz, info)
341
353
end
342
354
end
355
+ const in_oom_ctor = Ref {Bool} (false )
343
356
344
357
function Base. showerror (io:: IO , err:: OutOfGPUMemoryError )
345
358
print (io, " Out of GPU memory" )
You can’t perform that action at this time.
0 commit comments