布置theano(Windows10,无cuda)

时间:2023-03-09 15:46:20
布置theano(Windows10,无cuda)

软件包准备

1、Anaconda 下载地址,包含python、numpy、scipy、nose、pip等包,嗯,很爽。

2、tdm64-gcc 下载地址,windows下的gcc、g++编译器,用来theano性能优化的,不然速度会很慢(官方文档如是说)

3、theano源码 下载地址,github上的实时更新的thenao源码,可以下载zip包,或者clone。

一、安装

Anaconda、tdm64-gcc一路下一步安装即可,没有什么特殊需要注意的。

下载theano源码后进入其根目录例如:theano-master,cmd执行如下命令进行安装:

python setup.py develop

二、配置theanorc.txt

编辑thenaorc.txt 存放在用户的根目录,知道根目录在哪可以cmd执行如下命令进行查看:

echo  %USERPROFILE%

theanorc.txt内容如下(只配置了gcc、g++路径,用来theano的优化):

[cxx]
flags=C:\TDM-GCC-64\bin
以上C:\TDM-GCC-64\bin路径为tdm-gcc编译器的bin目录,按照你自己的路径来配置。

三、测试theano安装成功

cmd打开python,执行:

import theano
theano.test()

import theano执行失败证明theano安装不成功,我在theano.test()时出现如下错误:

ERROR: Failure: ImportError (No module named nose_parameterized)

安装nose_parameterized即可,cmd执行:

pip install nose_parameterized

后记

1、LINK : fatal error LNK1181: cannot open input file 'cublas.lib' 的问题

可能是因为cuda安装的该版本(我的是7.5),这个版本的cublas.lib只有64位的,这样如果你的anacanda安装的是32位就会在编译的时候报错,链接不了。

2、theano 提示 g++ not detected !

导入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. To remove this warning, set Theano flags cxx to an empty string.

解决办法:

conda install mingw libpython

3、安装cudnn

cudnn下载地址

解压缩,复制到cuda的相应的文件夹里即可。

4、配置文件

[global]
device = cpu
floatX = float32
exception_verbosity=high [lib]
cnmem = . [cuda]
root=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.\bin [nvcc]
flags=-LD:\Anaconda2\libs
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
fastmath = True [traceback]
limit=