最近在implement DeepLearning.net上面的程序。对于开源的python,最头疼的就是各种package和各种configuration. 而且还是在windows下。

想要让theano在windows下能GPU并行,总结配置如下:

1. 下载CUDA,安装,重启(重要)!

2. 下载Canopy, 申请academic free lincense.

3. Canopy中下载package, 由于numpy, scipy都集成了,主要下载:pip, mingw, libpython, urllib, theano这几个

4. 在C:\Users\<User name>\ (所谓的Home,或根目录)下建立一个文件 .theanorc.txt或.theanorc, 里面复制如下内容:

[global]
device = gpu
floatX=float32 [nvcc]
flags=-LC:\Users\Sam\AppData\Local\Enthought\Canopy32\User\libs
compiler_bindir=D:\Program Files\Microsoft Visual Studio 10.0\VC\bin [blas]
ldflags = -LD:\Program Files\Enthought\Canopy32\App\appdata\canopy-1.1.0.1371.win-x86\Scripts -lmk2_core -lmk2_intel_thread -lmk2_rt

  注意:由于windows下创建文件必须有文件名,这里我们用canopy创建一个文件,然后保存为.theanorc.txt或.theanorc在根目录下(C:\Users\<User name>\).

5. 测试theano环境。

import theano

  如果不报错,恭喜你已经完成了测试第一步。

6. 运行下面程序。(来自http://deeplearning.net)

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 = 10000 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'

  这时,CUDA的nvcc不断的出现,说明我们的GPU运行已经调试可运行。之后就是本段程序的运行。如果还是CPU,时间大约在20秒左右(跟机器配置相关,我的是E8400);但如果是GPU,时间大约是0.6秒左右(我的是9800GT)。可见GPU的速度不是一般的快。

还有几个例子下面一起给大家:

数据:MNIST http://deeplearning.net/data/mnist/mnist.pkl.gz

模型:Logistic Regression using Stochastic Gradient Descent http://deeplearning.net/tutorial/code/logistic_sgd.py

   Multilayer Perceptron http://deeplearning.net/tutorial/code/mlp.py

     Restricted Boltzmann Machine http://deeplearning.net/tutorial/code/rbm.py

     Deep Belief Network http://deeplearning.net/tutorial/code/DBN.py

PS1:上面模型的代码中注意改data的路径,这样就可以直接运行了!

PS2:记得把utils.py(http://deeplearning.net/tutorial/code/utils.py)文件拷贝到一个系统环境目录(如C:\Program Files\Enthought\Canopy32\App\appdata\canopy-1.1.0.1371.win-x86\Lib\site-packages)下。

让theano在windows下能进行GPU并行的配置步骤的更多相关文章

  1. 【深度学习】在linux和windows下anaconda+pycharm+tensorflow+cuda的配置

    在linux和windows下anaconda+pycharm+tensorflow+cuda的配置 在linux和windows下anaconda+pycharm+tensorflow+cuda的配 ...

  2. Windows下Nginx Virtual Host多站点配置详解

    Windows下Nginx Virtual Host多站点配置详解 此教程适用于Windows系统已经配置好Nginx+Php+Mysql环境的同学. 如果您还未搭建WNMP环境,请查看 window ...

  3. 在windows下用eclipse + pydev插件来配置python的开发环境

    在windows下用eclipse + pydev插件来配置python的开发环境 一.安装 python 可以到网上下个Windows版的python,官网为:https://www.python. ...

  4. Windows下的Anaconda+OpenCV的环境配置

    Windows下的Anaconda+OpenCV的环境配置

  5. Windows下OpenFOAM开发及使用环境配置指南 (2)【转载】

    转载自:http://openfoam.blog.sohu.com/158751915.html *************************************************** ...

  6. Windows下OpenFOAM开发及使用环境配置指南 (1)【转载】

    转载自:http://openfoam.blog.sohu.com/158614863.html *************************************************** ...

  7. windows下安装node.js及环境配置、部署项目

    windows下安装node.js及环境配置.部署项目 一.总结 一句话总结: 安装nodejs软件:就像普普通通的的软件那样安装 配置nodejs安装的全局模块的环境变量 并且安装cnpm(比如cn ...

  8. Windows+Python+anaconda机器学习安装及环境配置步骤

    Windows+Python+anaconda机器学习安装及环境配置步骤 1. 下载安装python3.6以上版本(包含pip,不用自己安装)2. 直接下载安装pycharm安装包(用于编写pytho ...

  9. Windows下如何采用微软的Caffe配置Faster R-CNN

    前言 比较简单的一篇博客.https://github.com/microsoft/caffe 微软的Caffe以在Windows下编译简单而受到了很多人的喜爱(包括我),只用改改prop配置然后无脑 ...

随机推荐

  1. smart_pointer example

    #pragma oncetemplate<typename T>class smart_pointer{private: T* m_pRawPointer;public: smart_po ...

  2. Node.js启动服务报错SyntaxError: Unexpected token import

    启动服务报错如下: Last login: Wed Nov :: on ttys000 localhost:~ sipeng$ cd /Users/sipeng/Desktop/彭思/2017年学习/ ...

  3. Swift加载Xib创建的Controller

    Xib显示如下: <注意箭头处即可> 按住Control键,点击Files'owner拖动到View即可. 加载该控制器如下: func registerClick() { let reg ...

  4. swift 第十一课 结构体定义model类

    结构体是可以作为 model 类使用的不过也要 写下的创建方法 import UIKit/***创建一个model 结构,重写init 方法,结构体的属性不能出现可选类型**/ struct Mode ...

  5. (转)svn执行clean up命令时报错“Previous operation has not finished; run 'cleanup' if it was interrupted”

    今天碰到了个郁闷的问题,svn执行clean up命令时报错“Previous operation has not finished; run 'cleanup' if it was interrup ...

  6. Github上的python开源项目

    Python开源项目,期待大家和我们一起共同维护 github排名榜单 https://github.com/trending github搜索榜单:https://github.com/search ...

  7. C\C++中的 struct 关键字详解

    struct关键字是用来定义一个新的类型,这个新类型里面可以包含各种其他类型,称为结构体. 1. 什么是结构体 结构体(struct)是一种自定义的数据类型,就是把一组需要在一起使用的数据元素组合成一 ...

  8. tensorflow搭建神经网络

    最简单的神经网络 import tensorflow as tf import numpy as np import matplotlib.pyplot as plt date = np.linspa ...

  9. 【编程开发】MD5和RSA

    MD5和RSA是网络传输中最常用的两个算法,了解这两个算法原理后就能大致知道加密是怎么一回事了.但这两种算法使用环境有差异,刚好互补. (1)MD5 MD5(单向散列算法)的全称是Message-Di ...

  10. beego conf配置文件

    1. 多个配置文件通过include引入 自定义配置文件mysql.conf 在app.conf 中引入mysql.conf include "mysql.conf"