参考 http://deeplearning.net/software/theano/install_windows.html
至于theano的安装是比较简答的,可以选择集成的安装包(如:WinPython、Anaconda等),也可以使用python自带的命令pip安装。(Python的安装路径上不能有空格,否则会给后续的配置带来麻烦)
要使用GPU,系统还需安装CUDA驱动。两者都安装好之后,接下来就是要配置theano,使其能用上GPU
在C:\Users\<User name>\ (所谓的Home,或根目录)下建立一个文件 .theanorc.txt 里面复制如下内容:
[blas] ldflags = [gcc] cxxflags = [nvcc] fastmath = True [global] device = gpu floatX = float32
[blas] ldflags= [gcc] cxxflags = -ID:\WinPython-2.7.10.3\python-2.7.10.amd64\include [nvcc] fastmath = True --flags=-LD:\WinPython-2.7.10.3\python-2.7.10.amd64\libs --compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\ [global] device = gpu floatX = float32 openmp = False
但在配置这个文件时,要特别注意gcc.cxxflags和nvcc.flags的路径中不能有空格,否则编译会出错。也就是Python的安装路径中不要含空格。
使用WinPython的,配置GPU时要注意配置文件的存放路径:
Theano can be configured with a .theanorc
text file (or .theanorc.txt
, whichever is easier for you to create under Windows). It should be placed in the directory pointed to by the %USERPROFILE%
variable. Please note, that WinPython changes it to WinPythonDir\settings
(so in our system this corresponds to D:\WinPython-2.7.10.3\settings
.
To use the GPU please write the following configuration file:
[global]
device = gpu
floatX = float32
[nvcc]
flags = --use-local-env --cl-version=2008