Differences between revisions 42 and 43
Revision 42 as of 2015-09-29 08:47:56
Size: 12011
Editor: ::ffff:87
Revision 43 as of 2016-06-30 15:06:49
Size: 12158
Editor: pool-96-230-30-198
Comment: update Python(x, y) urls
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
 [[http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl|the binary version distributed by Christoph Gohlke]]

 [[https://code.google.com/p/pythonxy|PythonXY]] with the [[https://code.google.com/p/pythonxy/wiki/AdditionalPlugins|pyopencl plugin for PythonXY]]
 the [[http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl|binary version distributed by Christoph Gohlke]] (see the additional notes below)

 the [[https://sourceforge.net/projects/python-xy/files/plugins/|pyopencl plugin for Python(x, y)]] which works with either [[http://python-xy.github.io/|Python(x, y)]] or the [[https://www.python.org/downloads/windows/|standard 32-bit CPython 2.7 distribution]]

Installing PyOpenCL on Windows

Before you try building PyOpenCL for Windows yourself, you may want to consider trying:

Installation from binary

Windows Vista Professional

And that worked right away without any further installation or modification.

Christoph Bussler

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 10 64 bit, Python 3.4, PyOpenCL/Git Master, MingWPy, Nvidia CUDA 7.5

Successfully built from github source. Please note that OpenCL 1.2 instruction set not available on Fermi only Kepler/Maxwell GPUs -- Blair 2015-09-29 00:00:17

> pip install -i https://pypi.anaconda.org/carlkl/simple mingwpy
  • Clone a copy of PyOpenCL from Github

    • Edit .\src\c_wrapper\wrap_constants.cpp and add "#undef CONST" after include statements, i.e.

#include "wrap_cl.h"
#include <iostream>

#undef CONST

extern "C"
  • Edit ".\pyopencl\compyte\ndarray\gen_elemwise.py" and ".\pyopencl\compyte\ndarray\test_gpu_ndarray.py" and convert most Python 2.x style print statements to python 3 syntax. Basically wrap print arguments in brackets "(..)" and ignore any lines containing StringIO ">>" operator.

  • Run

> python configure.py
  • Edit siteconf.py to following:

CL_TRACE = False
CL_INC_DIR = ['c:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.5\\include']
CL_LIB_DIR = ['C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.5\\lib\\x64']
CXXFLAGS = ['-std=c++0x']
  • Run following commands.

> python setup.py build_ext --compiler=mingw32 
> python setup.py install

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 64bit) - downloaded from http://www.activestate.com/activepython/downloads

  • Installed NumPy from 1.6.1 (numpy-MKL-1.6.1.win-amd64-py2.7.exe) - kindly provided in binary format at http://www.lfd.uci.edu/~gohlke/pythonlibs/

  • 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_PYTHON_LIBNAME = ['boost_python']
CL_TRACE = False
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']
CXXFLAGS = ['/EHsc']
  • 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_PYTHON_LIBNAME = ['boost_python']
CL_TRACE = False
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']
CXXFLAGS = ['/EHsc']

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

Windows 7

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_PYTHON_LIBNAME = ['boost_python-vc90-mt-1_39']
#BOOST_THREAD_LIBNAME = ['boost_thread-vc90-mt-1_39']
CL_TRACE = 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']

Boost is not required but PyOpenCL wouldn't compile for me without it.

Windows 7, VS2010, Python 3.4, OpenCL

Assumes you've built boost using:

b2.exe toolset=msvc-10.0 variant=release threading=multi

Be sure to find the correct version of boost_python*.lib and plug it into BOOST_PYTHON_LIBNAME,

BOOST_INC_DIR = ['C:/local/boost_1_56_0']
BOOST_LIB_DIR = ['C:/local/boost_1_56_0/stage/lib']
BOOST_PYTHON_LIBNAME = ['boost_python3-vc100-mt-1_56']
CL_TRACE = False
CL_INC_DIR = ['C:/Program Files (x86)\AMD APP SDK/3.0-0-Beta/include']
CL_LIB_DIR = ['C:/Program Files (x86)\AMD APP SDK/3.0-0-Beta/lib/x86_64']

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:

  1. Microsoft Visual Studio C++ 2008 Express

  2. ATI Stream SDK v2 Beta or Nvidia's OpenCL GPU driver and OpenCL SDK

  3. Python 2.6.4

  4. Numpy 1.3 and SciPy 0.7.1 (not sure if SciPy is really needed)

  5. Boost 1.39 precompiled version (Multithreaded DLLs and libraries, compiled against MSVC 9.0, including DateTime, Python and Thread)

  6. 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_PYTHON_LIBNAME = ['boost_python-vc90-mt-1_39']
BOOST_THREAD_LIBNAME = ['boost_thread-vc90-mt-1_39']
CL_TRACE = False
CL_INC_DIR = [r'C:\Program Files\ATI Stream\include']
CL_LIB_DIR = [r'C:\Program Files\ATI Stream\lib\x86']

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.

PyOpenCL/Installation/Windows (last edited 2016-06-30 15:06:49 by pool-96-230-30-198)