0

Under Windows 10, after successfully installing tensorflow gpu, and keras gpu, I installed theano gpu using:

conda install theano pygpu

Everything still worked fine, tensorflow gpu, keras gpu, etc. I ran simple example in theano, and on executing the line in jupyter,

import numpy
import theano.tensor as T
from theano import function

it gives a warning:

WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Anaconda3\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

So I decided to install g++ using conda as it suggested:

conda install m2w64-toolchain

Now, when I run the same line in theano,

import numpy
import theano.tensor as T

I get an error:

You can find the C code in this temporary file: C:\Users\IVANFI~1\AppData\Local\Temp\theano_compilation_error_fq4oz7pp
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
C:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
     80                     version,
---> 81                     actual_version, force_compile, _need_reload))
     82 except ImportError:

ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
C:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
    104                         version,
--> 105                         actual_version, force_compile, _need_reload))
    106         except ImportError:

ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-12-29f575dfe616> in <module>()
      1 import numpy
----> 2 import theano.tensor as T

C:\Anaconda3\lib\site-packages\theano\__init__.py in <module>()
    108     object2, utils)
    109 
--> 110 from theano.compile import (
    111     SymbolicInput, In,
    112     SymbolicOutput, Out,

C:\Anaconda3\lib\site-packages\theano\compile\__init__.py in <module>()
     10 from theano.compile.function_module import *
     11 
---> 12 from theano.compile.mode import *
     13 
     14 from theano.compile.io import *

C:\Anaconda3\lib\site-packages\theano\compile\mode.py in <module>()
      9 import theano
     10 from theano import gof
---> 11 import theano.gof.vm
     12 from theano import config
     13 from six import string_types

C:\Anaconda3\lib\site-packages\theano\gof\vm.py in <module>()
    672     if not theano.config.cxx:
    673         raise theano.gof.cmodule.MissingGXX('lazylinker will not be imported if theano.config.cxx is not set.')
--> 674     from . import lazylinker_c
    675 
    676     class CVM(lazylinker_c.CLazyLinker, VM):

C:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
    138             args = cmodule.GCC_compiler.compile_args()
    139             cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
--> 140                                              preargs=args)
    141             # Save version into the __init__.py file.
    142             init_py = os.path.join(loc, '__init__.py')

C:\Anaconda3\lib\site-packages\theano\gof\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2394             # difficult to read.
   2395             raise Exception('Compilation failed (return status=%s): %s' %
-> 2396                             (status, compile_stderr.replace('\n', '. ')))
   2397         elif config.cmodule.compilation_warning and compile_stderr:
   2398             # Print errors just below the command line.

. collect2.exe: error: ld returned 1 exit statusompiledir_Windows-10-10.0.17134-SP0-Intel64_Family_6_Model_158_Stepping_9_GenuineIntel-3.6.6-64/lazylinker_ext/mod.cpp:976: undefined reference to `__imp__Py_TrueStruct'Error'e undefined references to `__imp__Py_NoneStruct' followow

Removing it

conda remove m2w64-toolchain

Doesn't help. It seems like theano is now permanently damaged. How do I restore theano to working?

Ivan
  • 7,448
  • 14
  • 69
  • 134

2 Answers2

0

To revert to the original NumPy based mode just config theano not to use compiler.

Create C:\\Users\\username\\.theanorc.txt file with:

[global]
cxx=

More about theano config

sherdim
  • 1,159
  • 8
  • 19
0

I was losing hours on that topic. First, make sure Theano works on the ordinary CPU, using a compiler. Using m2w64-toolchain repeatedly killed the complete anaconda setup concerning theano. You will not only have to uninstall Anaconda, but also all artifacts which are left. The article from Xavier Dupré put me on the right track. So for CPU only just use conda install commands:

conda install -c anaconda libpython
conda install -c anaconda mingw
conda install -c anaconda Theano
conda install -c anaconda  pymc3

at least then you have a proper compiling environment.

BR, Alex