win10 anacoda2 cuda theano安装笔记

Theano 0.9 pygpu 0.6.9 anaconda2版本匹配问题,目前最新的theano是1.0rc版,刚开始安装了最新的版本(condainstall theano=0.9),匹配的pygpu是0.7.x版本,pygpu又跟cudnn版本不匹配,重复安装折腾了好久。

官网:http://deeplearning.net/software/theano/


找不到cudnn –lcudnn

在[dnn]中配置library_path之后就好了。


如果主机上安装了多个版本的编译器,要在配置文件中手动的指定用的是哪个编译器。不然会有Warning,看着很不舒服。

 

安装了cuda之后,就不要再制定device=gpu了,应该将device=cuda,或者device=cuda0


配置文件整理如下:

[global]
openmp=False
device=cuda
floatX=float32
allow_input_downcast=True
optimizer_including=cudnn
optimizer=None
cxx=C:\yf_program\Anaconda2\Library\mingw-w64\bin\g++.exe

[blas]
ldflags= -LC:\yf_program\Anaconda2\Library\bin

[gcc]
cxxflags=-IC:\yf_program\Anaconda2\MinGW
cxxflags=-IC:\yf_program\CUDA\cuda_development\include

[nvcc]
flags = -LC:\yf_program\Anaconda2\libs
compiler_bindir = C:\yf_program\VS2013\VC\bin\amd64
fastmath = True
flags=-arch=sm_30

[lib]
cnmem=0.8

[dnn]
enabled=True
include_path=C:\yf_program\CUDA\cuda_development\include
library_path=C:\yf_program\CUDA\cuda_development\lib\x64

[cuda]
root = C:\yf_program\CUDA\cuda_development\

 

测试代码的问题,网上比较旧的版本,我跑起来也能看到gpu已经在工作了,但是吐出来的结果仍然是”used the cpu”,好多人说要命令行的方式添加环境变量,配置文件中的不好用。

这个问题我也没有再详细追,直接使用了官网上比较新的代码,结果测试正常。

官网地址:http://deeplearning.net/software/theano/tutorial/using_gpu.html

from theano import function, config, shared, tensor
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([], tensor.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 %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, tensor.Elemwise) and
              ('Gpu' not in type(x.op).__name__)
              for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值