Note this method will probably also work for 32 bit - just substitute 32 bit versions of software. Also, for 32 bit can probably use VS 2008 Express Edition plus relevant Windows SDK. I had problems with this because it didn't seem to install the x64 compilers.

Instructions by Sam Adams

Please don't forget that this is a Wiki. If you feel like you can improve these instructions, please don't hesitate to do so. There's an edit button in the header, and you won't even need an account or any such nonsense.

Binaries

Christoph Gohlke at UC Irvine has made binary packages of PyCUDA that might be able to save you the trouble of building PyCUDA yourself. You can find them on his page of Python packges.

Using Visual Studio 2008

This set of instructions has not been updated for the removal of the Boost dependency in 0.94. If you use these instructions, please perform the necessary updates (and remove this note)! Thanks! -- AndreasKloeckner 2010-09-21 00:22:05

boost 1.38: I suggest using BoostPro installer as that enables you to just install the Boost libraries you need (much faster than compiling all of Boost!)

CUDA 2.2 (185.xx driver)

Windows XP 32-bit

First of all - you need git version for Windows (git is a version control system). Then get (with git) a fresh copy of PyCUDA. To do this open GitBash and type in the command line

git clone http://git.tiker.net/trees/pycuda.git

You need to have and use Visual Studio 2008 (previous version does not seem to work).

I recommend to use BoostPro installer, boost 1.38, which can interactively install binary dlls and libs. You need only the ones for Version 9 of MSVC, and make sure you get a DLL variant. Also make sure you install the Boost Python, Boost DateTime, and BoostThreadlibraries, otherwise the PyCUDA setup won't work.

Then put this text into PyCUDA's source directory as siteconf.py (potentially with adapted paths):

After driver installation (python setup.py install), copy all boost dlls into windows/system32 directory or add the path to it. You minimally need boost_python-vc90-mt-1_38.dll and boost_thread-vc90-mt-1_38.dll.

Finally, add a HOME environment variable in Windows: it doesn't matter what it is, so you can make it "123456" or your My Documents directory, etc.

(Instructions by {loginovdv, wuzzyview} at gmail com. Instead of emailing him directly, please go to the PyCuda/MailingList for support.)

Another Visual Studio 2008 Win64 example (February 2012)

This example of a siteconf.py uses a custom-built boost, and is using the boost auto-link capability to choose the Python and Thread libnames. It's also linking with the boost libraries statically, so you don't have to fiddle with boost DLLs.

This was not documented, but I found it necessary to also install compyte. Installing compyte was also undocumented, but what seems to work is cloning the repository at https://github.com/inducer/compyte/, then simply copying the cloned compyte folder into the pycuda installation directory. In my case, this created the folder C:\Python27\Lib\site-packages\pycuda-2011.2.2-py2.7-win-amd64.egg\pycuda\compyte.

After building with the above siteconf.py and installing compyte (which didn't seem to require any C++ building), I was able to run the 3 test files in pycuda/test successfully (except for a complaint about needing the Mako template system, which I then proceeded to install).

For examples with dynamic compilations, you'll want to run the appropriate vcvars32.bat/vcvars64.bat before running the Python interpreter.

Using Visual Studio 2008 (alternative on June 2010)

This set of instructions has not been updated for the removal of the Boost dependency in 0.94. If you use these instructions, please perform the necessary updates (and remove this note)! Thanks! -- AndreasKloeckner 2010-09-21 00:22:05

boost 1.38 from source, note that 1.41 did not work on Windows (details below)

CUDA 2.3 (update - works with 3.0 too)

Windows XP 32-bit

Follow the above instructions for Visual Studio 2008. The only difference is the use of boost from source.

Get Boost v1.38 source and the pre-compiled bjam via the Sourceforge Boost page. Note that v1.41 (latest when written in Jan 2010) did not work for pyCUDA. When compiling the python Boost library it insisted on linking to PYTHON25.DLL which does not exist on my machine. Switching back to v1.38 and compiling from source worked first time, it correctly linked to PYTHON26.DLL. Details in this thread includes references to DependencyWalker for debugging.

I used boost-jam-3.1.18-1-ntx86.zip and boost_1_38_0.7z.

Read the index.html file and then compile Boost v1.38 using:

bjam --build-type=complete stage # complete means build all the libs/dlls, stage puts the libs into ./stage/lib
# note you can add --debug-configuration to get debug info for details of e.g. the compiler and Python version it finds

This is a working siteconf.py (created first by running configure.py):

and you'll have a working pyCUDA (check that your build/install process finishes without any errors).

Next you have to setup your PATH, go to the Start menu, Settings, Control Panel, choose System, go to the Advanced tab, select Environment Variables. Under System Variables you'll find "Path". Copy all of it into a text editor and take a look at it.

You'll almost certainly see existing references to CUDA (from the CUDA package) and Python in the path looking like:

C:\CUDA\bin;
C:\Python26;

You now need to add the Boost library directory (including stage\lib) by adding something like the following:

The \bin directory contains "cl.exe", the "Common7\IDE" contains necessary DLLs you'll get an error on screen telling you the DLLs it can't find - you just need to locate them and add the right directory. The easiest way to test this is to open a new Command Prompt and type "cl.exe" - if it isn't found then your path isn't configured. If it runs OK then "cl.exe" will be seen by nvcc.

You should also add "HOME" as an environment variable, it isn't used but it is required (if you don't add it you'll get an obvious error message saying it needs to know where HOME is), I used:

HOME=pycuda;

You add it by adding a New environment variable on the same screen where you can edit the PATH.

To test first open a new Command Prompt (so you get the new PATH info you configured above) and try:

cd examples
python measure_gpuarray_speed_random.py

and you should see a simple memory benchmark running, you will see that your GPU outperforms your CPU for the larger memory transfers.

Using MinGW

This set of instructions has not been updated for the removal of the Boost dependency in 0.94. If you use these instructions, please perform the necessary updates (and remove this note)! Thanks! -- AndreasKloeckner 2010-09-21 00:22:05

The following instructions can be used to install PyCUDA on a Windows machine with Visual Studio 2005. The issue that this solves is related to building python extensions when python was built with Visual Studio 2003. The MinGW compiler can be used to work around this issue.

PyCUDA can be built and installed using the MinGW compiler. You can use MinGW which is installed with python(x,y), which is a nice Python development environment. The python(x,y) installer places the MinGW compiler into the PATH variable. I used python(x,y) 2.1.14.

For all of the commands that require a command prompt, I used the ‘open console here’ option in the Windows Explorer context menu that is created when python(x,y) is installed.

Build the Boost thread and python libraries using the MinGW compiler and the toolset=gcc command line argument with bjam. For example, assuming boost is installed in C:\boost_1_39_0:

Make sure that the Visual Studio cl.exe compiler is in the PATH. For example, C:\Program Files\Microsoft Visual Studio 8\VC\bin.

Make sure that the boost libs are in the PATH. For example, C:\boost_1_39_0\stage\lib.

Change to the PyCUDA examples directory and run demo.py after setting the HOME environment variable to 123456. The demo should run without error.

(Instructions by Frank Buckle, fbuckle at gmail com. Instead of emailing him directly, please go to the PyCuda/MailingList for support.)

Windows Vista 64-bit with Visual Studio 2008

This set of instructions has not been updated for the removal of the Boost dependency in 0.94. If you use these instructions, please perform the necessary updates (and remove this note)! Thanks! -- AndreasKloeckner 2010-09-21 00:22:05

(see also this blog post) (the following instructions seems to work on Windows 7(x64) too. Test.py passes) I successfully built and passed the test_driver.py script on Windows Vista 64-bit (x64, amd64) with Visual Studio 2008. My configuration:

Python 2.6, using the amd64 installer on the web site

Numpy 1.3.0 built from source. The 1.3.0 amd64 installer on their web site seems to be compiled with something other than Visual Studio 2008 and, after installation, it crashes when I import numpy. Building from source with Visual Studio 2008 seems to make it more stable, despite the warning that support is not perfect on 64 bit Windows.

pycuda from git (I used 0.94 beta)

boost 1.39: As above, I suggest using BoostPro installer, but only you only need the Boost header files, Source and Documentation and Tools.

In the prompt, navigate to your boost directory (The example assumes C:\boost\boost_1_39). You need to compile the python, thread and date_time libraries. This should create dll's and libraries in the stage directory under your boost unzip.

bjam.exe is the boost jam executable. On other versions(such as 1.40) this file may be located in another path. You may need to add extra information into the user-config.jam located in C:\boost\boost_1_39\tools\build\v2

Note this method will probably also work for 32 bit - just substitute 32 bit versions of software. Also, for 32 bit can probably use VS 2008 Express Edition plus relevant Windows SDK. I had problems with this because it didn't seem to install the x64 compilers.

Here is my step-by-step adaptation of Christoph Bussler's directions to Windows 8 64 bit. May also work on windows 7, but I haven't tested it. If you can't find any of the specific package versions, then install the latest x64 build for your version of python.