提交 973798da authored 作者: Frederic's avatar Frederic

Add theano.sandbox.cuda.unuse()

上级 59cb7198
...@@ -66,6 +66,16 @@ multiple time in a DB. Tryed to register "%s" again under the new name "%s". ...@@ -66,6 +66,16 @@ multiple time in a DB. Tryed to register "%s" again under the new name "%s".
obj, tag) obj, tag)
self.__db__[tag].add(obj) self.__db__[tag].add(obj)
def remove_tags(self, name, *tags):
obj = self.__db__[name]
assert len(obj) == 1
obj = obj.copy().pop()
for tag in tags:
if tag in self._names:
raise ValueError('The tag of the object collides with a name.',
obj, tag)
self.__db__[tag].remove(obj)
def __query__(self, q): def __query__(self, q):
if not isinstance(q, Query): if not isinstance(q, Query):
raise TypeError('Expected a Query.', q) raise TypeError('Expected a Query.', q)
......
...@@ -437,6 +437,29 @@ def use(device, ...@@ -437,6 +437,29 @@ def use(device,
use.device_number = None use.device_number = None
def unuse():
"""
This undo what was done by the call to
use('gpu[0-9]', default_to_move_computation_to_gpu=True,
move_shared_float32_to_gpu=True,
enable_cuda=True)
This is used in Pylearn2 tests to enable/disable the GPU when needed.
After this call, the rest of Theano think the GPU shouldn't be used by default.
"""
global cuda_enabled
cuda_enabled = False
handle_shared_float32(False)
optdb.remove_tags('gpu_opt',
'fast_run',
'inplace')
optdb.remove_tags('gpu_after_fusion',
'fast_run',
'inplace')
def handle_shared_float32(tf): def handle_shared_float32(tf):
"""Set the default shared type for float32 tensor to CudaNdarrayType """Set the default shared type for float32 tensor to CudaNdarrayType
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论