提交 c4ab09e9 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

merge

...@@ -8,9 +8,11 @@ AddConfigVar('floatX', ...@@ -8,9 +8,11 @@ AddConfigVar('floatX',
EnumStr('float64', 'float32'), EnumStr('float64', 'float32'),
) )
#gpu mean let the driver select the gpu. Needed in case of gpu in exclusive mode.
#gpuX mean use the gpu number X.
AddConfigVar('device', AddConfigVar('device',
"Default device for computations", "Default device for computations",
EnumStr('cpu', *['gpu%i'%i for i in range(4)]) EnumStr('cpu', 'gpu',*['gpu%i'%i for i in range(4)])
) )
# keep the default mode.optimizer==config.optimizer and mode.linker==config.linker! # keep the default mode.optimizer==config.optimizer and mode.linker==config.linker!
......
...@@ -629,7 +629,6 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[] ...@@ -629,7 +629,6 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
python_inc = distutils.sysconfig.get_python_inc() python_inc = distutils.sysconfig.get_python_inc()
libname = os.path.basename(python_inc) libname = os.path.basename(python_inc)
#DSE Patch 1 for supporting OSX frameworks; add -framework Python #DSE Patch 1 for supporting OSX frameworks; add -framework Python
if sys.platform=='darwin' : if sys.platform=='darwin' :
preargs.extend(['-undefined','dynamic_lookup']) preargs.extend(['-undefined','dynamic_lookup'])
...@@ -639,8 +638,15 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[] ...@@ -639,8 +638,15 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
if python_inc.count('Python.framework')>0 and config.cmodule.mac_framework_link: if python_inc.count('Python.framework')>0 and config.cmodule.mac_framework_link:
preargs.extend(['-framework','Python']) preargs.extend(['-framework','Python'])
workdir = location # sometimes, the linker cannot find -lpython so we need to tell it
# explicitly where it is located
# this returns somepath/lib/python2.5/site-packages
python_lib = distutils.sysconfig.get_python_lib()
python_lib = os.path.dirname(os.path.dirname(python_lib))
if python_lib not in lib_dirs:
lib_dirs.append(python_lib)
workdir = location
cppfilename = os.path.join(location, 'mod.cpp') cppfilename = os.path.join(location, 'mod.cpp')
cppfile = file(cppfilename, 'w') cppfile = file(cppfilename, 'w')
......
...@@ -441,12 +441,8 @@ def pydotprint(fct, outfile=os.path.join(config.compiledir,'theano.pydotprint.pn ...@@ -441,12 +441,8 @@ def pydotprint(fct, outfile=os.path.join(config.compiledir,'theano.pydotprint.pn
g.add_node(pd.Node(varstr,color='grey')) g.add_node(pd.Node(varstr,color='grey'))
elif var.name or not compact: elif var.name or not compact:
g.add_edge(pd.Edge(astr,varstr)) g.add_edge(pd.Edge(astr,varstr))
else: # else:
#no name, so we don't make a var ellipse #don't add egde here as it is already added from the inputs.
for client in var.clients:
edge = pd.Edge(astr,apply_name(client[0]))
g.add_edge(edge)
g.set_simplify(True)
g.write_png(outfile, prog='dot') g.write_png(outfile, prog='dot')
print 'The output file is available at',outfile print 'The output file is available at',outfile
......
...@@ -112,7 +112,9 @@ if cuda_available: ...@@ -112,7 +112,9 @@ if cuda_available:
def use(device): def use(device):
global cuda_enabled, enabled_cuda global cuda_enabled, enabled_cuda
if device.startswith('gpu'): if device == 'gpu':
pass
elif device.startswith('gpu'):
device = int(device[3:]) device = int(device[3:])
elif device == 'cpu': elif device == 'cpu':
device = -1 device = -1
...@@ -120,13 +122,17 @@ def use(device): ...@@ -120,13 +122,17 @@ def use(device):
raise ValueError("Invalid device identifier", device) raise ValueError("Invalid device identifier", device)
if use.device_number is None: if use.device_number is None:
# No successful call to use() has been made yet # No successful call to use() has been made yet
if device<0: if device != 'gpu' and device<0:
return return
if device in [None,""]: if device in [None,""]:
device=0 device=0
device=int(device)
try: try:
if device !='gpu':
gpu_init(device) gpu_init(device)
else:
#warning To let people see that the gpu will be used.
_logger.warn("We let the driver select the gpu device to use")
handle_shared_float32(True) handle_shared_float32(True)
use.device_number = device use.device_number = device
cuda_enabled = True cuda_enabled = True
......
...@@ -2,6 +2,7 @@ import sys, os, subprocess, logging ...@@ -2,6 +2,7 @@ import sys, os, subprocess, logging
from theano.gof.cmodule import (std_libs, std_lib_dirs, std_include_dirs, dlimport, from theano.gof.cmodule import (std_libs, std_lib_dirs, std_include_dirs, dlimport,
get_lib_extension) get_lib_extension)
from theano import config from theano import config
import distutils
_logger=logging.getLogger("theano.sandbox.cuda.nvcc_compiler") _logger=logging.getLogger("theano.sandbox.cuda.nvcc_compiler")
_logger.setLevel(logging.WARN) _logger.setLevel(logging.WARN)
...@@ -68,6 +69,14 @@ def nvcc_module_compile_str(module_name, src_code, location=None, include_dirs=[ ...@@ -68,6 +69,14 @@ def nvcc_module_compile_str(module_name, src_code, location=None, include_dirs=[
if cuda_root: if cuda_root:
lib_dirs.append(os.path.join(cuda_root, 'lib')) lib_dirs.append(os.path.join(cuda_root, 'lib'))
# sometimes, the linker cannot find -lpython so we need to tell it
# explicitly where it is located
# this returns somepath/lib/python2.5/site-packages
python_lib = distutils.sysconfig.get_python_lib()
python_lib = os.path.dirname(os.path.dirname(python_lib))
if python_lib not in lib_dirs:
lib_dirs.append(python_lib)
cppfilename = os.path.join(location, 'mod.cu') cppfilename = os.path.join(location, 'mod.cu')
cppfile = file(cppfilename, 'w') cppfile = file(cppfilename, 'w')
......
...@@ -225,6 +225,7 @@ def get_shapes2(scales_img=(1,1), scales_kern=(1,1), subsample=(1,1), img_stride ...@@ -225,6 +225,7 @@ def get_shapes2(scales_img=(1,1), scales_kern=(1,1), subsample=(1,1), img_stride
return shapes return shapes
def test_valid(): def test_valid():
raise Exception('One of the modes here causes a segmentation fault!')
# img shape, kern shape, subsample shape # img shape, kern shape, subsample shape
shapes = get_basic_shapes() shapes = get_basic_shapes()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论