提交 0af21f1d authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Delete gpuarray.init_device and use init_gpu_device like everyone else.

上级 49b55484
...@@ -109,8 +109,10 @@ if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'): ...@@ -109,8 +109,10 @@ if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'):
theano.sandbox.cuda.tests.test_driver.test_nvidia_driver1() theano.sandbox.cuda.tests.test_driver.test_nvidia_driver1()
if config.device.startswith('cuda') or config.device.startswith('opencl') or \ if (config.device.startswith('cuda') or
config.gpuarray.init_device != '': config.device.startswith('opencl') or
config.init_gpu_device.startswith('cuda') or
config.init_gpu_device.startswith('opencl')):
import theano.sandbox.gpuarray import theano.sandbox.gpuarray
# Use config.numpy to call numpy.seterr # Use config.numpy to call numpy.seterr
......
...@@ -73,19 +73,19 @@ class DeviceParam(ConfigParam): ...@@ -73,19 +73,19 @@ class DeviceParam(ConfigParam):
self.default = default self.default = default
def filter(val): def filter(val):
if val.startswith('cpu') or val.startswith('gpu') \ if val == self.default or val.startswith('gpu') \
or val.startswith('opencl') or val.startswith('cuda'): or val.startswith('opencl') or val.startswith('cuda'):
return val return val
else: else:
raise ValueError(('Invalid value ("%s") for configuration ' raise ValueError(('Invalid value ("%s") for configuration '
'variable "%s". Valid options start with ' 'variable "%s". Valid options start with '
'one of "cpu", "gpu", "opencl", "cuda"' 'one of "gpu", "opencl", "cuda"'
% (val, self.fullname))) % (val, self.fullname)))
over = kwargs.get("allow_override", True) over = kwargs.get("allow_override", True)
super(DeviceParam, self).__init__(default, filter, over) super(DeviceParam, self).__init__(default, filter, over)
def __str__(self): def __str__(self):
return '%s (cpu, gpu*, opencl*, cuda*) ' % (self.fullname,) return '%s (gpu*, opencl*, cuda*) ' % (self.fullname, self.default)
AddConfigVar( AddConfigVar(
'device', 'device',
...@@ -94,15 +94,7 @@ AddConfigVar( ...@@ -94,15 +94,7 @@ AddConfigVar(
"on it. Do not use upper case letters, only lower case even if " "on it. Do not use upper case letters, only lower case even if "
"NVIDIA use capital letters."), "NVIDIA use capital letters."),
DeviceParam('cpu', allow_override=False), DeviceParam('cpu', allow_override=False),
in_c_key=False,) in_c_key=False)
AddConfigVar('gpuarray.init_device',
"""
Device to initialize for gpuarray use without moving
computations automatically.
""",
StrParam(''),
in_c_key=False)
AddConfigVar( AddConfigVar(
'init_gpu_device', 'init_gpu_device',
...@@ -110,12 +102,7 @@ AddConfigVar( ...@@ -110,12 +102,7 @@ AddConfigVar(
"Unlike 'device', setting this option will NOT move computations, " "Unlike 'device', setting this option will NOT move computations, "
"nor shared variables, to the specified GPU. " "nor shared variables, to the specified GPU. "
"It can be used to run GPU-specific tests on a particular GPU."), "It can be used to run GPU-specific tests on a particular GPU."),
EnumStr('', 'gpu', DeviceParam('', allow_override=False),
'gpu0', 'gpu1', 'gpu2', 'gpu3',
'gpu4', 'gpu5', 'gpu6', 'gpu7',
'gpu8', 'gpu9', 'gpu10', 'gpu11',
'gpu12', 'gpu13', 'gpu14', 'gpu15',
allow_override=False),
in_c_key=False) in_c_key=False)
AddConfigVar( AddConfigVar(
......
...@@ -535,10 +535,7 @@ def handle_shared_float32(tf): ...@@ -535,10 +535,7 @@ def handle_shared_float32(tf):
# import dependency. So we also test it in the file theano/__init__.py # import dependency. So we also test it in the file theano/__init__.py
if config.device.startswith('gpu'): if config.device.startswith('gpu'):
use(device=config.device, force=config.force_device, test_driver=False) use(device=config.device, force=config.force_device, test_driver=False)
elif config.init_gpu_device: elif config.init_gpu_device.startswith('gpu'):
assert config.device == "cpu", (
"We can use the Theano flag init_gpu_device"
" only when the Theano flag device=='cpu'")
_logger.warning(("GPU device %s will be initialized, and used if a GPU is " _logger.warning(("GPU device %s will be initialized, and used if a GPU is "
"needed. " "needed. "
"However, no computation, nor shared variables, will be implicitly " "However, no computation, nor shared variables, will be implicitly "
......
...@@ -57,8 +57,9 @@ if pygpu: ...@@ -57,8 +57,9 @@ if pygpu:
import theano.compile import theano.compile
theano.compile.shared_constructor(gpuarray_shared_constructor) theano.compile.shared_constructor(gpuarray_shared_constructor)
optdb.add_tags('gpuarray_opt', 'fast_run', 'fast_compile') optdb.add_tags('gpuarray_opt', 'fast_run', 'fast_compile')
elif config.gpuarray.init_device != '': elif (config.init_gpu_device.startswith('cuda') or
init_dev(config.gpuarray.init_device) config.init_gpu_device.startswith('opencl')):
init_dev(config.init_gpu_device)
from .basic_ops import (GpuAlloc, GpuContiguous, GpuEye, GpuFromHost, from .basic_ops import (GpuAlloc, GpuContiguous, GpuEye, GpuFromHost,
GpuJoin, GpuReshape, GpuSplit, HostFromGpu) GpuJoin, GpuReshape, GpuSplit, HostFromGpu)
...@@ -70,7 +71,8 @@ if pygpu: ...@@ -70,7 +71,8 @@ if pygpu:
except Exception: except Exception:
error("Could not initialize pygpu, support disabled", exc_info=True) error("Could not initialize pygpu, support disabled", exc_info=True)
else: else:
if (config.gpuarray.init_device != '' or if (config.init_gpu_device.startswith('cuda') or
config.device.startswith('opencl') or config.init_gpu_device.startswith('opencl') or
config.device.startswith('cuda')): config.device.startswith('opencl') or
config.device.startswith('cuda')):
error("pygpu was configured but could not be imported", exc_info=True) error("pygpu was configured but could not be imported", exc_info=True)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论