Differences between revisions 27 and 28
Revision 27 as of 2015-06-22 09:21:05
Size: 5497
Editor: ::ffff:130
Comment: some update with lastest change and experience
Revision 28 as of 2016-05-20 05:30:08
Size: 1309
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
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''':
Ubuntu Maverick Meerkat (10.10) and later contain PyOpenCL packages for architectures amd64 and i386 in multiverse. Package is called python-pyopencl and depends on NVIDIA drivers.
Line 13: Line 5:
deb http://ppa.launchpad.net/fajran/opencl/ubuntu lucid main
deb-src http://ppa.launchpad.net/fajran/opencl/ubuntu lucid main
apt-get install python-pyopencl
Line 16: Line 7:
= Installing PyOpenCL on Ubuntu =
{{{#!wiki note
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:
Line 23: Line 8:
Download AMP APP from [[http://developer.amd.com/tools-and-sdks/opencl-zone/amd-accelerated-parallel-processing-app-sdk/download-archive/|here]] after accepting licence and run or
Line 26: Line 11:
tar zxvf AMD-APP-SDK-v[version]-lnx64.tgz
sudo ./Install-AMD-APP.sh
apt-get install python3-pyopencl
Line 29: Line 13:
(there may be ldconfig errors, they can be ignored)
Line 31: Line 14:
== Step 1: Install Boost and numpy ==
Use synaptic or apt-get to install python-setuptools python-numpy and libboost1.55-all-dev

{{{
sudo apt-get install python-setuptools python-numpy libboost1.55-all-dev
}}}
== Step 2: Download and unpack PyOpenCL ==
[[PyPi: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=/opt/AMDAPP/include \
  --cl-lib-dir=/opt/AMDAPP/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=/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 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.

Even writing the code above, some parameters are not always well taken into account on '''siteconfig.py '''configuration file, you may need to edit it with your favourite text editor.

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
}}}

PyOpenCL in Ubuntu repositories

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

apt-get install python-pyopencl

or

apt-get install python3-pyopencl

Additional Notes (Dell Inspiron laptop with Intel and Nvidia cards)

I am using Ubuntu 12.04 on a Dell Inspiron laptop. I needed to install bumblebee in order to use the Nvidia graphics card. In order to run tests, I needed to do

optirun python examples/benchmark.py

which gave me the error

clRetainDevice, version OPENCL_1.2 not defined in file libOpenCL.so.1

It turns out optirun redefines my LD_LIBRARY_PATH so now I pick up libOpenCL.so.1 from /usr/lib/nvidia-current/libOpenCL.so.1 where I want the one from /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 Once I moved it, for example with

#mv /usr/lib/nvidia-current/libOpenCL.so.1{,.1}

running the benchmark (under optirun, don't forget) gave me

clGetPlatformIDs failed: platform not found khr

which was solved by

#echo libnvidia-opencl.so.1 >> /etc/OpenCL/vendors/nvidia.icd


CategoryPyOpenCl

PyOpenCL/Installation/Linux/Ubuntu (last edited 2016-05-20 05:30:08 by AndreasKloeckner)