Python 在启用 GPU 的 Windows 8 上安装 theano

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25729969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 23:33:24  来源:igfitidea点击:

Installing theano on Windows 8 with GPU enabled

pythonwindowscudamingwtheano

提问by Matt

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.

我知道 Theano 对 Windows 8.1 的支持仅处于试验阶段,但我想知道是否有人有幸解决我的问题。根据我的配置,我收到三种不同类型的错误。我认为解决我的任何错误都会解决我的问题。

I have installed Python using WinPython 32-bit system, using MinGW as described here. The contents of my .theanorcfile are as follows:

我已经使用 WinPython 32 位系统安装了 Python,使用此处描述的 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 = 

When I run import theanothe error is as follows:

当我运行时import theano,错误如下:

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.0which is installed on my system with the following error:

我还使用Visual Studio 12.0安装在我的系统上的它进行了测试,但出现以下错误:

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.

在后一个错误中,有几个弹出窗口询问我想在抛出错误之前如何打开 (.res) 文件。

cl.exeis present in both folders (i.e. VS 2010 and VS 2013).

cl.exe存在于两个文件夹中(即 VS 2010 和 VS 2013)。

Finally, if I set VS 2013 in the environment path and set .theanorccontents as follows:

最后,如果我在环境路径中设置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 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 theanowithout the GPU option on, it runs without a problem. Also CUDA samples run without a problem.

如果我在import theano没有打开 GPU 选项的情况下运行,它运行没有问题。CUDA 样本也可以正常运行。

采纳答案by Matt

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.

Theano 是机器学习应用程序的一个很好的工具,但我发现它在 Windows 上的安装并不是微不足道的,尤其是对于编程初学者(比如我自己)。就我而言,在 GPU 上运行时,我的脚本速度提高了 5-6 倍,因此这绝对值得麻烦。

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 instructionsbut 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.

我根据我的安装过程编写了本指南,即使对于事先不了解在 Windows 环境下构建程序的人来说,它也很详细,希望能完成。本指南的大部分内容都基于这些说明,但我必须更改一些步骤才能使其在我的系统上运行。如果我所做的任何事情可能不是最佳的或在您的机器上不起作用,请告诉我,我将尝试相应地修改本指南。

These are the steps (in order) I followed when installing Theano with GPU enabled on my Windows 8.1 machine:

这些是我在 Windows 8.1 机器上安装启用 GPU 的 Theano 时遵循的步骤(按顺序):

CUDA Installation

CUDA 安装

CUDA can be downloaded from here. In my case, I chose 64-bit Notebook version for my NVIDIA Optimus laptop with Geforce 750m.

CUDA 可以从这里下载。就我而言,我为配备 Geforce 750m 的 NVIDIA Optimus 笔记本电脑选择了 64 位笔记本电脑版本。

Verify that your installation was successful by launching deviceQueryfrom 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.

通过deviceQuery从命令行启动来验证您的安装是否成功。在我的情况下,它位于以下文件夹中:C:\ProgramData\NVIDIA Corporation\CUDA Samples\v6.5\bin\win64\Release. 如果成功,您应该在测试结束时看到 PASS。

Visual Studio 2010 Installation

Visual Studio 2010 安装

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 versionwhich should work just as well. After install is complete you should be able to call Visual Studio Command Prompt 2010 from the start menu.

我是通过Dreampark安装的。如果您是学生,您有权获得免费版本。如果没有,您仍然可以安装Express 版本,它应该也能正常工作。安装完成后,您应该可以从开始菜单调用 Visual Studio 命令提示符 2010。

Python Installation

Python安装

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 scipyand numpy. 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.

在撰写本文时,GPU 上的 Theano 仅允许使用 32 位浮点数,并且主要为 2.7 版本的 Python 构建。Theano 需要大多数基本的科学 Python 库,例如scipynumpy。我发现安装这些最简单的方法是通过WinPython。它将所有依赖项安装在一个独立的文件夹中,如果安装过程中出现问题,可以轻松重新安装,并且您还可以免费安装一些有用的 IDE 工具,例如 ipython notebook 和 Spyder。为了便于使用,您可能需要在环境变量中添加 python.exe 的路径和 Scripts 文件夹的路径。

Git installation

Git安装

Found here.

这里找到。

MinGW Installation

MinGW安装

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.

安装文件在这里。我在安装过程中检查了所有基本安装文件。如果您遇到下面描述的 g++ 错误,这是必需的。

Cygwin installation

Cygwin 安装

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

你可以在这里找到它。我基本上只使用此实用程序来提取基本安装中已提供的 PyCUDA tar 文件(因此安装应该很简单)。

Python distutils fix

Python distutils 修复

Open msvc9compiler.pylocated 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):

打开msvc9compiler.py位于/lib/distutils/您的 Python 安装目录中。在我的情况下,641行写着:ld_args.append ('/IMPLIB:' + implib_file)。在此行之后添加以下内容(相同的缩进):

ld_args.append('/MANIFEST')

PyCUDA installation

PyCUDA 安装

Source for PyCUDA is here.

PyCUDA 的来源在这里

Steps:

脚步:

Open cygwin and navigate to the PyCUDA folder (i.e. /cygdrive/c/etc/etc) and execute tar -xzf pycuda-2012.1.tar.gz.

打开 cygwin 并导航到 PyCUDA 文件夹(即/cygdrive/c/etc/etc)并执行tar -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

打开 Visual Studio Command Prompt 2010 并导航到解压缩并执行 tarball 的目录 python configure.py

Open the ./siteconf.py and change the values so that it reads (for CUDA 6.5 for instance):

打开 ./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 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:

在 VS2010 命令提示符下执行以下命令:

set VS90COMNTOOLS=%VS100COMNTOOLS%
python setup.py build
python setup.py install

Create this python file and verify that you get a result:

创建此 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

Install Theano

安装 Theano

Open git bash shell and choose a folder in which you want to place Theano installation files and execute:

打开 git bash shell 并选择要放置 Theano 安装文件的文件夹并执行:

git clone git://github.com/Theano/Theano.git
python setup.py install

Try opening python in VS2010 command prompt and run import theano

尝试在 VS2010 命令提示符下打开 python 并运行 import theano

If you get a g++ related error, open MinGW msys.bat in my case installed here: C:\MinGW\msys\1.0and try importing theano in MinGW shell. Then retry importing theano from VS2010 Command Prompt and it should be working now.

如果您遇到与 g++ 相关的错误,请在我安装的情况下打开 MinGW msys.bat:C:\MinGW\msys\1.0并尝试在 MinGW shell 中导入 theano。然后重试从 VS2010 命令提示符导入 theano,它现在应该可以工作了。

Create a file in WordPad (NOT Notepad!), name it .theanorc.txtand put it in C:\Users\Your_Name\or wherever your users folder is located:

在写字板(不是记事本!)中创建一个文件,命名并将其.theanorc.txt放在C:\Users\Your_Name\用户文件夹所在的位置或任何位置:

#!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:

创建一个测试 python 脚本并运行它:

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 gpuat the end and you're done!

验证你已经Used the gpu到了最后,你就完成了!

回答by brentlance

Here's a guide to installing theano with CUDA on 64-bit Windows.

这是在 64 位 Windows 上使用 CUDA 安装 theano 的指南。

It seems straightforward, but I have not actually tested it to ensure that it works.

这看起来很简单,但我还没有真正测试过它以确保它有效。

http://pavel.surmenok.com/2014/05/31/installing-theano-with-gpu-on-windows-64-bit/

http://pavel.surmenok.com/2014/05/31/installing-theano-with-gpu-on-windows-64-bit/

回答by super-truite

Following the tutorial by Matt, I ran into issues with nvcc. I needed to add the path to VS2010 executables in nvcc.profile (you can find it in the cuda bin folder):

按照 Matt 的教程,我遇到了 nvcc 的问题。我需要在 nvcc.profile 中添加 VS2010 可执行文件的路径(您可以在 cuda bin 文件夹中找到它):

"compiler-bindir = C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"

"compiler-bindir = C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"

回答by Christian Schr?der de Witt

In case you want to upgrade to MS Visual Studio 2012 and CUDA 7 on Windows 8.1 x64, check out this tutorial here:

如果您想在 Windows 8.1 x64 上升级到 MS Visual Studio 2012 和 CUDA 7,请在此处查看本教程:

http://machinelearning.berlin/?p=383

http://machinelearning.berlin/?p=383

It should work as long as you stick to it exactly. All the best

只要你完全坚持它,它就应该有效。祝一切顺利

Christian

基督教

回答by tangkk

Here are my simple steps for installing theano on a 64-bit windows 10 machine. It's tested on the code listed here

这是我在 64 位 Windows 10 机器上安装 theano 的简单步骤。它已在此处列出的代码上进行了测试

(All installation are with default installation path)

(所有安装均采用默认安装路径)

  • install anaconda python 3.x distribution (it already includes numpy, scipy, matlibplot, etc.)
  • run 'conda install mingw libpython' in command-line
  • install theano by downloading it from the official website and do `python setup.py install'
  • install lastest CUDA toolkit for 64-bit windows 10 (now is 7.5)
  • install visual studio 2013 (free for windows 10)
  • create .theanorc.txt file under %USERPROFILE% path and here are the content in the .theanorc.txt file to run theano with GPU
  • 安装 anaconda python 3.x 发行版(它已经包含 numpy、scipy、matlibplot 等)
  • 在命令行中运行“conda install mingw libpython”
  • 通过从官方网站下载来安装 theano 并执行`python setup.py install'
  • 为 64 位 Windows 10 安装最新的 CUDA 工具包(现在是 7.5)
  • 安装 Visual Studio 2013(Windows 10 免费)
  • 在 %USERPROFILE% 路径下创建 .theanorc.txt 文件,这里是 .theanorc.txt 文件中的内容以使用 GPU 运行 theano


[global]

[全球的]

floatX = float32

浮动X = 浮动32

device = gpu

设备 = GPU

[nvcc]

[nvcc]

fastmath = True

快速数学 = 真

compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe

compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe

[cuda]

[CUDA]

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5

C:\Program Files\NVIDIA GPU 计算工具包\CUDA\v7.5



回答by Sunando

I could compile the cu files by adding the required dependencies in the nvcc profile located in “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin\nvcc.profile”

我可以通过在位于“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin\nvcc.profile”的 nvcc 配置文件中添加所需的依赖项来编译 cu 文件

I modified the include and the lib path and it started working.

我修改了包含和 lib 路径,它开始工作。

INCLUDES += “-I$(TOP)/include” $(SPACE) “-IC:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/include” $(SPACE) “-IC:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include” $(SPACE) LIBRARIES =+ $(SPACE) “/LIBPATH:$(TOP)/lib/$(_WIN_PLATFORM_)” $(SPACE) “/LIBPATH:C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/lib/amd64” $(SPACE) “/LIBPATH:C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64” $(SPACE)

INCLUDES += “-I$(TOP)/include” $( SPACE) “-IC:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/include” $( SPACE) “-IC:\Program Files (x86) )\Microsoft SDKs\Windows\v7.1A\Include” $( SPACE) LIBRARIES =+ $( SPACE) “/LIBPATH:$(TOP)/lib/$(_WIN_PLATFORM_)” $( SPACE) “/LIBPATH:C: /Program Files (x86)/Microsoft Visual Studio 12.0/VC/lib/amd64” $( SPACE) “/LIBPATH:C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64” $(空间)

I have made a full documentation of the install, hope it helps https://planetanacreon.wordpress.com/2015/10/09/install-theano-on-windows-8-1-with-visual-studio-2013-cuda-7-5/

我已经制作了安装的完整文档,希望它有所帮助https://planetanacreon.wordpress.com/2015/10/09/install-theano-on-windows-8-1-with-visual-studio-2013-cuda -7-5/

回答by Ilya Raykhel

I used this guide, and it was quite helpful. What many of Windows Theano guides only mention in passing (or not at all) is that you will need to compile theano from mingw shell, not from your IDE.

我使用了这个指南,它很有帮助。许多 Windows Theano 指南只是顺便提到(或根本没有提到)是您需要从 mingw shell 编译 theano,而不是从您的 IDE。

I ran mingw-w64.bat, and from there "python" and "import theano". Only after that importing it from pycharm works.

我运行了mingw-w64.bat,然后从那里“python”和“import theano”。只有在那之后从 pycharm 导入它才有效。

Additionally, official instructions on deeplearning.net are bad because they tell you to use CUDA 5.5, but it won't work with newer video cards.

此外,deeplearning.net 上的官方说明很糟糕,因为它们告诉您使用 CUDA 5.5,但它不适用于较新的视频卡。

The comments are also quite helpful. If it complains about missing crtdefs.h or basetsd.h, do what Sunando's answer says. If AFTER THAT it still complains that identifier "Iunknown" is undefined in objbase.h, stick the following in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\objbase.h file, on line 236:

评论也很有帮助。如果它抱怨缺少 crtdefs.h 或 basetsd.h,请按照 Sunando 的回答进行操作。如果之后它仍然抱怨 objbase.h 中未定义标识符“Iunknown”,请将以下内容粘贴到 C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\objbase.h 文件中,第 236 行:

#include <wtypes.h>
#include <unknwn.h>

I had to do this last part to make it work with bleeding edge install (required for parts of Keras).

我必须做最后一部分才能使其与前沿安装一起工作(Keras 的部分需要)。

I also wrote a list of things that worked for me, here: http://acoupleofrobots.com/everything/?p=2238This is for 64 bit version.

我还写了一份对我有用的清单,在这里:http: //acoupleofrobots.com/everything/?p=2238这是 64 位版本。