安裝環境:wondows 64bithtml
Teano安裝測試python
1. Anaconda 安裝git
Anaconda是一個科學計算環境,自帶的包管理器conda很強大。之因此選擇它是由於它內置了python,以及numpy、scipy兩個必要庫和一些其餘庫,比起本身安裝要省事。github
首先下載Anaconda-2.1.0-Windows-x86_64.exe 安裝選擇默認配置便可,下砸地址。安裝成功後效果以下:windows
這裏有Anaconda管理器(Anaconda Command Prompt),輸入conda list來查看已經安裝的庫。咱們能夠看到Anaconda已經安裝了numpy, nose, pip, python, scipy, mingw等等dom
PS:oop
2.卸載以前版本測試
由於Anaconda裏邊包含了python,因此須要在windows環境變量中找到Python的環境變量,刪除它。或者直接將以前單獨安裝的python等通通卸載掉。這一步能夠在安裝Anaconda以前進行。spa
3. 安裝theano.net
有以下兩種安裝方法:
1)打開CMD或Anaconda命令窗口,輸入 pip install theano。 回車後就是賞心悅目的下載進度條,這個很小,因此安裝的比較快。
2)手動下載theano的zip文件
下載地址:https://github.com/Theano/Theano ,解壓到XXX/Anaconda/Lib/site-packages/theano(文件裏面有個theano的文件夾,拿出來放在E:/Anaconda/Lib/site-packages裏面)目錄下。
添加環境變量: path: XXX/Anaconda/MinGW/bin;E:/Anaconda/MinGW/x86_64-w64-mingw32/lib;
(32bit E:/Anaconda/MinGW/i686-w64-mingw32/lib;)
新建環境變量: PYTHONPATH: E:/Anaconda/Lib/site-packages/theano;
PS:有些Anaconda版本底下沒有MinGW包,這時能夠:CMD輸入 conda install mingw libpython, MinGW會自動裝到Anaconda下。
4. 測試Theano
在cmd中,輸入python 進入到python環境下(PS:此時調用的應該是Anaconda自帶的Python,check一下輸出路徑),而後先輸入import theano回車,須要等一段時間,不輸出error則說明安裝成功。
GPU加速配置
對於用GPU的人(要安裝相應的CUDA版本,好比說我用的64位的python環境(Anaconda 64位),CUDA的版本也是64位的)
CUDA的 配置可參考 http://blog.csdn.net/yeyang911/article/details/17450963
1. 配置 .theanorc.txt文件
[global]
openmp=False
device = gpu
floatX = float32
allow_input_downcast=True
[blas]
ldflags=
[gcc]
cxxflags=-IE:\Anaconda\MinGW
[nvcc]
flags = -LE:\Anaconda\libs #此處是Anaconda的路徑
compiler_bindir = E:\VS2010\VC\bin #此處必定要和你安裝的VS的路徑保持一致,若是是默認安裝的,應該是C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\bin
fastmath = True
flags=-arch=sm_30 #個人加入這句話會報錯,去掉就行了
2. 測試GPU加速
from theano import function, config, shared, sandbox import theano.tensor as T import numpy import time vlen = 10 * 30 * 768 # 10 x #cores x # threads per core iters = 1000 rng = numpy.random.RandomState(22) x = shared(numpy.asarray(rng.rand(vlen), config.floatX)) f = function([], T.exp(x)) print (f.maker.fgraph.toposort()) t0 = time.time() for i in range(iters): r = f() t1 = time.time() print ('Looping %d times took' % iters, t1 - t0, 'seconds') print ('Result is', r) if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]): print ('Used the cpu') else: print ('Used the gpu')
參考:http://blog.csdn.net/niuwei22007/article/details/47684673
http://blog.sina.com.cn/s/blog_990865340101hvuq.html