提交 f6b0d0a4 authored 作者: Sina Honari's avatar Sina Honari

raising exception for running theano.test() with device=gpu

上级 a4e182df
...@@ -45,7 +45,10 @@ def main(): ...@@ -45,7 +45,10 @@ def main():
from theano import config from theano import config
if config.device != "cpu": if config.device != "cpu":
raise ValueError("Theano tests must be run with device=cpu." raise ValueError("Theano tests must be run with device=cpu."
" This will also run GPU tests when possible.") " This will also run GPU tests when possible.\n"
" If you want GPU-related tests to run on a"
" specific GPU device, and not the default one,"
" you should use the init_gpu_device theano flag.")
except ImportError: except ImportError:
pass pass
......
...@@ -107,6 +107,20 @@ class TheanoNoseTester(NoseTester): ...@@ -107,6 +107,20 @@ class TheanoNoseTester(NoseTester):
:returns: Returns the result of running the tests as a :returns: Returns the result of running the tests as a
``nose.result.TextTestResult`` object. ``nose.result.TextTestResult`` object.
""" """
# Many Theano tests suppose device=cpu, so we need to raise an
# error if device==gpu.
if not os.path.exists('theano/__init__.py'):
try:
from theano import config
if config.device != "cpu":
raise ValueError("Theano tests must be run with device=cpu."
" This will also run GPU tests when possible.\n"
" If you want GPU-related tests to run on a"
" specific GPU device, and not the default one,"
" you should use the init_gpu_device theano flag.")
except ImportError:
pass
# cap verbosity at 3 because nose becomes *very* verbose beyond that # cap verbosity at 3 because nose becomes *very* verbose beyond that
verbose = min(verbose, 3) verbose = min(verbose, 3)
self._show_system_info() self._show_system_info()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论