提交 86a7b75c authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Prevent gpu initialization when not required

上级 e5d09827
......@@ -8,7 +8,8 @@ if theano.gpuarray.pygpu is None:
raise SkipTest("pygpu not installed")
if (not theano.gpuarray.pygpu_activated and
not theano.config.init_gpu_device.startswith('gpu')):
not theano.config.init_gpu_device.startswith('gpu') and
not theano.config.force_device):
theano.gpuarray.init_dev('cuda')
if not theano.gpuarray.pygpu_activated:
......
......@@ -6,8 +6,6 @@ import theano
from theano import tensor, config, Apply, Op
from theano.gradient import grad_undefined
from .config import mode_with_gpu, test_ctx_name
from ..basic_ops import CGpuKernelBase
from ..type import GpuArrayType, get_context
......@@ -62,6 +60,10 @@ class GpuEye(CGpuKernelBase, Op):
def test_cgpukernelbase():
# Import inside the function to prevent the back-end from being
# initialized when reloading the GpuEye object from cache.
from .config import mode_with_gpu, test_ctx_name
op = GpuEye(dtype='int32', context_name=test_ctx_name)
f = theano.function([], op(4, 5), mode=mode_with_gpu)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论