提交 c01626c8 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #1554 from nouiz/fix-1540

fix gh-1540 and close gh-1541. Don't use rpath if the user didn't provid...
...@@ -18,18 +18,6 @@ _logger_name = 'theano.sandbox.cuda' ...@@ -18,18 +18,6 @@ _logger_name = 'theano.sandbox.cuda'
_logger = logging.getLogger(_logger_name) _logger = logging.getLogger(_logger_name)
_logger.setLevel(logging.WARNING) _logger.setLevel(logging.WARNING)
AddConfigVar('cuda.root',
"""directory with bin/, lib/, include/ for cuda utilities.
This directory is included via -L and -rpath when linking
dynamically compiled modules. If AUTO and nvcc is in the
path, it will use one of nvcc parent directory. Otherwise
/usr/local/cuda will be used. Leave empty to prevent extra
linker directives. Default: environment variable "CUDA_ROOT"
or else "AUTO".
""",
StrParam(os.getenv('CUDA_ROOT', "AUTO")),
in_c_key=False)
AddConfigVar('pycuda.init', AddConfigVar('pycuda.init',
"""If True, always initialize PyCUDA when Theano want to """If True, always initialize PyCUDA when Theano want to
initilize the GPU. Currently, we must always initialize initilize the GPU. Currently, we must always initialize
...@@ -41,9 +29,6 @@ AddConfigVar('pycuda.init', ...@@ -41,9 +29,6 @@ AddConfigVar('pycuda.init',
BoolParam(False), BoolParam(False),
in_c_key=False) in_c_key=False)
if config.cuda.root == "AUTO":
# set nvcc_path correctly and get the version
nvcc_compiler.set_cuda_root()
#is_nvcc_available called here to initialize global vars in #is_nvcc_available called here to initialize global vars in
#nvcc_compiler module #nvcc_compiler module
......
...@@ -30,6 +30,29 @@ AddConfigVar('nvcc.compiler_bindir', ...@@ -30,6 +30,29 @@ AddConfigVar('nvcc.compiler_bindir',
StrParam(""), StrParam(""),
in_c_key=False) in_c_key=False)
user_provided_cuda_root = True
def default_cuda_root():
global user_provided_cuda_root
v = os.getenv('CUDA_ROOT', "")
user_provided_cuda_root = False
if v:
return v
return find_cuda_root()
AddConfigVar('cuda.root',
"""directory with bin/, lib/, include/ for cuda utilities.
This directory is included via -L and -rpath when linking
dynamically compiled modules. If AUTO and nvcc is in the
path, it will use one of nvcc parent directory. Otherwise
/usr/local/cuda will be used. Leave empty to prevent extra
linker directives. Default: environment variable "CUDA_ROOT"
or else "AUTO".
""",
StrParam(default_cuda_root),
in_c_key=False)
AddConfigVar('cuda.nvccflags', AddConfigVar('cuda.nvccflags',
"DEPRECATED, use nvcc.flags instead", "DEPRECATED, use nvcc.flags instead",
StrParam("", allow_override=False), StrParam("", allow_override=False),
...@@ -104,7 +127,7 @@ def is_nvcc_available(): ...@@ -104,7 +127,7 @@ def is_nvcc_available():
return False return False
def set_cuda_root(): def find_cuda_root():
s = os.getenv("PATH") s = os.getenv("PATH")
if not s: if not s:
return return
...@@ -303,8 +326,13 @@ class NVCC_compiler(object): ...@@ -303,8 +326,13 @@ class NVCC_compiler(object):
if len(preargs2) > 0: if len(preargs2) > 0:
cmd.extend(['-Xcompiler', ','.join(preargs2)]) cmd.extend(['-Xcompiler', ','.join(preargs2)])
if config.cuda.root and os.path.exists(os.path.join(config.cuda.root, # We should not use rpath if possible. If the user provided
'lib')): # provided an cuda.root flag, we need to add one, but
# otherwise, we don't add it. See gh-1540 and
# https://wiki.debian.org/RpathIssue for details.
if (user_provided_cuda_root and
os.path.exists(os.path.join(config.cuda.root, 'lib'))):
rpaths.append(os.path.join(config.cuda.root, 'lib')) rpaths.append(os.path.join(config.cuda.root, 'lib'))
if sys.platform != 'darwin': if sys.platform != 'darwin':
# the 64bit CUDA libs are in the same files as are # the 64bit CUDA libs are in the same files as are
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论