PyCuda and Windows
These last few days I have been busy trying to install PyCuda for Windows, but Windows sucks a bit in these things, so it took quite a bit of time. This is a post documenting my Odyssey.
First of all, I had no luck at all with Python 2.6. After two days I got it to compile, but it couldn’t load the module, so I installed 2.5 again. You absolutely need Visual Studio 2003 because I couldn’t get either MinGW or the VC++ Toolkit to work in compiling.
The first step is to get the Boost sources (not binaries) and build them with bjam with this command line:
This will take a while, so relax. You basically need two or three files, boost_python-something and boost_thread-something, so you can start the next step as soon as these are done. I did not mess with trying to get it to compile only these.
After this is done, you should have a “stage” dir in the main boost source dir. Get PyCuda 0.93 beta (0.92 didn’t work), and use this siteconf.py file in the PyCuda dir:
BOOST_LIB_DIR = ['C:\\boost_1_38_0\\stage\\lib']
BOOST_PYTHON_LIBNAME = ['libboost_python-mgw34']
BOOST_THREAD_LIBNAME = ['libboost_thread-mgw34-mt']
CUDA_ROOT = 'C:\\CUDA'
CUDADRV_LIB_DIR = ['C:\\CUDA\\lib']
CUDADRV_LIBNAME = ['cuda']
CXXFLAGS = []
LDFLAGS = []
Obviously, you should change the paths to whatever you have. Do a “python setup.py build” in the PyCuda dir and it should build the files. Install them with “python setup.py install” as usual, and everything should be fine. If it complains about cl.exe when trying to run your script, make sure the VS2003 environment variables are set (run the bat file MS gives you).
I’m pretty sure I’ve missed a step, because this thing took me three or four days of puzzling out and sleeping at 6 am. I hope it is of use to anyone (or me, in the future), that my toil may not go in vain.
EDIT: Oh, hey, actually, you know what? Here you go. Just have the binary. On me, no worries. Put the boost_python-vc71-mt-1_38.dll somewhere in your path and you’re good to go.
It seems to be related to the unregistered dll. when I try to register it with regsvr32 it says the dll entry point can'be found...
Submitted by Anonymous (not verified) on Sat, 18/04/2009 - 04:00.Hmm, no, I think there's a bug in pyCUDA and you need to change a line. Can you paste the traceback? If it's something about "getuid not available in windows" or something, you need to remove the call and replace it with some random word.
Submitted by Stavros on Sat, 18/04/2009 - 09:58.I am not sure if it is a traceback. When I try to regsvr32 c:\Py...etc. it opens in a dialog box and says:
c:\Python25\DLLs\boost_python-cb71-mt-1_38.dll was loaded, but the DllRegisterServer entry point was not found. This file can not be registered.
Submitted by Anonymous (not verified) on Mon, 20/04/2009 - 14:28.You don't have to register the DLL.
Submitted by Stavros on Mon, 20/04/2009 - 14:33.I've got the following at IDLE:
IDLE 1.2.4
>>> import pycuda as cu
>>> dir()
['__builtins__', '__doc__', '__name__', 'cu']
>>> dir(cu)
['__builtins__', '__doc__', '__file__', '__name__', '__path__']
>>> import pycuda.autoinit
Traceback (most recent call last):
File "", line 1, in
import pycuda.autoinit
File "C:\Python25\lib\site-packages\pycuda\autoinit.py", line 1, in
import pycuda.driver as cuda
File "C:\Python25\lib\site-packages\pycuda\driver.py", line 2, in
from pytools.diskdict import DiskDict
ImportError: No module named pytools.diskdict
>>> import pycuda.driver as drv
Traceback (most recent call last):
Submitted by Anonymous (not verified) on Mon, 20/04/2009 - 15:02.File "", line 1, in
import pycuda.driver as drv
File "C:\Python25\lib\site-packages\pycuda\driver.py", line 2, in
from pytools.diskdict import DiskDict
ImportError: No module named pytools.diskdict
>>> inport numpy
SyntaxError: invalid syntax
You need to install pytools.
Submitted by Stavros on Mon, 20/04/2009 - 15:12.Which call do I have to replace? I've replaced the os.getuid for os.getpid, which is present in windows and IDLE says:
Traceback (most recent call last):
Submitted by Anonymous (not verified) on Tue, 21/04/2009 - 08:30.File "", line 1, in
import pycudatest
File "C:\Python25\pycudatest.py", line 11, in
""")
File "C:\Python25\lib\site-packages\pycuda\driver.py", line 413, in __init__
_SourceModule.__init__(self, *args, **kwargs)
File "C:\Python25\lib\site-packages\pycuda\compiler.py", line 128, in __init__
arch, code, cache_dir)
File "C:\Python25\lib\site-packages\pycuda\compiler.py", line 119, in compile
return compile_plain(source, options, keep, nvcc, cache_dir)
File "C:\Python25\lib\site-packages\pycuda\compiler.py", line 67, in compile_plain
raise CompileError, "nvcc compilation of %s failed" % cu_file_path
CompileError: nvcc compilation of c:\docume~1\admini~1\locals~1\temp\tmpyl3th1\kernel.cu failed
That's correct. You probably have a C syntax error.
Submitted by Stavros on Tue, 21/04/2009 - 11:06.Hi, I downloaded pycuda and others.
windows_vista+cygwin+python2.5+numpy+setuptools-6.9+pytools-9 => then I got this error message :
zipimport.ZipImportError: can't decompress data; zlib not availableI install zlib using cygwin.
how do I install pycuda my pc ?
Submitted by Anonymous (not verified) on Fri, 09/10/2009 - 08:04.Hmm, I'm not quite sure about that, you don't have to install it with Cygwin though... I'd probably google the error and see, because last time I checked the binary was working fine...
Submitted by Stavros on Fri, 09/10/2009 - 08:16.