根据官网上介绍的通过 AnacondaCE 最简单的安装方法安装theano环境,遇到以下问题。这里根据我们的情况给予解决方案。
问题1
Windows installerfor Theano on AnacondaCE for Windows是无法正常安装的。只能手动安装。按照官网上描述。其installer程序帮我们做了以下事。
- Copy MinGW runtime DLLs into C:\\Anaconda\\, so they are in the PATH;
- Call pipinstall theano, installing the latest released version;
- Set up a default configuration file for Theano,theanorc_default.txt, and set it up as your.theanorc.txt if itdoes not exist. It contains:
[blas]
ldflags =
[gcc]
cxxflags = -IC:\MinGW\include
问题2
按照网上的3大步骤安装好,并配置好.theanorc.txt后,测试,运行命令 import theano 出现以下提示:
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.
从字面理解,开始以为是MinGW的GCC没配置好,于是重新设置系统变量path 的c:/Anaconda/MinGW/bin 和lib。但是多次尝试无效。后分析了下,可能是机器上同时装了cygwin和MinGW,会不会是这两都有gcc和g++,两个gcc有冲突或python认的是cygwin的g++,于是去掉windows系统环境变量的cygwin/bin参量,重启机器再次运行,OK,以上的问题解决了。但是又产生以下问题。(好事多磨)
问题3
C:\Users\Administrator\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-x86_Family_18_Model_1_Stepping_0_AuthenticAMD-2.7.5-32\lazylinker_ext\mod.cpp:457:84: error: 'calloc' cannot be used as a functionnject*, PyObject*)':ze_t*, const char*)':
多班分析。应该是gcc编译问题。多半是下载的最新版MinGW和Anaconda中的MinGW版本冲突问题。因此去掉.theanorc.txt文件中的以下这句
[gcc]
cxxflags= -IC:\MinGW\include
删除拷贝到Anaconda目录下的MinGW的DLL文件。
输入 import theano
顺利执行!