提交 40feefca authored 作者: Frederic Bastien's avatar Frederic Bastien

now if THEANO_GPU is defined to something else then "", theano will automatically import cuda!

上级 1f344114
......@@ -63,6 +63,16 @@ import gof
import floatX
floatX.set_floatX()
import config
#if THEANO_GPU not defined: don't automaticcaly importe cuda
#if THEANO_GPU defined to something else then "": automatically import cuda
# he will init cuda automatically if THEANO_GPU is not -1 or GPU
#if cuda.use() and THEANO_GPU not defined or defined to "": init to device 0.
#if THEANO_GPU defined to "-1" or "CPU", automatically import cuda, but don't init it.
if config.THEANO_GPU not in [None,""]:
import theano.sandbox.cuda
## import scalar_opt
import subprocess as _subprocess
......
......@@ -30,7 +30,7 @@ THEANO_BLAS_LDFLAGS = os.getenv('THEANO_BLAS_LDFLAGS','-lblas')
#for gpu
CUDA_ROOT = os.getenv('CUDA_ROOT')
THEANO_GPU = os.getenv("THEANO_GPU",0)
THEANO_GPU = os.getenv("THEANO_GPU")
THEANO_DEFAULT_MODE = os.getenv('THEANO_DEFAULT_MODE','FAST_RUN')
......
......@@ -61,7 +61,6 @@ except ImportError:
set_cuda_disabled()
if enable_cuda:
print __file__
cuda_path=os.path.split(old_file)[0]
code = open(os.path.join(cuda_path, "type_support.cu")).read()
......@@ -115,6 +114,8 @@ def use(device=config.THEANO_GPU):
# No successful call to use() has been made yet
if device=="-1" or device=="CPU":
return
if device in [None,""]:
device=0
device=int(device)
try:
cuda_ndarray.gpu_init(device)
......@@ -142,3 +143,6 @@ def handle_shared_float32(tf):
else:
raise NotImplementedError('removing our handler')
if enable_cuda and config.THEANO_GPU not in [None, ""]:
use()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论