提交 50c16b4a authored 作者: Frederic's avatar Frederic

Fix pycuda import to remove tests error.

上级 ef1b9f3a
......@@ -41,17 +41,23 @@ if (not hasattr(theano.sandbox, 'cuda') or
import pycuda.autoinit
pycuda_available = True
else:
import pycuda.driver
if hasattr(pycuda.driver.Context, "attach"):
pycuda.driver.Context.attach()
else:
# Now we always import this file when we call theano.sandbox.cuda.use
# So this should not happen normally.
# TODO: make this an error.
warnings.warn("For some unknow reason, theano.misc.pycuda_init was not"
" imported before Theano initialized the GPU and"
" your PyCUDA version is 2011.2.2 or earlier."
" To fix the problem, import theano.misc.pycuda_init"
" manually before using/initializing the GPU, use the"
" Theano flag pycuda.init=True or use a"
" more recent version of PyCUDA.")
try:
import pycuda.driver
pycuda_available = True
except ImportError:
pass
if pycuda_available:
if hasattr(pycuda.driver.Context, "attach"):
pycuda.driver.Context.attach()
else:
# Now we always import this file when we call
# theano.sandbox.cuda.use. So this should not happen
# normally.
# TODO: make this an error.
warnings.warn("For some unknow reason, theano.misc.pycuda_init was"
" not imported before Theano initialized the GPU and"
" your PyCUDA version is 2011.2.2 or earlier."
" To fix the problem, import theano.misc.pycuda_init"
" manually before using/initializing the GPU, use the"
" Theano flag pycuda.init=True or use a"
" more recent version of PyCUDA.")
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论