提交 5c0d8837 authored 作者: Frederic's avatar Frederic

Use the new pycuda feature to attach to an existing context.

上级 06cccd43
...@@ -151,11 +151,13 @@ import theano and print the config variable, as in: ...@@ -151,11 +151,13 @@ import theano and print the config variable, as in:
Default: ``False`` Default: ``False``
If True, always initialize PyCUDA when Theano want to initilize If True, always initialize PyCUDA when Theano want to initialize
the GPU. Currently, we must always initialize PyCUDA before the GPU. With PyCUDA version 2011.2.2 or earlier, PyCUDA must
Theano do it. Setting this flag to True, ensure that, but always initialize the GPU before Theano does it. Setting
import PyCUDA. It can be done manually by importing this flag to True, ensure that, but always import PyCUDA. It can
theano.misc.pycuda_init before theano initialize the GPU device. be done manually by importing theano.misc.pycuda_init before
Theano initialize the GPU device. Newer version of PyCUDA
(currently only in the trunk) don't have this restriction.
.. attribute:: floatX .. attribute:: floatX
......
...@@ -44,9 +44,16 @@ if (not hasattr(theano.sandbox, 'cuda') or ...@@ -44,9 +44,16 @@ if (not hasattr(theano.sandbox, 'cuda') or
pass pass
pycuda_available = True pycuda_available = True
else: else:
# Now we always import this file when we call theano.sandbox.cuda.use import pycuda.driver
# So this should not happen normally. 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. To fix the" else:
" problem, import theano.misc.pycuda_init manually before" # Now we always import this file when we call theano.sandbox.cuda.use
" using the GPU.") # 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 or use a"
" more recent version of PyCUDA.")
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论