简体   繁体   English

运行theano时的编译失败 - 使用Anaconda python发行版的Windows 8.1 64位

[英]compilation failure when running theano - windows 8.1 64 bit with Anaconda python distribution

I am running lasagne/nolearn, which uses theano. 我正在运行lasagne / nolearn,它使用theano。

It has been particularly difficult to install and compile theano. 安装和编译theano特别困难。 The following compilation error happens after installing a 64 bit g++ compiler. 安装64位g ++编译器后发生以下编译错误。

Help is much appreciated. 非常感谢帮助。 Thanks! 谢谢!

Problem occurred during compilation with the command line below: 使用以下命令行编译期间出现问题:

C:\MinGW\bin\g++.exe -shared -g -march=corei7-avx -mcx16 -msahf -mmovbe -maes -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mno-rtm -mno-hle -mrdrnd -mf16c -mfsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt --param l1-cache-size=0 --param l1-cache-line-size=0 --param l2-cache-size=256 -mtune=generic -D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -IC:\Users\aleja_000\Anaconda\lib\site-packages\numpy\core\include -IC:\Users\aleja_000\Anaconda\include -o C:\Users\aleja_000\AppData\Local\Theano\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.9-64\lazylinker_ext\lazylinker_ext.pyd C:\Users\aleja_000\AppData\Local\Theano\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.9-64\lazylinker_ext\mod.cpp -LC:\Users\aleja_000\Anaconda\libs -LC:\Users\aleja_000\Anaconda -lpython27
Traceback (most recent call last):
  File "C:\Users\aleja_000\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3032, in run_code
===============================
C:\Users\aleja_000\AppData\Local\Theano\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.9-64\lazylinker_ext\mod.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in
 #include <Python.h>
 ^

    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-1e86b04c8a9c>", line 6, in <module>
    from lasagne.layers import DenseLayer
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.5\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "c:\users\aleja_000\anaconda\src\lasagne\lasagne\__init__.py", line 5, in <module>
    from . import nonlinearities
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.5\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "c:\users\aleja_000\anaconda\src\lasagne\lasagne\nonlinearities.py", line 6, in <module>
    from theano.tensor.nnet import sigmoid
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.5\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\aleja_000\AppData\Roaming\Python\Python27\site-packages\theano\__init__.py", line 55, in <module>
    from theano.compile import (
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.5\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\aleja_000\AppData\Roaming\Python\Python27\site-packages\theano\compile\__init__.py", line 9, in <module>
    from theano.compile.function_module import *
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.5\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\aleja_000\AppData\Roaming\Python\Python27\site-packages\theano\compile\function_module.py", line 17, in <module>
    import theano.compile.mode
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.5\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\aleja_000\AppData\Roaming\Python\Python27\site-packages\theano\compile\mode.py", line 11, in <module>
    import theano.gof.vm
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.5\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\aleja_000\AppData\Roaming\Python\Python27\site-packages\theano\gof\vm.py", line 654, in <module>
    import lazylinker_c
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.5\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\aleja_000\AppData\Roaming\Python\Python27\site-packages\theano\gof\lazylinker_c.py", line 125, in <module>
    preargs=args)
  File "C:\Users\aleja_000\AppData\Roaming\Python\Python27\site-packages\theano\gof\cmodule.py", line 2042, in compile_str
    (status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): C:\Users\aleja_000\AppData\Local\Theano\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.9-64\lazylinker_ext\mod.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in
.  #include <Python.h>
.  ^
. 

I found what the problem was and would like to post the solution. 我发现问题是什么,并希望发布解决方案。 This particular problem was caused because the file libpythonxx.a file was missing in the same directory where you find the pythonxx.dll file (in my case python27.dll and thus I created the libpython27.a file. 导致这个特殊问题是因为文件libpythonxx.a文件在找到pythonxx.dll文件的同一目录中丢失(在我的情况下是python27.dll,因此我创建了libpython27.a文件。

A noble soul posted all steps necessary to install theano at http://rosinality.ncity.net/doku.php?id=python:installing_theano (in Korean and English). 一位高贵的灵魂在http://rosinality.ncity.net/doku.php?id=python:installing_theano (韩语和英语)中发布了安装theano所需的所有步骤。 To generate such file, you copy the pythonxx.dll file to a temporary directory and type the following commands in the windows console: 要生成此类文件,请将pythonxx.dll文件复制到临时目录,然后在Windows控制台中键入以下命令:

gendef pythonXX.dll gendef pythonXX.dll

dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libpythonXX.a --input-def pythonXX.def dlltool --as-flags = - 64 -m i386:x86-64 -k --output-lib libpythonXX.a --input-def pythonXX.def

Then you paste the generated libpythonxx.a file in the same directory as the pythonxx.dll file. 然后将生成的libpythonxx.a文件粘贴到pythonxx.dll文件所在的目录中。

In windows, you usually find this file under C:\\Windows\\System3 but if you are using anaconda as I am, you will find it under? 在Windows中,你通常会在C:\\ Windows \\ System3下找到这个文件但是如果你像我一样使用anaconda,你会发现它?

C:\\Users\\xxxxx\\Anaconda\\libs, xxxxx being your user. C:\\ Users \\ xxxxx \\ Anaconda \\ libs,xxxxx是您的用户。

For those using WinPython and mingw, here some additional information: 对于那些使用WinPython和mingw的人,这里有一些额外的信息:

1) Don't even bother trying the mingw32 package when using a 64bit Windows, immediately go for mingw64. 1)使用64位Windows时,甚至不打扰尝试使用mingw32软件包,请立即使用mingw64。 That stops the above shown error from occuring 这可以阻止上面显示的错误发生

2) For WinPython, the .theanorc or .theanorc.txt file must not be in your home directory, but in the WinPython/settings directory! 2)对于WinPython,.theanorc或.theanorc.txt文件不能在您的主目录中,而是在WinPython / settings目录中!

3) Make things easier by using linux style path separators such as, for the g++ flag, cxx=d:/dev/mingw-w64/mingw64/bin/g++.exe 3)使用linux样式路径分隔符使事情变得更容易,例如,对于g ++标志,cxx = d:/ dev / mingw-w64 / mingw64 / bin / g ++。exe

4) nvcc needs the windows path to have included the cl.exe file, which can in general be found in you VS installation under something like (VSPATH)/VC/bin 4)nvcc需要windows路径包含cl.exe文件,一般可以在你的VS安装下找到(VSPATH)/ VC / bin之类的东西

Regards, G. 问候,G。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM