提交 1c296908 authored 作者: Josh Bleecher Snyder's avatar Josh Bleecher Snyder

Run gc before release gpu to be sure all device pointers are freed

上级 24ccfb93
import atexit, os, stat import atexit, gc, os, stat
from theano.compile import optdb from theano.compile import optdb
from theano import config from theano import config
...@@ -94,6 +94,9 @@ if cuda_available: ...@@ -94,6 +94,9 @@ if cuda_available:
gpu_init() gpu_init()
cuda_available = True cuda_available = True
cuda_initialization_error_message = "" cuda_initialization_error_message = ""
# do garbage collection before releasing the gpu to avoid releasing invalid pointers later
atexit.register(gc.collect)
# actively closing our gpu session presents segfault-on-exit on some systems
atexit.register(gpu_shutdown) atexit.register(gpu_shutdown)
except EnvironmentError, e: except EnvironmentError, e:
cuda_available = False cuda_available = False
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论