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')