提交 073288a3 authored 作者: notoraptor's avatar notoraptor

Better fix: skip checking when we are in the same processus

上级 9d63d0ed
...@@ -54,9 +54,7 @@ mkdir %BUILDBOT_DIR% ...@@ -54,9 +54,7 @@ mkdir %BUILDBOT_DIR%
echo "Directory of stdout/stderr %BUILDBOT_DIR%" echo "Directory of stdout/stderr %BUILDBOT_DIR%"
REM Exit if theano.gpuarray import fails REM Exit if theano.gpuarray import fails
REM NB: As we define `set THEANO_FLAGS=init_gpu_device=cuda` above, python -c "import theano.gpuarray; theano.gpuarray.use('%DEVICE%')" || exit /b
REM importing theano.gpuarray will automatically initialize GPU.
python -c "import theano.gpuarray; exit(1 - int(theano.gpuarray.pygpu_activated))" || exit /b
REM Fast run and float32 REM Fast run and float32
set FILE=%BUILDBOT_DIR%\theano_python2_fastrun_f32_tests.xml set FILE=%BUILDBOT_DIR%\theano_python2_fastrun_f32_tests.xml
......
...@@ -17,6 +17,8 @@ error = _logger.error ...@@ -17,6 +17,8 @@ error = _logger.error
info = _logger.info info = _logger.info
pygpu_activated = False pygpu_activated = False
# Used to skip initialization checking when we are in the same processus.
theano_gpu_is_already_active = False
try: try:
import pygpu import pygpu
import pygpu.gpuarray import pygpu.gpuarray
...@@ -58,7 +60,8 @@ def pygpu_parse_version(version_string): ...@@ -58,7 +60,8 @@ def pygpu_parse_version(version_string):
def init_dev(dev, name=None, preallocate=None): def init_dev(dev, name=None, preallocate=None):
global pygpu_activated global pygpu_activated
if os.environ.get('THEANO_GPU_IS_ALREADY_ACTIVE', '') == 'Yes': global theano_gpu_is_already_active
if not theano_gpu_is_already_active and os.environ.get('THEANO_GPU_IS_ALREADY_ACTIVE', '') == 'Yes':
raise RuntimeError("You can't initialize the GPU in a subprocess if the parent process already did it") raise RuntimeError("You can't initialize the GPU in a subprocess if the parent process already did it")
if not config.cxx: if not config.cxx:
raise RuntimeError("The new gpu-backend need a c++ compiler.") raise RuntimeError("The new gpu-backend need a c++ compiler.")
...@@ -95,6 +98,7 @@ def init_dev(dev, name=None, preallocate=None): ...@@ -95,6 +98,7 @@ def init_dev(dev, name=None, preallocate=None):
single_stream=config.gpuarray.single_stream, single_stream=config.gpuarray.single_stream,
**args) **args)
os.environ['THEANO_GPU_IS_ALREADY_ACTIVE'] = 'Yes' os.environ['THEANO_GPU_IS_ALREADY_ACTIVE'] = 'Yes'
theano_gpu_is_already_active = True
context.dev = dev context.dev = dev
init_dev.devmap[dev] = context init_dev.devmap[dev] = context
reg_context(name, context) reg_context(name, context)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论