提交 c0d9f466 authored 作者: lamblin's avatar lamblin

Merge pull request #680 from nouiz/lock

Get the lock before compiling cuda_ndarray.so file.
...@@ -10,6 +10,7 @@ import numpy ...@@ -10,6 +10,7 @@ import numpy
import theano import theano
from theano.compile import optdb from theano.compile import optdb
from theano.gof.cmodule import get_lib_extension from theano.gof.cmodule import get_lib_extension
from theano.gof.compilelock import get_lock, release_lock
from theano.configparser import config, AddConfigVar, StrParam from theano.configparser import config, AddConfigVar, StrParam
import nvcc_compiler import nvcc_compiler
...@@ -106,8 +107,9 @@ if not compile_cuda_ndarray: ...@@ -106,8 +107,9 @@ if not compile_cuda_ndarray:
except ImportError: except ImportError:
compile_cuda_ndarray = True compile_cuda_ndarray = True
try: if compile_cuda_ndarray:
if compile_cuda_ndarray: get_lock()
try:
if not nvcc_compiler.is_nvcc_available(): if not nvcc_compiler.is_nvcc_available():
set_cuda_disabled() set_cuda_disabled()
...@@ -131,9 +133,11 @@ try: ...@@ -131,9 +133,11 @@ try:
include_dirs=[cuda_path], libs=['cublas'], include_dirs=[cuda_path], libs=['cublas'],
preargs=compiler.compile_args()) preargs=compiler.compile_args())
from cuda_ndarray.cuda_ndarray import * from cuda_ndarray.cuda_ndarray import *
except Exception, e: except Exception, e:
_logger.error("Failed to compile cuda_ndarray.cu: %s", str(e)) _logger.error("Failed to compile cuda_ndarray.cu: %s", str(e))
set_cuda_disabled() set_cuda_disabled()
finally:
release_lock()
if cuda_available: if cuda_available:
# If necessary, # If necessary,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论