Experimental OpenCL driver for Ubuntu 16.04

on July 17th, 2016 by Hades | No Comments »

On Ubuntu 16.04, fglrx support was dropped and currently the opensource driver AMDGPU is still in an early stage and only supports very limited devices. I attempted to make the OpenCL part of fglrx working and made a modified fglrx package providing OpenCL support on Ubuntu 16.04. There is still no X support, so if you want to use X you have to use another GPU with X11 driver. The modified driver can co-exist with radeon, so you can just grab a low-end AMD card for display only. The followings are the changes I made:


  1. Applied patches to the driver source to make it compatible with kernel 4.4.
  2. Modified the driver so that it can co-exist with radeon. I added an new parameter “blocked_devs” to fglrx. You can specify the device IDs (separated by comma) that fglrx will skip and thus these devices can then be used by the radeon driver.
  3. The modified fglrx should be loaded before radeon, otherwise radeon will take all AMD GPU devices and conflict with fglrx. I made necessary changes to the postinst script and modprobe.d configurations to make this automatic for you.
  4. fixed an openCL crash bug by adding the /etc/ati folder to the package.

The modified package can be downloaded here

Link 1: fglrx-core_15.302-0ubuntu1_amd64.deb – Google Drive

Link 2: MEGA

Installation procedures:

1. Remove any existing fglrx packages and install the modified package:

  1. sudo dpkg -i fglrx-core_15.302-0ubuntu1_amd64.deb
  2. sudo apt-get install -f # Fix any broken dependencies

2. If you want to use radeon for one of your GPUs for display, you need to modify /etc/modprobe.d/fglrx-core.conf.

Otherwise, it should be compatible with other display drivers. In my case I have a HD 6450 card for display only, and a R9 280X for compute. According to “lspci -nn” the device ID for HD 6450 is 6779. So I add the following line to /etc/modprobe.d/fglrx-core.conf:

  1. options fglrx blocked_devs=6779

In this way I can run X through HD 6450 and run OpenCL applications on R9 280X. After changing this option you also need to update initramfs:

  1. sudo update-initramfs -u

3. Reboot. Check dmesg and verify that fglrx is loaded before radeon, and radeon is not using the card for OpenCL. Then try clinfo.

If your X.org won’t start and complains, you need to give it some hints on finding the correct display GPU by adding a “Device” section to /etc/X11/xorg.conf

  1. Section “Device”
  2.     Identifier     “Device0”
  3.     # Change the Driver name to the driver of your display GPU (radeon, intel, nouveau, etc)
  4.     Driver         “radeon”
  5.     # Change the BusID to the PCI BusID given by lspci of your display GPU
  6.     # Please note that the numbers given by lspci is hexadecimal and you need decimal here
  7.     BusID          “PCI:129:0:0”
  8. EndSection

I have tested my package on Ubuntu 16.04 LTS with R9 280X and R9 270X. OpenCL works flawlessly in headless mode and in X mode (X runs on the other display-only GPU with the radeon driver). It should work with other GCN-based cards as well. If you find this package useful, please share your experience and feedback here. If it does not work for you, please provide your dmesg and I can take a look. Thanks!