win7 64位成功安装theano 并且配置了GPU

安装Theano

我的环境:64位 windows 7。Anaconda 64位(里面附带的python2.7也是64位的)

1. 安装Anaconda,这是一个python的超集,里面包含了python2.7,而且还包含很多库。下了这个就不用单独下python了,很好用!

2. 安装Theano on AnaondaCE for Windows,可是在安装的时候出现了问题!


解决办法:

(1)下载theano的zip文件:https://github.com/Theano/Theano ,解压到C:\Anaconda\Lib\site-packages\theano目录下

(2)添加环境变量:    path: C:\Anaconda\MinGW\bin;C:\Anaconda\MinGW\x86_64-w64-mingw32\lib;  

新建环境变量:  PYTHONPATH: C:\Anaconda\Lib\site-packages\theano;

(3)在home目录下(cmd可以看到,我的是C:\Users\Administrator),创建 .theanorc.txt 文件内容如下:

[global]
openmp=False

[blas]
ldflags=

[gcc]
cxxflags = -IC:\MinGW\include

保存。

在命令框里输入如下命令:

python

import theano 

print theano.config.blas.ldflags

如果没有报错(无显示则正常),说明安装成功。

如果不使用GPU,配置到这里就ok了,就可以使用theano库函数了,如果需要使用GPU,请看下面


ok,以上安装好之后,如果您想使用GPU,那么下面就是GPU的配置了哦。

环境清单:

win7 64位

Anaconda 64位(里面附带的python2.7也是64位的)

Vs2010 (VS2012不知如何,如果哪位用2012配置成功了,告诉我哈)

CUDA5.0  64位(因为在win7 64位环境下,CUDA好像也只能安装64位的;另外要保持和python一样)

下载地址https://developer.nvidia.com/cuda-toolkit-archive

step1:配置好cuda和vs2010,参考链接http://blog.csdn.net/jasonleesjtu/article/details/8454253


step2:配置theano。.theanorc.txt:如下


[blas]
ldflags=
[gcc]
cxxflags = -IC:\MinGW\include
[nvcc]
flags=-L C:\Anaconda\libs              
compiler_bindir= C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
#容易出错的是这两个地方,一定要和你安装的python和vs的路径保持一致
[global]
openmp=False
device = gpu
floatX = float32



step3:测试一下你的配置成功没有哈

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 xrange(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'
如果最后输出的有 used the gpu ,那恭喜你了哦




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值