在启用GPU的Windows 8上安装theano [英] Installing theano on Windows 8 with GPU enabled
问题描述
我知道Theano对Windows 8.1的支持只是在实验阶段,但我不知道有没有人有解决我的问题的运气。根据我的配置,我得到三种不同类型的错误。我假设我的任何错误的解决方案将解决我的问题。
我已经安装Python使用WinPython 32位系统,使用MinGW 在这里。我的 .theanorc
文件的内容如下:
[global ]
openmp = False
device = gpu
[nvcc]
flags = -LC:\TheanoPython\python-2.7.6\libs
compiler_bindir = C:\Program Files(x86)\Microsoft Visual Studio 10.0 \VC\bin \
[blas]
ldflags =
当我运行 import theano
时,错误如下:
nvcc致命:nvcc找不到受支持的Microsoft Visual Studio版本。
仅支持版本2010,2012和2013
['nvcc','-shared','-g','-O3','--compiler-bindir' ,'C:\\Program Files(x86)\\
Microsoft Visual Studio 10.0 \\VC\\bin#flags = -m32#我们将这个硬编码为
现在','-Xlinker','/ DEBUG','-m32','-Xcompiler','-DCUDA_NDARRAY_CUH = d67f7c8a21
306c67152a70a88a837011 / Zi / MD','-IC:\\ TheanoPython \\python-2.7.6\\\lib\\site-pa
ckages\\theano\\sandbox\\cuda','-IC:\ \TheanoPython \\python-2.7.6\\lib\\site-pac
kages \\\\
umpy\\core\\include','-IC: \\TheanoPython\\python-2.7.6\\include','-o',
'C:\\Users\\Matej\\AppData\ \Local \\Theano\\compiledir_Windows-8-6.2.9200-Intel6
4_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\\\\\\\\\\\\\\\\\\ 'mod.cu','-LC:\\TheanoPython\\python-2.7.6\\libs','-LNone\\lib','-LNon
e\ \lib64','-LC:\\TheanoPython\\python-2.7.6','-lpython27','-lcublas','-lcuda
rt']
错误(aan.sandbox.cuda):无法编译cuda_ndarray.cu:('nvcc返回st
atus',1,'为cmd','nvcc -shared -g -O3 --compiler-bindir C: \\\Program Files(x
86)\\ Microsoft Visual Studio 10.0 \\VC\\bin#flags = -m32#我们现在有这个硬编码的
现在-Xlinker / DEBUG -m32 -Xcompiler -DCUDA_NDARRAY_CUH = d67f7c8a21306c67152a
70a88a837011,/ Zi,/ MD -IC:\\TheanoPython\\python-2.7.6\\\lib\\site-packages \\thean
o \\sandbox\\cuda -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\ \\\
umpy\\co
re\\include -IC:\\TheanoPython\\python-2.7.6\\include -o C:\\Users\\ \\\Matej\\AppDa
ta\\Local\\Theano\\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepp
ing_3_GenuineIntel-2.7.6-32\ \cuda_ndarray\\cuda_ndarray.pyd mod.cu -LC:\\TheanoP
ython\\python-2.7.6\\libs -LNone\\\lib -LNone\\ \\\lib64 -LC:\\TheanoPython \\python-2
.7.6 -lpython27 -lcublas -lcudart')
警告(theano.sandbox.cuda):安装了CUDA,但设备gpu不可用
e
我也使用 Visual Studio 12.0
安装在我的系统上时出现以下错误:
mod.cu
nvlink fatal:无法打开输入文件'C:/ Users / Matej / AppData / Local / Temp / tm
pxft_00001b70_00000000-28_mod.obj'
['nvcc' -shared','-g','-O3','--compiler-bindir','C:\\Program Files(x86)\\
Microsoft Visual Studio 12.0 \\ VC \\bin\\','-Xlinker','/ DEBUG','-m32','-Xcompi
ler','-LC:\\TheanoPython\\ python-2.7.6\\libs,-DCUDA_NDARRAY_CUH = d67f7c8a21306c6
7152a70a88a837011,/ Zi,/ MD','-IC:\\TheanoPython\\python-2.7.6\\ lib \\site-package
s\\theano\\sandbox\\cuda','-IC:\\TheanoPython\\python-2.7.6\\\ \\ lib \\site-packages
\\\\
umpy\\core\\include','-IC:\\TheanoPython\\python-2.7.6\ \include','-o','C:\
\Users \\Matej\\AppData\\Local\\Theano\\compiledir_Windows-8- 6.2.9200-Intel64_Fam
ily_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\ \\\python-2.7.6\\libs','-LNone\\lib','-LNone\\li
b64','-LC:\\TheanoPython\\ \\\python-2.7.6','-lpython27','-lcublas','-lcudart']
错误(theano.sandbox.cuda):无法编译cuda_ndarray.cu:('nvcc return st
atus',1,'for cmd','nvcc -shared -g -O3 --compiler-bindir C:\\Program Files(x
86)\\Microsoft Visual Studio 12.0 \\VC\\bin\\ -Xlinker / DEBUG -m32 -Xcompiler -LC
:\\TheanoPython\\python-2.7.6\\libs, -DCUDA_NDARRAY_CUH = d67f7c8a21306c67152a70a88
a837011 / Zi,/ MD -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\theano\\ \\\sa
ndbox\\cuda -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\\\
umpy\ \core\\i
nclude -IC:\\TheanoPython\\python-2.7.6\\include -o C:\\Users\\Matej\\ \\\AppData\\L
ocal\\Theano\\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3
_GenuineIntel-2.7.6-32\\\cuda_ndarray\ \cuda_ndarray.pyd mod.cu -LC:\\TheanoPython
\\python-2.7.6\\libs -LNone\\lib -LNone\\lib64 -LC :\\TheanoPython \\python-2.7.6
-lpython27 -lcublas -lcudart')
警告(theano.sandbox.cuda):安装了CUDA,但是设备gpu不可用
e
在后一个错误中,几个弹出窗口问我如何
cl.exe
VS 2010和VS 2013)。
最后,如果我在环境路径中设置VS 2013,并设置 .theanorc
>
[global]
base_compiledir = C:\Program Files(x86)\ Microsoft Visual Studio 12.0 \VC\ bin
openmp = False
floatX = float32
device = gpu
[nvcc]
flags = -LC:\TheanoPython\python-2.7 .6 \libs
compiler_bindir = C:\Program文件(x86)\Microsoft Visual Studio 12.0 \VC\bin \
[blas]
ldflags =
我得到以下错误:
c:\theanopython\python-2.7.6 \include\pymath.h(22):警告:dllexport / dllimport与round冲突
c: \\program files \ nvidia gpu computing toolkit \cuda\v6.5\include\math_functions.h(2455):here; dllimport / dllexport dropped
mod.cu(954):warning:语句不可达
mod.cu(1114):error:namespacestd没有成员min
mod.cu(1145):error:namespacestd没有成员min
mod.cu没有成员min
mod.cu(1174):error:namespacestd没有成员min
mod.cu(1317):error: std没有成员min
mod.cu(1318):error:namespacestd没有成员min :error:namespacestd没有成员min
mod.cu(1443):error:namespacestd没有成员min
mod。 cu(1742):错误:命名空间std没有成员min
mod.cu(1777):错误:命名空间std没有成员min
mod.cu(1781):error:namespacestd没有成员min
mod.cu(1814):error:namespacestd没有成员min
mod.cu(1821):错误:命名空间std没有成员min
mod.cu(1853):error:namespacestd min
mod.cu(1861):error:namespacestd没有成员min
mod.cu没有成员min
mod.cu(1905):error:namespacestd没有成员min
mod.cu(1946)命名空间std没有成员min
mod.cu(1960):error:namespacestd没有成员min
mod.cu ):error:namespacestd没有成员min
mod.cu(3752):error:namespacestd没有成员min
.cu(3784):error:namespacestd没有成员min
mod.cu(3786):error:namespacestd没有成员min
b $ b mod.cu(3789):error:namespacestd没有成员min
mod.cu(3791):error:namespacestd没有成员min
mod.cu(3794):error:namespacestd没有成员min
mod.cu(3795):error:namespacestd min
mod.cu(3836):error:namespacestd没有成员min
mod.cu(3838):error:namespacestd 没有成员min
mod.cu(4602):error:namespacestd没有成员min
mod.cu :namespacestd没有成员min
在C:/Users/Matej/AppData/Local/Temp/tmpxft_00001d84_00000000-10_mod.cpp1.ii的编译中检测到31个错误。
ERROR(theano.sandbox.cuda):无法编译cuda_ndarray.cu:('nvcc return status',2,'for cmd','nvcc -shared -g -O3 -Xlinker / DEBUG -m32 -Xcompiler -DCUDA_NDARRAY_CUH = d67f7c8a21306c67152a70a88a837011 / Zi,/ MD -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\ theano\\sandbox\\ \\\cuda -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\\\
umpy\\core\\include -IC :\\TheanoPython\\python-2.7.6\\include -o C:\\Users\\Matej\\AppData\\Local\\Theano\\ \\\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\libs -LNone\\lib -LNone\\lib64 -LC:\\TheanoPython\\python-2.7.6 -lpython27 -lcublas -lcudart')
错误: theano.sandbox.cuda:无法编译cuda_ndarray.cu:('nvcc return status',2,'for cmd','nvcc -shared -g -O3 -Xlinker / DEBUG -m32 -Xcompiler -DCUDA_NDARRAY_CUH = d67f7c8a21306c67152a70a88a837011,/ Zi ,/ MD -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\theano\\sandbox\\cuda -IC: \\TheanoPython\\python-2.7.6\\lib\\site-packages\\\\
umpy\\core\\include -IC:\\TheanoPython\\ \\\python-2.7.6\\include -o C:\\Users\\Matej\\AppData\\Local\\Theano\\compiledir_Windows-8- 6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\ cuda_ndarray\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\TheThePan \\lib -LNone\\lib64 -LC:\\TheanoPython\\python-2.7.6 -lpython27 -lcublas -lcudart')
mod.cu
['nvcc','-shared','-g','-O3','-Xlinker','/ DEBUG','-m32','-Xcompiler','-DCUDA_NDARRAY_CUH = d67f7c8a21306c67152a70a88a837011,/ Zi ,/ MD','-IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\theano\\\sandbox\\cuda ','-IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\\\
umpy\\\core\\include',' -IC:\\TheanoPython\\python-2.7.6\\include','-o','C:\\Users\\Matej\\AppData\\\ \\ Local \\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32 \\ \\TheanoPython\\python-2.7.6\\libs','-LNone\\lib','-LNone\\lib64','-LC:\\TheanoPython \\python-2.7.6','-lpython27','-lcublas','-lcudart']
如果我运行 import theano
没有GPU选项,它运行没有问题。另外,CUDA示例运行没有问题。
Theano是机器学习应用程序的一个很好的工具,但我发现它在Windows上的安装不是特别为初学者像我自己)在编程。在我的情况下,我看到在GPU上运行我的脚本5-6倍加速,所以这是绝对值得的麻烦。
我根据我的安装程序写了本指南,并且意味着冗长,希望即使对于没有预先了解在Windows环境下构建程序的人也能完成。本指南的大部分内容都是基于这些说明,但我必须更改一些步骤才能正常工作在我的系统上。如果有任何我做的,可能不是最佳的,或不能在您的机器上工作,请让我知道,我将尝试相应地修改本指南。
这些是我在Windows 8.1计算机上安装启用了GPU的Theano时遵循的步骤:
< h3> CUDA安装
CUDA可以从此处下载。在我的情况下,我选择64位笔记本版本为我的NVIDIA Optimus笔记本电脑与Geforce 750m。
通过从命令行启动 deviceQuery
,验证您的安装是否成功。在我的情况下,这是位于以下文件夹中: C:\ProgramData\NVIDIA Corporation \CUDA Samples\v6.5\bin\win64\Release
。如果成功,您应该在测试结束时看到PASS。
Visual Studio 2010安装
我通过 dreamspark 。如果你是一个学生,你有权获得一个免费版本。如果没有,您仍然可以安装 Express版本,它应该工作以及。安装完成后,您应该能够从开始菜单中调用Visual Studio命令提示符2010。
Python安装
在撰写本文时,Theano在GPU上只允许使用32位浮点数主要是为2.7版本的Python构建的。 Theano需要大多数基本的科学Python库,如 scipy
和 numpy
。我发现最简单的安装方式是通过 WinPython 。它安装所有的依赖项在一个自包含的文件夹,如果在安装过程中出现问题,你可以很容易重新安装,并得到一些有用的IDE工具,如ipython notebook和Spyder免费安装。为了易于使用,您可能需要在环境变量。
Git安装
找到这里。
MinGW安装
设置文件位于此处。我在安装过程中检查了所有的基本安装文件。如果你遇到下面描述的g ++错误,这是必需的。
Cygwin安装
您可以找到此处。我基本上使用这个实用程序只提取基本安装中已经提供的PyCUDA tar文件(所以安装应该很简单)。
Python distutils修复
打开 msvc9compiler.py
位于您的Python安装的 / lib / distutils /
目录中。在我的case 641行显示: ld_args.append('/ IMPLIB:'+ implib_file)
。在此行后面添加以下内容(相同缩进):
ld_args.append('/ MANIFEST')
或用户文件夹所在的位置:
)并执行
PyCUDA安装
PyCUDA的源代码是此处。
步骤:
打开cygwin并导航到PyCUDA文件夹code> / cygdrive / c / etc / etc
tar -xzf pycuda-2012.1.tar.gz
。
打开Visual Studio命令提示符2010并导航到tarball提取目录,并执行
python configure.py
打开./siteconf.py并更改值(例如对于CUDA 6.5):
BOOST_INC_DIR = []
BOOST_LIB_DIR = []
BOOST_COMPILER ='gcc43'
USE_SHIPPED_BOOST = True
BOOST_PYTHON_LIBNAME = ['boost_python']
BOOST_THREAD_LIBNAME = ['boost_thread']
CUDA_TRACE = False
CUDA_ROOT ='C:\\Program Files \\NVIDIA GPU计算工具包\\CUDA \\v6.5 '
CUDA_ENABLE_GL = False
CUDA_ENABLE_CURAND = True
CUDADRV_LIB_DIR = ['$ {CUDA_ROOT} / lib / Win32']
CUDADRV_LIBNAME = ['cuda']
CUDART_LIB_DIR = ['$ {CUDA_ROOT} / lib / Win32']
CUDART_LIBNAME = ['cudart']
CURAND_LIB_DIR = ['$ {CUDA_ROOT} / lib / Win32']
CURAND_LIBNAME = ']
CXXFLAGS = ['/ EHsc']
LDFLAGS = ['/ FORCE']
在VS2010命令提示符处执行以下命令:
设置VS90COMNTOOLS =%VS100COMNTOOLS%
python setup.py build
python setup.py install
创建此Python文件,获取结果:
#from:http://documen.tician.de/pycuda/tutorial.html
import pycuda.gpuarray as gpuarray
import pycuda.driver as cuda
import pycuda.autoinit
import numpy
a_gpu = gpuarray.to_gpu(numpy.random.randn(4,4) .astype(numpy.float32))
a_doubled =(2 * a_gpu).get()
print a_doubled
print a_gpu
安装Theano
打开git bash shell并选择要放置Theano安装文件并执行的文件夹:
git clone git://github.com/Theano/Theano.git
python setup.py install
尝试在VS2010命令提示符下打开python并运行
import theano
如果你得到一个g ++相关的错误,打开MinGW msys.bat在我的case安装在这里:
C:\MinGW\msys \1.0
并尝试在MinGW shell中导入theano。然后重试从VS2010命令提示符导入theano它应该是现在工作。
在写字板中创建文件(NOT Notepad!),将其命名为
.theanorc.txt
code> C:\Users\Your_Name\#!sh
[global]
device = gpu
floatX = float32
[nvcc]
compiler_bindir = C:\Program文件(x86)\Microsoft Visual Studio 10.0 \VC \bin
#flags = -m32#我们现在硬编码为
[blas]
ldflags =
#ldflags = -lopenblas#为openblas支持的占位符
创建测试python脚本并运行it:
来自theano导入函数,config,shared,sandbox
import theano.tensor as T
import numpy
导入时间
vlen = 10 * 30 * 768#10 x #cores x每个核心的线程数
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'循环%d次使用'%iters,t1 - t0,'秒'
print'Result is',r
if numpy.any([isinstance .op,T.Elemwise)for x in f.maker.fgraph.toposort()]):
print'使用cpu'
else:
print'使用gpu'
验证您是否有
使用gpu
你完成了!I understand that the Theano support for Windows 8.1 is at experimental stage only but I wonder if anyone had any luck with resolving my issues. Depending on my config, I get three distinct types of errors. I assume that the resolution of any of my errors would solve my problem.
I have installed Python using WinPython 32-bit system, using MinGW as described here. The contents of my
.theanorc
file are as follows:[global] openmp=False device = gpu [nvcc] flags=-LC:\TheanoPython\python-2.7.6\libs compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\ [blas] ldflags =
When I run
import theano
the error is as follows:nvcc fatal : nvcc cannot find a supported version of Microsoft Visual Studio. Only the versions 2010, 2012, and 2013 are supported ['nvcc', '-shared', '-g', '-O3', '--compiler-bindir', 'C:\\Program Files (x86)\\ Microsoft Visual Studio 10.0\\VC\\bin# flags=-m32 # we have this hard coded for now', '-Xlinker', '/DEBUG', '-m32', '-Xcompiler', '-DCUDA_NDARRAY_CUH=d67f7c8a21 306c67152a70a88a837011,/Zi,/MD', '-IC:\\TheanoPython\\python-2.7.6\\lib\\site-pa ckages\\theano\\sandbox\\cuda', '-IC:\\TheanoPython\\python-2.7.6\\lib\\site-pac kages\\numpy\\core\\include', '-IC:\\TheanoPython\\python-2.7.6\\include', '-o', 'C:\\Users\\Matej\\AppData\\Local\\Theano\\compiledir_Windows-8-6.2.9200-Intel6 4_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\cuda_ndarray\\cuda_ndarray .pyd', 'mod.cu', '-LC:\\TheanoPython\\python-2.7.6\\libs', '-LNone\\lib', '-LNon e\\lib64', '-LC:\\TheanoPython\\python-2.7.6', '-lpython27', '-lcublas', '-lcuda rt'] ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return st atus', 1, 'for cmd', 'nvcc -shared -g -O3 --compiler-bindir C:\\Program Files (x 86)\\Microsoft Visual Studio 10.0\\VC\\bin# flags=-m32 # we have this hard coded for now -Xlinker /DEBUG -m32 -Xcompiler -DCUDA_NDARRAY_CUH=d67f7c8a21306c67152a 70a88a837011,/Zi,/MD -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\thean o\\sandbox\\cuda -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\numpy\\co re\\include -IC:\\TheanoPython\\python-2.7.6\\include -o C:\\Users\\Matej\\AppDa ta\\Local\\Theano\\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepp ing_3_GenuineIntel-2.7.6-32\\cuda_ndarray\\cuda_ndarray.pyd mod.cu -LC:\\TheanoP ython\\python-2.7.6\\libs -LNone\\lib -LNone\\lib64 -LC:\\TheanoPython\\python-2 .7.6 -lpython27 -lcublas -lcudart') WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not availabl e
I have also tested it using
Visual Studio 12.0
which is installed on my system with the following error:mod.cu nvlink fatal : Could not open input file 'C:/Users/Matej/AppData/Local/Temp/tm pxft_00001b70_00000000-28_mod.obj' ['nvcc', '-shared', '-g', '-O3', '--compiler-bindir', 'C:\\Program Files (x86)\\ Microsoft Visual Studio 12.0\\VC\\bin\\', '-Xlinker', '/DEBUG', '-m32', '-Xcompi ler', '-LC:\\TheanoPython\\python-2.7.6\\libs,-DCUDA_NDARRAY_CUH=d67f7c8a21306c6 7152a70a88a837011,/Zi,/MD', '-IC:\\TheanoPython\\python-2.7.6\\lib\\site-package s\\theano\\sandbox\\cuda', '-IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages \\numpy\\core\\include', '-IC:\\TheanoPython\\python-2.7.6\\include', '-o', 'C:\ \Users\\Matej\\AppData\\Local\\Theano\\compiledir_Windows-8-6.2.9200-Intel64_Fam ily_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\cuda_ndarray\\cuda_ndarray.pyd' , 'mod.cu', '-LC:\\TheanoPython\\python-2.7.6\\libs', '-LNone\\lib', '-LNone\\li b64', '-LC:\\TheanoPython\\python-2.7.6', '-lpython27', '-lcublas', '-lcudart'] ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return st atus', 1, 'for cmd', 'nvcc -shared -g -O3 --compiler-bindir C:\\Program Files (x 86)\\Microsoft Visual Studio 12.0\\VC\\bin\\ -Xlinker /DEBUG -m32 -Xcompiler -LC :\\TheanoPython\\python-2.7.6\\libs,-DCUDA_NDARRAY_CUH=d67f7c8a21306c67152a70a88 a837011,/Zi,/MD -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\theano\\sa ndbox\\cuda -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\numpy\\core\\i nclude -IC:\\TheanoPython\\python-2.7.6\\include -o C:\\Users\\Matej\\AppData\\L ocal\\Theano\\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3 _GenuineIntel-2.7.6-32\\cuda_ndarray\\cuda_ndarray.pyd mod.cu -LC:\\TheanoPython \\python-2.7.6\\libs -LNone\\lib -LNone\\lib64 -LC:\\TheanoPython\\python-2.7.6 -lpython27 -lcublas -lcudart') WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not availabl e
In the latter error, several pop-up windows ask me how would I like to open (.res) file before error is thrown.
cl.exe
is present in both folders (i.e. VS 2010 and VS 2013).Finally, if I set VS 2013 in the environment path and set
.theanorc
contents as follows:[global] base_compiledir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin openmp=False floatX = float32 device = gpu [nvcc] flags=-LC:\TheanoPython\python-2.7.6\libs compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\ [blas] ldflags =
I get the following error:
c:\theanopython\python-2.7.6\include\pymath.h(22): warning: dllexport/dllimport conflict with "round" c:\program files\nvidia gpu computing toolkit\cuda\v6.5\include\math_functions.h(2455): here; dllimport/dllexport dropped mod.cu(954): warning: statement is unreachable mod.cu(1114): error: namespace "std" has no member "min" mod.cu(1145): error: namespace "std" has no member "min" mod.cu(1173): error: namespace "std" has no member "min" mod.cu(1174): error: namespace "std" has no member "min" mod.cu(1317): error: namespace "std" has no member "min" mod.cu(1318): error: namespace "std" has no member "min" mod.cu(1442): error: namespace "std" has no member "min" mod.cu(1443): error: namespace "std" has no member "min" mod.cu(1742): error: namespace "std" has no member "min" mod.cu(1777): error: namespace "std" has no member "min" mod.cu(1781): error: namespace "std" has no member "min" mod.cu(1814): error: namespace "std" has no member "min" mod.cu(1821): error: namespace "std" has no member "min" mod.cu(1853): error: namespace "std" has no member "min" mod.cu(1861): error: namespace "std" has no member "min" mod.cu(1898): error: namespace "std" has no member "min" mod.cu(1905): error: namespace "std" has no member "min" mod.cu(1946): error: namespace "std" has no member "min" mod.cu(1960): error: namespace "std" has no member "min" mod.cu(3750): error: namespace "std" has no member "min" mod.cu(3752): error: namespace "std" has no member "min" mod.cu(3784): error: namespace "std" has no member "min" mod.cu(3786): error: namespace "std" has no member "min" mod.cu(3789): error: namespace "std" has no member "min" mod.cu(3791): error: namespace "std" has no member "min" mod.cu(3794): error: namespace "std" has no member "min" mod.cu(3795): error: namespace "std" has no member "min" mod.cu(3836): error: namespace "std" has no member "min" mod.cu(3838): error: namespace "std" has no member "min" mod.cu(4602): error: namespace "std" has no member "min" mod.cu(4604): error: namespace "std" has no member "min" 31 errors detected in the compilation of "C:/Users/Matej/AppData/Local/Temp/tmpxft_00001d84_00000000-10_mod.cpp1.ii". ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 2, 'for cmd', 'nvcc -shared -g -O3 -Xlinker /DEBUG -m32 -Xcompiler -DCUDA_NDARRAY_CUH=d67f7c8a21306c67152a70a88a837011,/Zi,/MD -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\theano\\sandbox\\cuda -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\numpy\\core\\include -IC:\\TheanoPython\\python-2.7.6\\include -o C:\\Users\\Matej\\AppData\\Local\\Theano\\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\cuda_ndarray\\cuda_ndarray.pyd mod.cu -LC:\\TheanoPython\\python-2.7.6\\libs -LNone\\lib -LNone\\lib64 -LC:\\TheanoPython\\python-2.7.6 -lpython27 -lcublas -lcudart') ERROR:theano.sandbox.cuda:Failed to compile cuda_ndarray.cu: ('nvcc return status', 2, 'for cmd', 'nvcc -shared -g -O3 -Xlinker /DEBUG -m32 -Xcompiler -DCUDA_NDARRAY_CUH=d67f7c8a21306c67152a70a88a837011,/Zi,/MD -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\theano\\sandbox\\cuda -IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\numpy\\core\\include -IC:\\TheanoPython\\python-2.7.6\\include -o C:\\Users\\Matej\\AppData\\Local\\Theano\\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\cuda_ndarray\\cuda_ndarray.pyd mod.cu -LC:\\TheanoPython\\python-2.7.6\\libs -LNone\\lib -LNone\\lib64 -LC:\\TheanoPython\\python-2.7.6 -lpython27 -lcublas -lcudart') mod.cu ['nvcc', '-shared', '-g', '-O3', '-Xlinker', '/DEBUG', '-m32', '-Xcompiler', '-DCUDA_NDARRAY_CUH=d67f7c8a21306c67152a70a88a837011,/Zi,/MD', '-IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\theano\\sandbox\\cuda', '-IC:\\TheanoPython\\python-2.7.6\\lib\\site-packages\\numpy\\core\\include', '-IC:\\TheanoPython\\python-2.7.6\\include', '-o', 'C:\\Users\\Matej\\AppData\\Local\\Theano\\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.6-32\\cuda_ndarray\\cuda_ndarray.pyd', 'mod.cu', '-LC:\\TheanoPython\\python-2.7.6\\libs', '-LNone\\lib', '-LNone\\lib64', '-LC:\\TheanoPython\\python-2.7.6', '-lpython27', '-lcublas', '-lcudart']
If I run
import theano
without the GPU option on, it runs without a problem. Also CUDA samples run without a problem.解决方案Theano is a great tool for machine learning applications, yet I found that its installation on Windows is not trivial especially for beginners (like myself) in programming. In my case, I see 5-6x speedups of my scripts when run on a GPU so it was definitely worth the hassle.
I wrote this guide based on my installation procedure and is meant to be verbose and hopefully complete even for people with no prior understanding of building programs under Windows environment. Most of this guide is based on these instructions but I had to change some of the steps in order for it to work on my system. If there is anything that I do that may not be optimal or that doesn't work on your machine, please, let me know and I will try to modify this guide accordingly.
These are the steps (in order) I followed when installing Theano with GPU enabled on my Windows 8.1 machine:
CUDA Installation
CUDA can be downloaded from here. In my case, I chose 64-bit Notebook version for my NVIDIA Optimus laptop with Geforce 750m.
Verify that your installation was successful by launching
deviceQuery
from command line. In my case this was located in the following folder:C:\ProgramData\NVIDIA Corporation\CUDA Samples\v6.5\bin\win64\Release
. If successful, you should see PASS at the end of the test.Visual Studio 2010 Installation
I installed this via dreamspark. If you are a student you are entitled for a free version. If not, you can still install the Express version which should work just as well. After install is complete you should be able to call Visual Studio Command Prompt 2010 from the start menu.
Python Installation
At the time of writing, Theano on GPU only allows working with 32-bit floats and is primarily built for 2.7 version of Python. Theano requires most of the basic scientific Python libraries such as
scipy
andnumpy
. I found that the easiest way to install these was via WinPython. It installs all the dependencies in a self-contained folder which allows easy reinstall if something goes wrong in the installation process and you get some useful IDE tools such as ipython notebook and Spyder installed for free as well. For ease of use you might want to add the path to your python.exe and path to your Scripts folder in the environment variables.Git installation
Found here.
MinGW Installation
Setup file is here. I checked all the base installation files during the installation process. This is required if you run into g++ error described below.
Cygwin installation
You can find it here. I basically used this utility only to extract PyCUDA tar file which is already provided in the base install (so the install should be straightforward).
Python distutils fix
Open
msvc9compiler.py
located in your/lib/distutils/
directory of your Python installation. Line 641 in my case reads:ld_args.append ('/IMPLIB:' + implib_file)
. Add the following after this line (same indentation):ld_args.append('/MANIFEST')
PyCUDA installation
Source for PyCUDA is here.
Steps:
Open cygwin and navigate to the PyCUDA folder (i.e.
/cygdrive/c/etc/etc
) and executetar -xzf pycuda-2012.1.tar.gz
.Open Visual Studio Command Prompt 2010 and navigate to the directory where tarball was extracted and execute
python configure.py
Open the ./siteconf.py and change the values so that it reads (for CUDA 6.5 for instance):
BOOST_INC_DIR = [] BOOST_LIB_DIR = [] BOOST_COMPILER = 'gcc43' USE_SHIPPED_BOOST = True BOOST_PYTHON_LIBNAME = ['boost_python'] BOOST_THREAD_LIBNAME = ['boost_thread'] CUDA_TRACE = False CUDA_ROOT = 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v6.5' CUDA_ENABLE_GL = False CUDA_ENABLE_CURAND = True CUDADRV_LIB_DIR = ['${CUDA_ROOT}/lib/Win32'] CUDADRV_LIBNAME = ['cuda'] CUDART_LIB_DIR = ['${CUDA_ROOT}/lib/Win32'] CUDART_LIBNAME = ['cudart'] CURAND_LIB_DIR = ['${CUDA_ROOT}/lib/Win32'] CURAND_LIBNAME = ['curand'] CXXFLAGS = ['/EHsc'] LDFLAGS = ['/FORCE']
Execute the following commands at the VS2010 command prompt:
set VS90COMNTOOLS=%VS100COMNTOOLS% python setup.py build python setup.py install
Create this python file and verify that you get a result:
# from: http://documen.tician.de/pycuda/tutorial.html import pycuda.gpuarray as gpuarray import pycuda.driver as cuda import pycuda.autoinit import numpy a_gpu = gpuarray.to_gpu(numpy.random.randn(4,4).astype(numpy.float32)) a_doubled = (2*a_gpu).get() print a_doubled print a_gpu
Install Theano
Open git bash shell and choose a folder in which you want to place Theano installation files and execute:
git clone git://github.com/Theano/Theano.git python setup.py install
Try opening python in VS2010 command prompt and run
import theano
If you get a g++ related error, open MinGW msys.bat in my case installed here:
C:\MinGW\msys\1.0
and try importing theano in MinGW shell. Then retry importing theano from VS2010 Command Prompt and it should be working now.Create a file in WordPad (NOT Notepad!), name it
.theanorc.txt
and put it inC:\Users\Your_Name\
or wherever your users folder is located:#!sh [global] device = gpu floatX = float32 [nvcc] compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin # flags=-m32 # we have this hard coded for now [blas] ldflags = # ldflags = -lopenblas # placeholder for openblas support
Create a test python script and run it:
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'
Verify you got
Used the gpu
at the end and you're done!这篇关于在启用GPU的Windows 8上安装theano的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!