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