3

This Theano Installation is making me mad :(

So, I've followed the instructions here on the most voted answer because it seemed like the most similar condiguration from mine and up-to-date version : Installing theano on Windows 8 with GPU enabled

1- I've installed Cuda v6.5, launched deviceQuery and it works fine.

2- I already have Visual Studio 2013 so I haven't installed Visual Studio 2010

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

So i don't know exactly what is the current state now but I have a friend with the same configuration than mine and he managed to make it work so I guess it's possible. I've installed Python through Anaconda.

4- I've installed MinGW and Cygwin

5- I've fixed msvc9compiler.py

6- Here's the bottleneck : the PyCUDA Installation

Here's what I've done: - I've used cygwin to extract the pycuda tar file - I've executed python configure.py through VS2013 x64 Native Tools Command Prompt than configured siteconfig.py as followed:

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', '${CUDA_ROOT}/lib/x64']
CUDADRV_LIBNAME = ['cuda']
CUDART_LIB_DIR = ['${CUDA_ROOT}/lib', '${CUDA_ROOT}/lib/x64']
CUDART_LIBNAME = ['cudart']
CURAND_LIB_DIR = ['${CUDA_ROOT}/lib', '${CUDA_ROOT}/lib/x64']
CURAND_LIBNAME = ['curand']
CXXFLAGS = ['/EHsc', '-DBOOST_NO_TYPEID']
LDFLAGS = ['/FORCE']
  • I've executed python setup.py build --compiler="msvc" through VS2013 x64 Native Tools Command Prompt
  • I've executed python setup.py install through VS2013 x64 Native Tools Command Prompt
  • When I execute the little test in python, here's what's happening:

    PS C:\users\jmm\desktop> python test.py
    
    Vendor:  Continuum Analytics, Inc.
    
    Package: mkl
    
    Message: trial mode expires in 29 days
    
    Traceback (most recent call last):
    
      File "test.py", line 7, in <module>
        a_doubled = (2*a_gpu).get()
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\gpuarray.py", line 471, in __rm
    ul__
        return self._axpbz(scalar, 0, result)
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\gpuarray.py", line 333, in _axp
    bz
        func = elementwise.get_axpbz_kernel(self.dtype, out.dtype)
    
      File "<string>", line 2, in get_axpbz_kernel
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\tools.py", line 423, in context
    _dependent_memoize
        result = func(*args)
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\elementwise.py", line 417, in g
    et_axpbz_kernel
        "axpb")
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\elementwise.py", line 157, in g
    et_elwise_kernel
        arguments, operation, name, keep, options, **kwargs)
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\elementwise.py", line 143, in g
    et_elwise_kernel_and_types
        keep, options, **kwargs)
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\elementwise.py", line 71, in ge
    t_elwise_module
        options=options, keep=keep)
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\compiler.py", line 251, in __in
    it__
        arch, code, cache_dir, include_dirs)
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\compiler.py", line 241, in comp
    ile
        return compile_plain(source, options, keep, nvcc, cache_dir)
    
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\compiler.py", line 73, in compi
    le_plain
        checksum.update(preprocess_source(source, options, nvcc).encode("utf-8"))
      File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\compiler.py", line 52, in prepr
    ocess_source
        cmdline, stderr=stderr)
    
    pycuda.driver.CompileError: nvcc preprocessing of c:\users\jmm\appdata\local\temp\tmp32jnzb.cu failed
    [command: nvcc --preprocess -arch sm_30 -m64 -Ic:\users\jmm\anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg
    \pycuda\cuda c:\users\jmm\appdata\local\temp\tmp32jnzb.cu --compiler-options -EP]
    [stderr:
    tmp32jnzb.cu
    'C:\Program' n'est pas reconnu en tant que commande interne
    ou externe, un programme exécutable ou un fichier de commandes.
    ]
    

Could you please tell me why the hell this doesn't work ?

Community
  • 1
  • 1
orangejaipur
  • 51
  • 1
  • 5

5 Answers5

2

I have written a practical guide for the whole process:

https://my6266blog.wordpress.com/2015/01/21/installing-theano-pylearn2-and-even-gpu-on-windows/

Good luck! It's not that complicated, just follow the steps one by one.

MZHm
  • 2,388
  • 1
  • 18
  • 24
1

You probably need to add the path to the executables for Visual Studio in your nvcc.profile

(you can find it in your CUDA bin folder. On my system: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin).

In my case, since I have Visual studio 2010, I added at the end of nvcc.profile:

"compiler-bindir =  C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"
parakmiakos
  • 2,994
  • 9
  • 29
  • 43
1

Actually you don't need to install pycuda to get theano working on your windows machine. I'm not an expert but I have Theano installed on Windows 8.1.

This is my laptop config: 64-bit, nvcc/cuda 6.5, Python 2.7.9, WinPython-64bit-2.7.9.3, Windows 8.1, VS2013 and two graphic units (Intel HD Graphics 4600 and NVIDIA GeForce GT 750M).

Buzz Lightyear
  • 61
  • 1
  • 1
  • 5
1

The process was a pretty big hassle, so here is a tutorial for anyone that is interested:

All of this has been tested using a clean install of Windows 8.1, with nothing else on it, though it should work fine if you don't have a clean install because this will install all the required versions of the software for you.

You need 64-bit windows, 32 bit will not work. You will also need a CUDA compatible graphics card, so if you don’t have one you’re stuck for now, sadly. This means that you need a relatively modern NVIDIA graphics card, AMD will not work (it can run OpenCL but not CUDA because CUDA is lame and proprietary).

I am installing this on Windows 8.1, but I suspect it should all still work on windows 7 as well.

First download WinPython, (make sure to get python 2.7, version 2.7.10.3, this link points to there) and install it TO A PATH THAT DOES NOT HAVE SPACES IN IT. OTHERWISE THINGS BREAK. I made an Other folder in C:\ (C:\Other) and then made a folder named Python27 (C:\Other\Python27) and tell the installer to install it in there.

Once it is done installing, you will need to add it to your path. Press the windows key and type environment variables, then click “Edit the System Environment Variables”, click Environment Variables in the windows that pops up, scroll down to Path, and then append

C:\Other\Python27\python-2.7.10.amd64

Or wherever else you installed WinPython to

Then add a semicolon after it, so you get

C:\Other\Python27\python-2.7.10.amd64;

This is how you add a specific path to the Path variables, in the future, I will just say to add it here and now give specific steps about how to do that. Note that if you update the system path, the current command prompt windows that are open won’t get that update, and you will have to open a new command prompt window to actually have it use the new path.

The purpose of a path is so your command prompt window knows where programs are, because if you call, say

python

in the command prompt, it will look through every folder in your path until it finds a python.exe. If it can’t find any, it will get angry as it typically would if that program didn’t exist.

If you don’t want to clutter your path variable/if your path variable is full, I put a tutorial here about how to make it so your path is just appended to when you open a command prompt window via a text file that stores all the paths, instead of having to edit the environment variable itself, if you are interested.

You then need to add

C:\Other\Python27\python-2.7.10.amd64\DLL;
C:\Other\Python27\python-2.7.10.amd64\Scripts;

to your path as well (again, or wherever else you installed python. For later on I will just say where I installed it and if you installed it somewhere else it should be pretty easy to just tweak the commands accordingly)

Next, install visual studio 2015 community and visual studio 2013, making sure to install all the tools related to c++ development as well (using custom installation, then under Programming Languages). These don’t need to be in a path without spaces, and they probably won’t let you store them anywhere else anyway and that is OK.

Add

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin;

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64;

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib;

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\amd64;

To your system path.

Install NOT NEWEST DRIVER BECAUSE THEY ARE UNSTABLE, but instead 355.60 because it is known to be very reliable, and new enough. Then install the CUDA toolkit (it’s also okay to store this in a path with spaces, it probably won’t give you the option either, but even if it does, just let it store it in the default place it wants to store it to). Version 6.5 is needed because version 7 and above aren’t supported by pycuda. If you have a GTX 9__ you will need to download CUDA from here instead.

This will probably automatically append

C:\Program Files (x86)\Windows Kits\8.1\Redist\D3D\x64;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\libnvvp;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;

To your path, if not you will need to do so now.

Those are the only three things that can be stored to paths with spaces (these will be in like Program Files or Program Files (x86)), with everything else be very careful to store them to paths that don’t have spaces.

Download the boost binaries (1_55_0 for 64 bit which is the version this link points to), and run the installer, then select to store them to a path without spaces (I stored them to C:\Other\boost)

Navigate to that directory in the command line, then run

bootstrap.bat

and then when it is done run

.\b2

This will start building, and take a long time, and use a lot of space (about 6 GB).

It will probably say that 8 targets failed, 8 targets were skipped, and 1075 were updated. This is what one should expect, and is not a problem.

Install Git-2.7.0-64-bit to some path without a space in it

Choose to use Git from the Windows Command Prompt, checkout Windows-style, commit Unix-style endings, use Window’s default console window, and do not enable file system caching.

Add

C:\Other\Git\bin;

To your system path

Next, run the installer for VCForPython.

Download pycuda source (pycuda-2015.1.3)

Navigate inside that directory, then run

python configure.py

this will create a file named siteconf.py.

Open this file, and it should look something like

BOOST_INC_DIR = []
BOOST_LIB_DIR = []
BOOST_COMPILER = 'gcc43'
USE_SHIPPED_BOOST = True
BOOST_PYTHON_LIBNAME = ['boost_python-py27']
BOOST_THREAD_LIBNAME = ['boost_thread']
CUDA_TRACE = False
CUDA_ROOT = 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v6.5'
CUDA_INC_DIR = ['${CUDA_ROOT}/include']
CUDA_ENABLE_GL = False
CUDA_ENABLE_CURAND = True
CUDADRV_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CUDADRV_LIBNAME = ['cuda']
CUDART_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CUDART_LIBNAME = ['cudart']
CURAND_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CURAND_LIBNAME = ['curand']
CXXFLAGS = []
LDFLAGS = []

modify it so it looks like:

BOOST_INC_DIR = ['C:/Other/boost']
BOOST_LIB_DIR = ['C:/Other/boost/lib64-msvc-12.0']
BOOST_COMPILER = 'msvc'
USE_SHIPPED_BOOST = True
BOOST_PYTHON_LIBNAME = ['boost_python-vc120-mt-1_55']
BOOST_THREAD_LIBNAME = ['boost_thread-vc110-mt-1_55']
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', '${CUDA_ROOT}/lib/x64']
CUDADRV_LIBNAME = ['cuda']
CUDART_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CUDART_LIBNAME = ['cudart']
CURAND_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CURAND_LIBNAME = ['curand']
CXXFLAGS = ['/DBOOST_PYTHON_STATIC_LIB', '/EHsc']
LDFLAGS = ['/LIBPATH:C:\\Other\\boost\\/lib64-msvc-12.0', '/FORCE']

then run

python setup.py build

followed by

python setup.py install

This should install pycuda for you =)

To install Theano (with GPU enabled), download release 0.7, unzip it, navigate inside it using a command prompt, and then type

python setup.py install

then go and edit system environment variables, and create one named

THEANO_FLAGS

and set it’s value to

device=gpu,floatX=float32

Then open a new command prompt, and if you have completed all of the steps above, this should work well =) You can run the code here to make sure that you are actually running off the GPU.

Community
  • 1
  • 1
Phylliida
  • 4,217
  • 3
  • 22
  • 34
0

I was able to get Theano installed on my ASUS K501LX Windows 8.1 laptop, with an NVIDIA GeForce 950M GPU, without any hassle whatsoever. I largely followed Maor's post above from March 29th. I was actually shocked at how easy it was! All I needed was the Community Edition of Visual Studio 2013 and the CUDA 7 Toolkit. I then installed Anaconda 3.4 (I used the latest version that's out there now). The one modification I made to Maor's post was installing mingw, via conda install mingw libpython immediately after installing Anaconda. Also, since I am using Python 3, I had to change the flags parameter in .theanorc.txt to point to C:\Anaconda3\libs.

Upon importing theano, it returned that it was using my GeForce GTX 950M device, and running the theano\misc\check_blas.py check returned no errors and carried out its tests on my GPU.

Happy times!

Damian Kozlak
  • 7,065
  • 10
  • 45
  • 51