Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Adept I

Experimental OpenCL driver for Ubuntu 16.04

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 (if many people find it helpful, I will consider creating a PPA):

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:

sudo dpkg -i fglrx-core_15.302-0ubuntu1_amd64.deb

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:

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:

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

Section "Device"

    Identifier     "Device0"

    # Change the Driver name to the driver of your display GPU (radeon, intel, nouveau, etc)

    Driver         "radeon"

    # Change the BusID to the PCI BusID given by lspci of your display GPU

    # Please note that the numbers given by lspci is hexadecimal and you need decimal here

    BusID          "PCI:129:0:0"


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!

3 Replies

Hi Huan.

Welcome to the AMD DevGurus. You've been added to the whitelist. Now, you can post anywhere in DevGurus.

I'm moving this thread to OpenCL forum.


Adept I

Is it possible to block a card in windows 10 from computing OpenCL so my secondary card can do all OpenCL calculations?



You may try GPU_DEVICE_ORDINAL environment parameter for that purpose.

As AMD Programming User guide (section "Masking Visible Devices" ) says:

"By default, OpenCL applications are exposed to all GPUs installed in the system; this allows applications to use multiple GPUs to run the compute task.

In some cases, the user might want to mask the visibility of the GPUs seen by the OpenCL application. One example is to dedicate one GPU for regular graphics operations and the other three (in a four-GPU system) for Compute. To do that, set the GPU_DEVICE_ORDINAL environment parameter, which is a comma--separated list variable:

 Under Windows: set GPU_DEVICE_ORDINAL=1,2,3

 Under Linux: export GPU_DEVICE_ORDINAL=1,2,3