amdgpu-pro-install on Ubuntu GNOME 16.04 with R9 285 and RX 480

Solution 1:

Quote from http://www.phoronix.com/scan.php?page=article&item=amd-gpu-pro&num=1

At first I was trying an Ubuntu 16.04 daily system with its packaged Xenial kernel. However, even though this packaged AMDGPU binary driver uses DKMS, there is broken compatibility with this kernel driver's code against Linux 4.4. Due to some changes in the DRM kernel interface of Linux 4.4, building the DKMS module failed. This should be fixed by AMD soon as Bridgman noted in the forums, but for now, the easy fix was just installing Linux 4.2 on the Ubuntu 16.04 box

I did not try the easy fix, but I found the hard one earlier in the day, and it worked for me without an issue.

However If you attempt this I recommend backing up your system before trying this.

The problem For AMDGPU-PRO on Ubuntu GNOME is that COGL is failing to compile correctly.

there is a patch file for it:

Fix COGL for AMDGPU-PRO drivers by Ashley Sommer. https://gist.github.com/ashleysommer/25118d366bf8c1608f3b1a64bc52d4e5

    --- a/cogl/driver/gl/gl/cogl-driver-gl.c
    +++ b/cogl/driver/gl/gl/cogl-driver-gl.c
    @@ -403,9 +403,13 @@
                                   &ctx->glsl_minor);
         }

    -  if (COGL_CHECK_GL_VERSION (ctx->glsl_major, ctx->glsl_minor, 1, 2))
    -    /* We want to use version 120 if it is available so that the
    -     * gl_PointCoord can be used. */
    +  if (COGL_CHECK_GL_VERSION (ctx->glsl_major, ctx->glsl_minor, 1, 5))
    +    ctx->glsl_version_to_use = 150;
    +  else if (COGL_CHECK_GL_VERSION (ctx->glsl_major, ctx->glsl_minor, 1, 4))
    +    ctx->glsl_version_to_use = 140; 
    +  else if (COGL_CHECK_GL_VERSION (ctx->glsl_major, ctx->glsl_minor, 1, 3))
    +    ctx->glsl_version_to_use = 130; 
    +  else if (COGL_CHECK_GL_VERSION (ctx->glsl_major, ctx->glsl_minor, 1, 2))
         ctx->glsl_version_to_use = 120;
       else
         ctx->glsl_version_to_use = 110;

There is a guide by user illwieckz on how to apply the fix here:

https://www.phoronix.com/forums/forum/linux-graphics-x-org-drivers/amd-linux/881527-amdgpu-pro-16-30-released-with-rx-480-support/page5

Things to do:

You have to rebuild the libcogl20 package. Since I was not able to successfully rebuild the cogl packages, I just replaced the libcogl.so binary itself.

 sudo apt-get build-dep cogl

if you get: E: Unable to find a source package for cogl

 sudo gedit /etc/apt/sources.list

and add this at the end of the file:

 # COGL
 deb-src ftp://ftp.de.debian.org/debian/ stable main contrib

next:

 sudo apt-get update &&  sudo apt-get build-dep cogl

install a couple packages required to build cogl:

 sudo apt-get install devscripts libcogl-gst-dev

then continue:


 The following commands I executed from the home directory,
 because of permission errors and `command is not found`
 errors I was getting.

 apt-get source cogl
 cd cogl-1.22.0
 wget -O /tmp/cogl.patch https://gist.githubusercontent.com/ashleysommer/25118d366bf8c1608f3b1a64bc52d4e5/raw/e35e535e7ea9684538a63fe6ea0eb2709b1813f1/cogl_driver_gl_gl_cogl-driver-gl.c
 patch -p1 < /tmp/cogl.patch
 dpkg-source --commit
 debuild -us -uc -j$(nproc)

If the build ends successfully for you, you just have to install the generated libcogl20 deb file (in parent directory) with gdebi or dpkg:

 sudo dpkg -i libcogl20_1.22.0-2_amd64.deb

If it fails for you like it failed for me, there is another option remaining, you can do as I did.

Since on my end, the build failed on some unnecessary part, but the patched lib was built fine, I just replaced the binary by hand:

Code:

 sudo cp -a debian/tmp/usr/lib/x86_64-linux-gnu/libcogl.so.20.4.1 /usr/lib/x86_64-linux-gnu/libcogl.so.20.4.1

The desktop freezes for a couple of seconds.

Since I overwritten a file that comes from a package, I marked the package to be “hold” to be sure a future update will not overwrite it, it's a good idea to hold it too if you built successfully the package, for the same reason.

Code:

sudo apt-mark hold libcogl20

If you want to revert the dirty things, you just have to do:

Code:

 sudo apt-mark unhold libcogl20
 sudo apt-get install --reinstall libcogl20

Pro-tip, you can use the debsums tool (from the debsums package) to check if you're running a libcogl.so from a package or a fast- and-dirty patched one like me:

Code:

 debsums -s libcogl20
 debsums: changed file /usr/lib/x86_64-linux-gnu/libcogl.so.20.4.1 (from libcogl20:amd64 package)

If you successfully built the package and installed it the dpkg way, debsums will not complain.

The last part of the amdgpu-pro instalation looks like this


Setting up amdgpu-pro (16.30.3-315407) ...

Setting up amdgpu-pro-dkms (16.30.3-315407) ...

Loading new amdgpu-pro-16.30.3-315407 DKMS files...

First Installation: checking all kernels...

Building for 4.4.0-36-generic and 4.8.0-rc5

Building for architecture x86_64

Building initial module for 4.4.0-36-generic

Done.


amdgpu:

Running module version sanity check.

- Original module

- Installation

- Installing to /lib/modules/4.4.0-36-generic/updates/dkms/


depmod....


DKMS: install completed.

Building initial module for 4.8.0-rc5

ERROR: Cannot create report: [Errno 17] File exists:
 '/var/crash/amdgpu-pro-dkms.0.crash'

Error! Bad return status for module build on kernel: 4.8.0-rc5 (x86_64)
Consult /var/lib/dkms/amdgpu-pro/16.30.3-315407/build/make.log for more information.

update-initramfs: deferring update (trigger activated)

Setting up amdgpu-pro-lib32:i386 (16.30.3-315407) ...

Processing triggers for libc-bin (2.23-0ubuntu3) ...

Processing triggers for initramfs-tools (0.122ubuntu8.1) ...

update-initramfs: Generating /boot/initrd.img-4.8.0-rc5

Warning: Not updating LILO; /etc/lilo.conf not found!

Update 10-9-2016: Using RX 480.

enter image description here

The installation is a success with a 4.4.0-36-generic kernel,

but the module building for kernel 4.8.0-rc5 fails.

Make sure you have: sudo apt-mark hold libcogl20

This command prevents the gnome package updater from replacing the compiled libgogl20 with a newer version.

It also prevents other packages from being installed because of some packages depend on a more recent version of cogl and so on.

We just have to wait for an official fix for this issue, until then this is a good way to get the amdgpu-pro driver working on Ubuntu Gnome 16.04.