Monday, 20 July 2015

How to install OpenCL for Nvidia GPUs on Ubuntu

These instructions are for installing the Ubuntu packages that contain the necessary drivers and libraries for Nvidia and OpenCL. I prefer doing it this way over the ones provided by Nvidia because it makes installation and/or cleanup a lot easier. However, you won't end up with the latest driver and toolkit. For reference I did this with Ubuntu server release14.04 LTS and an Nvidia GTX 780.

Step 1: Get the Nvidia driver

Use the following command to have the packaged driver for your GPU listed. Use the non-updates versions.
sudo ubuntu-drivers devices
Then install the driver:
sudo apt-get install nvidia-<version here>
 It should look like this for example. Reference
sudo apt-get install nvidia-331

Step 2: Get more Nvidia driver packages

Not quite sure what the following packages are for,  but you need them for this to work. Reference
sudo apt-get install nvidia-<version here>-uvm nvidia-opencl-dev nvidia-modprobe

Step 3: Get the toolkit

Easiest step here. I know it says cuda, but it includes OpenCL libraries too:
sudo apt-get install nvidia-cuda-toolkit

getPlatformIDs returns -1001

For me this was resolved by applying step 2, but I saw people getting this error for other reasons. See here and here

Next steps

Run nvidia-smi to confirm that the driver was installed correctly. Next build and run the deviceQuery sample to ensure you can build and run OpenCL programs successfully.

No comments:

Post a Comment