PyOpenCL

PyOpenCL lets you access the OpenCL parallel computation API from Python. Here's what sets PyOpenCL apart:

  • Object cleanup tied to lifetime of objects. This idiom, often called RAII in C++, makes it much easier to write correct, leak- and crash-free code.
  • Completeness. PyOpenCL puts the full power of OpenCL’s API at your disposal, if you wish.
  • Convenience. While PyOpenCL's primary focus is to make all of OpenCL accessible, it tries hard to make your life less complicated as it does so--without taking any shortcuts.
  • Automatic Error Checking. All OpenCL errors are automatically translated into Python exceptions.
  • Speed. PyOpenCL’s base layer is written in C++, so all the niceties above are virtually free.
  • Helpful, complete documentation and a wiki.
  • Liberal licensing (MIT).

Documentation

See the PyOpenCL Documentation.

Support

Having trouble with PyOpenCL? First, you may want to check the PyOpenCL Wiki. If that doesn't help, maybe the nice people on the PyOpenCL mailing list can.

Download

Download PyOpenCL here.

Or get it directly from my source code repository by typing

git clone --recursive http://git.tiker.net/trees/pyopencl.git

You may also browse the source.

Prerequisites: All you need is an OpenCL implementation. And Python obviously.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Andreas,

Sorry for making troubles, but spent a few days but can't build PyOpenCL against MacOS X 10.6. I went through procedures described in Wiki, but I've got the output:

alexandr-kuzmins-macbook:pyopencl-0.91.4 shurik$ python configure.py --boost-inc-dir=/usr/local/include --boost-lib-dir=/usr/local/lib --boost-python-libname=boost_python --boost-thread-libname=boost_thread --cl-libname='' --ldflags='-W1,-framework,OpenCL' --boost-compiler='gcc42'
Creating /Users/shurik/Downloads/pyopencl-0.91.4/setuptools-0.6c9-py2.6.egg-info
Creating /Users/shurik/Downloads/pyopencl-0.91.4/setuptools.pth
alexandr-kuzmins-macbook:pyopencl-0.91.4 shurik$ make
ctags -R src || true
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
/Library/Frameworks/Python.framework/Versions/6.0.0/Resources/Python.app/Contents/MacOS/Python setup.py build
/Users/shurik/Downloads/pyopencl-0.91.4/setuptools-0.6c9-py2.6.egg-info already exists
running build
running build_py
creating build
creating build/lib.macosx-10.5-i386-2.6
creating build/lib.macosx-10.5-i386-2.6/pyopencl
copying pyopencl/__init__.py -> build/lib.macosx-10.5-i386-2.6/pyopencl
copying pyopencl/version.py -> build/lib.macosx-10.5-i386-2.6/pyopencl
running build_ext
building '_cl' extension
creating build/temp.macosx-10.5-i386-2.6
creating build/temp.macosx-10.5-i386-2.6/src
creating build/temp.macosx-10.5-i386-2.6/src/wrapper
gcc -fno-strict-aliasing -fno-common -dynamic -I/Library/Frameworks/Python.framework/Versions/6.0.0/include -O3 -DNDEBUG -Isrc/cpp -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/6.0.0/include/python2.6 -c src/wrapper/wrap_cl.cpp -o build/temp.macosx-10.5-i386-2.6/src/wrapper/wrap_cl.o -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk
src/wrapper/wrap_cl.cpp: In function ‘void init_module__cl()’:
src/wrapper/wrap_cl.cpp:83: warning: deprecated conversion from string constant to ‘char*’
src/wrapper/wrap_cl.cpp:87: warning: deprecated conversion from string constant to ‘char*’
src/wrapper/wrap_cl.cpp:88: warning: deprecated conversion from string constant to ‘char*’
src/wrapper/wrap_cl.cpp:89: warning: deprecated conversion from string constant to ‘char*’
src/wrapper/wrap_cl.cpp: In function ‘void init_module__cl()’:
src/wrapper/wrap_cl.cpp:83: warning: deprecated conversion from string constant to ‘char*’
src/wrapper/wrap_cl.cpp:87: warning: deprecated conversion from string constant to ‘char*’
src/wrapper/wrap_cl.cpp:88: warning: deprecated conversion from string constant to ‘char*’
src/wrapper/wrap_cl.cpp:89: warning: deprecated conversion from string constant to ‘char*’
g++ -g -L/usr/local/lib -L/Library/Frameworks/Python.framework/Versions/6.0.0/lib -bundle -undefined dynamic_lookup -arch i386 build/temp.macosx-10.5-i386-2.6/src/wrapper/wrap_cl.o -L/usr/local/lib -lboost_python -lboost_thread -o build/lib.macosx-10.5-i386-2.6/pyopencl/_cl.so -W1 -framework OpenCL -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -Wl,-framework,OpenCL
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk/usr/local/lib/libboost_python.dylib, file is not of required architecture
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk/usr/local/lib/libboost_thread.dylib, file is not of required architecture

It seems to me that it wants to build it against MacOSX10.5 and link with BOOST Libraries built on MacOSX10.6. Any comment is appreciated.

Thank you, Alex shurik.kuzmin@gmail.com

I was going to recommend that you ask on the mailing list for a solution, but it appears you've already done so. :)

Andreas

Very nice. Works great. Thanks!

PS! The OpenCL link has got a typo (http://khronos.org/openl should be http://khronos.org/opencl)

Fixed, thanks!

Andreas

Hello,

I've installed PyOpenCL on Mac OS X 10.6, after a little bit of tweaking, but now when I try to run the example I get this error:

Traceback (most recent call last): File "demo.py", line 1, in import pyopencl as cl File "/Library/Python/2.6/site-packages/pyopencl-0.90-py2.6-macosx-10.6-i386.egg/pyopencl/init.py", line 5, in import pyopencl._cl as _cl ImportError: dlopen(/Library/Python/2.6/site-packages/pyopencl-0.90-py2.6-macosx-10.6-i386.egg/pyopencl/_cl.so, 2): Symbol not found: _clUnloadCompiler Referenced from: /Library/Python/2.6/site-packages/pyopencl-0.90-py2.6-macosx-10.6-i386.egg/pyopencl/_cl.so Expected in: flat namespace in /Library/Python/2.6/site-packages/pyopencl-0.90-py2.6-macosx-10.6-i386.egg/pyopencl/_cl.so

I'm out of ideas, if you could give me a hand I would be very glad, my email is royger at gmail dot com

This comment received a reply on the mailing list. -Andreas