3

When running theano.test() on an Ubuntu operating system, some error message about an optimization failure is produced as follows:

ERROR (theano.gof.opt): Optimization failure due to: constant_folding

ERROR (theano.gof.opt): TRACEBACK:

ERROR (theano.gof.opt): Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/theano/gof/opt.py", line 1286, in process_node
replacements = lopt.transform(node)
File "/usr/local/lib/python2.7/dist-packages/theano/tensor/opt.py", line 3996, in constant_folding
no_recycling=[])

File "/usr/local/lib/python2.7/dist-packages/theano/sandbox/cuda/__init__.py", line 237, in make_thunk
compute_map, no_recycling)

File "/usr/local/lib/python2.7/dist-packages/theano/gof/op.py", line 606, in make_thunk
output_storage=node_output_storage)

File "/usr/local/lib/python2.7/dist-packages/theano/gof/cc.py", line 948, in make_thunk
keep_lock=keep_lock)

File "/usr/local/lib/python2.7/dist-packages/theano/gof/cc.py", line 891, in __compile__
keep_lock=keep_lock)

File "/usr/local/lib/python2.7/dist-packages/theano/gof/cc.py", line 1322, in cthunk_factory
key=key, fn=self.compile_cmodule_by_step, keep_lock=keep_lock)
File "/usr/local/lib/python2.7/dist-packages/theano/gof/cmodule.py", line 996, in module_from_key
module = next(compile_steps)

File "/usr/local/lib/python2.7/dist-packages/theano/gof/cc.py", line 1237, in compile_cmodule_by_step
preargs=preargs)

File "/usr/local/lib/python2.7/dist-packages/theano/sandbox/cuda/nvcc_compiler.py", line 444, in compile_str
return dlimport(lib_filename)

File "/usr/local/lib/python2.7/dist-packages/theano/gof/cmodule.py", line 284, in dlimport
rval = __import__(module_name, {}, {}, [module_name])

ImportError: ('/home/csz/.theano/compiledir_Linux-3.11.0-20-generic-x86_64-with-Ubuntu-12.04-precise-x86_64-2.7.3-64/tmpcF2It0/3ea6a99a1a8d1d8523de8d72c27b90f4.so: undefined symbol: _Z25CudaNdarray_CopyFromArrayP11CudaNdarrayP23tagPyArrayObject_fields', '[GpuFromHost(TensorConstant{0.0})]')

Does anybody know a way to fix these problem, or what exactly is going on?

talonmies
  • 70,661
  • 34
  • 192
  • 269
csz-carrot
  • 265
  • 3
  • 12

1 Answers1

2

This can be caused by many things. The error is related to the GPU. So first, make sure you can compile nvidia example and that they run fine. To be sure this isn't the problem.

The problem is that Theano isn't able to import a GPU module it compiled, because he didn't found the symbol it need. This missing symbol "_Z25CudaNdarray_CopyFromArrayP11CudaNdarrayP23tagPyArrayObject_fields" is in a shared library that Theano already pre-compiled.

What is your OS? Make sure to update to the latest development version of Theano. There was a fix recently (Monday if my memory is exact) that could solve this on some OS.

nouiz
  • 5,071
  • 25
  • 21
  • Thank you for your advice. I can compile nvidia samples and upgraded the latest version of Theano, but there're still errors in theano.test(). But I can use gpu to run my programs. The cpu device also cause this problem: ImportError: ('The following error happened while compiling the node', Dot22(Subtensor{int64:int64:}.0, W), '\n', '/home/csz/.theano/compiledir_Linux-3.11.0-20-generic-x86_64-with-Ubuntu-12.04-precise-x86_64-2.7.3-64/tmppzxNss/443217667310e7697fed0ce96e26ea6e.so: undefined symbol: _gfortran_st_write_done', '[Dot22(, W)]') – csz-carrot Jun 26 '14 at 02:10
  • 2
    I found solution, using the Theano flag “blas.ldflags=-lblas -lgfortran”. Thank you for your help! – csz-carrot Jun 26 '14 at 05:56
  • You had 2 problems. The first in the questions was about GPU. It seem the Theano upgrade fixed that one. It is great that you found the fix yourself for the second problem about gfortran. – nouiz Jun 26 '14 at 13:12