PyOpenCL in Ubuntu repositories

Ubuntu Maverick Meerkat (10.10) contains PyOpenCL packages for architectures amd64 and i386 in multiverse. Package is called python-pyopencl and depends on NVIDIA drivers.

For Ubuntu Lucid Lynx (10.04 LTS) there is PPA with backported python-pyopencl packages: https://launchpad.net/~fajran/+archive/opencl

To be able to install PyOpenCL in Lucid Lynx you can:

Add ppa:fajran/opencl to the Software Sources

or add following lines to the software sources list /etc/apt/sources.list:

deb http://ppa.launchpad.net/fajran/opencl/ubuntu lucid main 
deb-src http://ppa.launchpad.net/fajran/opencl/ubuntu lucid main 

Installing PyOpenCL on Ubuntu

These instructions were originally written for Ubuntu 9.10 but have been updated for Ubuntu 11.04. Older versions work just like this, except for a changed boost version number. You may also look at the generic instructions if you'd like to install manually.

Step 0: Install OpenCL

There are many sources for the OpenCL SDK. Here we use the AMD source. Runs on any x86 64bit platform:

wget http://developer.amd.com/Downloads/AMD-APP-SDK-v2.6-lnx64.tgz
tar zxvf AMD-APP-SDK-v2.6-lnx64.tgz
chmod +x Install-AMD-APP.sh
./Install-AMD-APP.sh
tar zxvf icd-registration.tgz
sudo cp -r etc/OpenCL/* /etc/OpenCL/

(there may be ldconfig errors, they can be ignored)

Step 1: Install Boost and numpy

Use synaptic or apt-get to install python-setuptools python-numpy libboost1.38-dev or libboost1.40-all-dev

sudo apt-get install python-setuptools python-numpy libboost1.40-all-dev

Step 2: Download and unpack PyOpenCL

Download PyOpenCL and unpack it:

$ tar xfz pyopencl-VERSION.tar.gz

Step 3: Build PyOpenCL

For the AMD Stream (64bit)

$ cd pyopencl-VERSION # if you're not there already
$ python configure.py \
  --boost-inc-dir=/usr/include/boost \
  --boost-lib-dir=/usr/lib \
  --no-use-shipped-boost \
  --boost-python-libname=boost_python-mt-py26 \
  --cl-inc-dir=/etc/ati-stream-sdk-v2.0-beta4-lnx64/include \
  --cl-lib-dir=/etc/ati-stream-sdk-v2.0-beta4-lnx64/lib/x86_64 \
  --cl-libname=OpenCL

If instead of the AMD SDK, you have the ATI Stream (64bit) beta4-implementation:

$ cd pyopencl-VERSION # if you're not there already
$ python configure.py \
  --boost-inc-dir=/usr/include/boost \
  --boost-lib-dir=/usr/lib \
  --no-use-shipped-boost \
  --boost-python-libname=boost_python-mt-py26 \
  --cl-inc-dir=/opt/AMDAPP/include \
  --cl-lib-dir=/opt/AMDAPP/lib/x86_64 \
  --cl-libname=OpenCL

If you want to compile in 32bit, change the cl-lib-dir from x86_64 to x86. You Should you also change -lnx64 to lnx32 in ati-stream-sdk-v2.0-beta4-lnx64.

The configure.py command converts the command line arguments in a siteconfig.py configuration file. You can later edit it, if necessary. You should delete it if you want to run configure.py again.

Now type:

$ make
$ sudo make install

Now you should be done with compiling and installing. You can test it with

cd examples
python demo.py

Putting it all together

Here is a complete script starting from scratch for downloading, configuring, and installing OpenCL and pyOpenCL, and running the examples. Tested a x86_64 Ubuntu 11.04:

wget http://developer.amd.com/Downloads/AMD-APP-SDK-v2.6-lnx64.tgz
tar zxvf AMD-APP-SDK-v2.6-lnx64.tgz
chmod +x Install-AMD-APP.sh
./Install-AMD-APP.sh
tar zxvf icd-registration.tgz
sudo cp -r etc/OpenCL/* /etc/OpenCL/
rm -r etc

sudo apt-get install python-numpy libboost1.40-all-dev python-setuptools

wget http://pypi.python.org/packages/source/p/pyopencl/pyopencl-2011.2.tar.gz
tar xfz pyopencl-2011.2.tar.gz
cd pyopencl-2011.2/
python configure.py                            \
   --boost-inc-dir=/usr/include/boost          \
   --boost-lib-dir=/usr/lib                    \
   --no-use-shipped-boost                      \
   --boost-python-libname=boost_python-mt-py26 \
   --cl-inc-dir=/opt/AMDAPP/include/           \
   --cl-lib-dir=/opt/AMDAPP/lib/x86_64         \
   --cl-libname=OpenCL 
make
sudo make install
cd examples
python demo.py


CategoryPyOpenCl

PyOpenCL/Installation/Linux/Ubuntu (last edited 2013-02-20 23:20:20 by tor21)