windows下python3,Theano安装

1.直接安装winpython(python3)


2.安装mingw

后在cmd输入gcc -v以检验是否成功安装


3.安装vs2010


4.安装cuda7.0,nvida官网选择合适版本


后检验cuda是否成功安装:

安装后进入cmd,nvcc -V

并C:\Program Files\NVIDIA Corporation\Installer2\CUDASamples_7.0\5_Simulations 用vs2010随意生成一个文件

于C:\Program Files\NVIDIA Corporation\Installer2\CUDASamples_7.0.{1A50EF4F-E4C6-4A84-BA04-7FC667829E60}\bin\win64\Debug打开检验是否cuda能正常安装


5.安装theano

http://deeplearning.net/software/theano_versions/dev/install_windows.html

cmd,pip setup.py install


6.与cmd根目录下配置.theanorc.txt

[global]
openmp=False 
device = gpu 
floatX = float32 
allow_input_downcast=True
[blas]
ldflags=
[gcc]
cxxflags = -D_hypot=hypot
[nvcc]  
fastmath = True  
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
base_compiledir=path_to_a_directory_without_such_characters  
flags = -LE:\WinPython-64bit-3.4.3.2\python-3.4.3.amd64


7.测试代码

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([], sandbox.cuda.basic_ops.gpu_from_host(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)
print('Numpy result is', numpy.asarray(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')


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值