Installing PyOpenCL on Windows
- Installing PyOpenCL on Windows
- Installation from binary
- Installation from source
Before you try building PyOpenCL for Windows yourself, you may want to consider trying:
Installation from binary
Windows Vista Professional
- Install PyOpenCL
- get pyopencl-0.92.win-amd64-py2.7.?exe
And that worked right away without any further installation or modification.
Windows 7/8 and Python 3.3 (32bit)
Using the (32bit) appropriate exe-packages from www.lfd.uci.edu/~gohlke/pythonlibs/ under (a 32bit) Py3.3 on Windows (v7, 64bit, and also v8, 32bit) worked fine for me, except that pytools need the "decorator" module (https://pypi.python.org/pypi/decorator) which then isn't present, and so I used the pytools package directly from pypi with the standard "python setup.py install" command which then pulls in "decorator" automagically. Then "import pyopencl" worked. Later I also had to install the mako package to get some actual code running (IIRC). Thanks, Sven.
Installation from source
Windows XP Installation
This set of instruction builds boost separately. This should, in theory, not be required. If you encounter problems when setting USE_SHIPPED_BOOST to True, please complain on the mailing list with your error output! -- AndreasKloeckner 2013-01-13 15:00:22
I followed Windows 7 instructions below on Windows XP with python 2.7 and the installation worked. But then I got this error, when tried to import pyopencl. The error was resolved by installing pyopencl on python 2.6.4. (Not sure if the error was because of version mismatch or because of installing python 2.7 before Boost.) Ghasem 2011-09-30 00:00:17
Installation of PyOpenCL is similar to installation of PyCUDA, with some obvious modifications.
The following were installed prior to installing PyOpenCL:
- Python setuptools 0.6c9 (installation from egg requires ez_setup.py from source; google for more info)
Run "python configure.py" in the pyopencl directory to get a sample siteconfig.py, then edit as appropriate. Here's my edited siteconfig.py:
BOOST_INC_DIR = [r'C:\Program Files\boost\boost_1_39'] BOOST_LIB_DIR = [r'C:\Program Files\boost\boost_1_39\lib'] BOOST_COMPILER = 'msvc' BOOST_PYTHON_LIBNAME = ['boost_python-vc90-mt-1_39'] BOOST_THREAD_LIBNAME = ['boost_thread-vc90-mt-1_39'] CL_TRACE = False SHIPPED_CL_HEADERS = False USE_SHIPPED_BOOST = False CL_INC_DIR = [r'C:\Program Files\ATI Stream\include'] CL_LIB_DIR = [r'C:\Program Files\ATI Stream\lib\x86'] CL_LIBNAME = ['OpenCL'] CXXFLAGS = ['/EHsc', '/DBOOST_PYTHON_NO_PY_SIGNATURES'] LDFLAGS = ['/FORCE']
Then run "python setup.py install" in the pyopencl directory.
After driver installation, copy all boost dlls into windows/system32 directory or add the path to it. You minimally need boost_python-vc90-mt-1_39.dll and boost_thread-vc90-mt-1_39.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.
A user was kind enough to supply a PDF installation manual, which might be of help.
*Edit: Was able to get pyopencl working in Win7 64 Bit, VS2010, and Py2.7 using options given for XP. Thanks for that. Had to run setup.py twice since it didn't go through completely due to mt.exe error (some one needs to add quotes for all paths). Now, import pyopencl as cl works like a charm.
Windows 7 64bit, Python 2.7, Visual Studio 2010, CUDA 4.1
After a conversation with Andreas and reading the suggestions in this wiki, I was able to use the above configuration following these steps:
Installed Python 2.7 (Active Python Community Edition 188.8.131.52 64bit) - downloaded from http://www.activestate.com/activepython/downloads
Downloaded PyOpenCL doing: git clone http://git.tiker.net/trees/pyopencl.git (this step produces "pyopencl" directory at the current location)
cd pyopencl git submodule init git submodule update
- the above step is necessary, w.r.t to downloading PyOpenCL 2011.2, as the git repository contains some fixes which results otherwise in phtread.h missing
edit C:\Python27\Lib\distutils\msvc9compiler.py and add after line 641 (which reads "ld_args.append ('/IMPLIB:' + implib_file)") a new line which reads "ld_args.append('/MANIFEST')" - this fixes problems with the use of Visual Studio 2010
- open now your Visual Studio 2010 64bit Command prompt with administrator rights
- cd into your pyopencl directory
- issue the command "python configure.py"
- edit the siteconf.py file to be:
BOOST_INC_DIR =  BOOST_LIB_DIR =  BOOST_COMPILER = 'gcc43' BOOST_PYTHON_LIBNAME = ['boost_python'] USE_SHIPPED_BOOST = True CL_TRACE = False CL_ENABLE_GL = True CL_ENABLE_DEVICE_FISSION = True CL_INC_DIR = [r'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\include', r'C:\Program Files\Microsoft SDKs\Windows\v7.1\Include'] CL_LIB_DIR = [r'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\lib\x64', r'C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64'] CL_LIBNAME = ['OpenCL'] CXXFLAGS = ['/EHsc'] LDFLAGS = ['/FORCE']
- type "set VS90COMNTOOLS=%VS100COMNTOOLS%"
- type python setup.py install
- let the compiler compile PyOpenCL, no error messages should appear, after the installation process is terminated you can remove the pyopencl directory
Windows 7 64bit, Python 2.7, Visual Studio 2010, Intel OpenCL SDK 1.5
Intel SDK currently supports a range of CPUs (Core 2, i3, i5, i7, maybe others ?) and can be used for OpenCL development and testing where access to a GPU is not possible (e.g. many laptops)
Please follow the above instructions for Win 7 64bith with CUDA 4.1, with the only exception that the siteconf.py should be:
BOOST_INC_DIR =  BOOST_LIB_DIR =  BOOST_COMPILER = 'gcc43' BOOST_PYTHON_LIBNAME = ['boost_python'] USE_SHIPPED_BOOST = True CL_TRACE = False CL_ENABLE_GL = True CL_ENABLE_DEVICE_FISSION = True CL_INC_DIR = [r'C:\Program Files (x86)\Intel\OpenCL SDK\1.5\include', r'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\Include'] CL_LIB_DIR = [r'C:\Program Files (x86)\Intel\OpenCL SDK\1.5\lib\x64', r'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\Lib\x64'] CL_LIBNAME = ['OpenCL'] CXXFLAGS = ['/EHsc'] LDFLAGS = ['/FORCE']
Building PyOpenCL with Visual Studio 2010
Python 2.6 is built with VS2008, but we can make some small changes to make it work with VS2010.
VS2010 requires you specify /MANIFEST to link.exe if you want a manifest file. So edit your Python26\Lib\distutils\msvc9compiler.py, and add the following to line 636
Then type the below before running python setup.py install, to trick Python in to using VS2010
You'll need to build Boost with VS2010. To build boost, from the boost directory type
bjar --build-type=complete --with-python install
then edit the siteconf.py to point to the new .lib files in c:\boost\lib, and run python setup.py install
This is similar to Windows XP but with a couple changes.
Installing Visual Studio C++ 2008 Express didn't provide all the necessary headers such as windows.h. To get these I had to download the Microsoft Windows SDK and add its paths to the siteconf too. Here was my siteconf.py:
BOOST_INC_DIR = [r'C:\Program Files (x86)\boost\boost_1_39'] BOOST_LIB_DIR = [r'C:\Program Files (x86)\boost\boost_1_39\lib'] BOOST_COMPILER = 'msvc' BOOST_PYTHON_LIBNAME = ['boost_python-vc90-mt-1_39'] #BOOST_THREAD_LIBNAME = ['boost_thread-vc90-mt-1_39'] USE_SHIPPED_BOOST = False CL_TRACE = False CL_ENABLE_GL = False CL_INC_DIR = [r'C:\Program Files (x86)\ATI Stream\include', r'C:\Program Files\Microsoft SDKs\Windows\v6.0\Include'] CL_LIB_DIR = [r'C:\Program Files (x86)\ATI Stream\lib\x86', r'C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib'] CL_LIBNAME = ['OpenCL'] CXXFLAGS = ['/EHsc', '/DBOOST_PYTHON_NO_PY_SIGNATURES'] LDFLAGS = ['/FORCE']
Boost is not required but PyOpenCL wouldn't compile for me without it.