提交 194400fd authored 作者: Frederic Bastien's avatar Frederic Bastien

Default the cuda.root to a parents directory where nvcc if nvcc is in the path.

上级 4693e7d5
...@@ -118,10 +118,6 @@ AddConfigVar('nvcc.fastmath', ...@@ -118,10 +118,6 @@ AddConfigVar('nvcc.fastmath',
"", "",
BoolParam(False)) BoolParam(False))
AddConfigVar('cuda.root',
"directory with bin/, lib/, include/ for cuda utilities",
StrParam(os.getenv('CUDA_ROOT', "/usr/local/cuda")))
AddConfigVar('gpuelemwise.sync', AddConfigVar('gpuelemwise.sync',
"when true, wait that the gpu fct finished and check it error code.", "when true, wait that the gpu fct finished and check it error code.",
BoolParam(True)) BoolParam(True))
......
...@@ -10,13 +10,18 @@ _logger.setLevel(logging.WARN) ...@@ -10,13 +10,18 @@ _logger.setLevel(logging.WARN)
from theano.configparser import config, AddConfigVar, StrParam from theano.configparser import config, AddConfigVar, StrParam
AddConfigVar('nvcc.compiler_bindir', AddConfigVar('nvcc.compiler_bindir',
"if defined, nvcc compiler driver will seek g++ and gcc in this directory", "If defined, nvcc compiler driver will seek g++ and gcc in this directory",
StrParam("")) StrParam(""))
AddConfigVar('cuda.nvccflags', AddConfigVar('cuda.nvccflags',
"Extra compiler flags for nvcc", "Extra compiler flags for nvcc",
StrParam("")) StrParam(""))
AddConfigVar('cuda.root',
"The directory with bin/, lib/, include/ for cuda utilities. Used to put this directory of nvidia lib in the compiled libraire. Usefull when people forget to update there LD_LIBRARY_PATH and LIBRARY_PATH environment variable. If AUTO, if nvcc is in the path, it will use one of this parent directory. Otherwise /usr/local/cuda. If empty, won't appen the directory in the compiled library",
StrParam(os.getenv('CUDA_ROOT', "AUTO")))
def error(*args): def error(*args):
#sys.stderr.write('ERROR:'+ ' '.join(str(a) for a in args)+'\n') #sys.stderr.write('ERROR:'+ ' '.join(str(a) for a in args)+'\n')
_logger.error("ERROR: "+' '.join(str(a) for a in args)) _logger.error("ERROR: "+' '.join(str(a) for a in args))
...@@ -43,7 +48,7 @@ def is_nvcc_available(): ...@@ -43,7 +48,7 @@ def is_nvcc_available():
global nvcc_version global nvcc_version
nvcc_version = s[1] nvcc_version = s[1]
return True return True
except: except Exception:
#try to find nvcc into cuda.root #try to find nvcc into cuda.root
p = os.path.join(config.cuda.root,'bin','nvcc') p = os.path.join(config.cuda.root,'bin','nvcc')
if os.path.exists(p): if os.path.exists(p):
...@@ -51,6 +56,20 @@ def is_nvcc_available(): ...@@ -51,6 +56,20 @@ def is_nvcc_available():
nvcc_path = p nvcc_path = p
return True return True
else: return False else: return False
def set_cuda_root():
import pdb;pdb.set_trace()
s = os.getenv("PATH")
if not s:
return
for dir in s.split(os.path.pathsep):
if os.path.exists(os.path.join(dir,"nvcc")):
config.cuda.root = os.path.split(dir)[0]
return
if config.cuda.root == "AUTO":
set_cuda_root()
is_nvcc_available()#to set nvcc_path correctly and get the version is_nvcc_available()#to set nvcc_path correctly and get the version
def nvcc_module_compile_str( def nvcc_module_compile_str(
...@@ -152,7 +171,7 @@ def nvcc_module_compile_str( ...@@ -152,7 +171,7 @@ def nvcc_module_compile_str(
if len(preargs2)>0: if len(preargs2)>0:
cmd.extend(['-Xcompiler', ','.join(preargs2)]) cmd.extend(['-Xcompiler', ','.join(preargs2)])
if os.path.exists(os.path.join(config.cuda.root,'lib')): if config.cuda.root and os.path.exists(os.path.join(config.cuda.root,'lib')):
cmd.extend(['-Xlinker',','.join(['-rpath',os.path.join(config.cuda.root,'lib')])]) cmd.extend(['-Xlinker',','.join(['-rpath',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 named by the function above # the 64bit CUDA libs are in the same files as are named by the function above
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论