AMDGPU-PRO Gentoo Install
AMDGPU-PRO driver guide for Gentoo
Note: this page was copied from the Warwick site that is no longer available. I'm going to try to maintain this to keep it going in case anyone wants the closed-source drivers.
The following is a short guide to install the proprietary AMDGPU-PRO driver in Gentoo linux.
This driver seems to produce a good increase of performance on older workstation cards (GCN1), but, perhaps more importantly, it introduces support for Raven Ridge. Also, it supports hybrid configurations, including the latest RX500 series.
In the following, I assume you know how to maintain your system, change keywords on a package basis, etc. Needless to say, you need to be root for all these steps. Before the actual steps, a few notes: - This guide is for driver version 17.40.492261. I know that there is a newer driver, but it requires at least version 1.0.65 of vulkan-loader, which, at the moment, is not available in Portage. - The steps below assume you are making a new installation. If, instead, you are updating from a previous version of the same driver, you should simply install the new ebuild and proceed as for a normal system update (including of course unmasking its keyword, potentially recompiling the kernel and building the new dkms module). - During the installation of the driver or later, during a normal system update, it is possible to get compilation errors with libtool complaining about gbm-related stuff. This is a known problem due to libtool getting confused during the link stage, and it happens in exactly the same way for users of the proprietary nVidia driver. Typically the error will occur while compiling mesa or cairo, but it may happen when building other packages as well. The workaround is to run "eselect opengl xorg-x11", then emerge the package that was failing, then run "eselect opengl amdgpu-pro", and finally continue whatever you were doing before. - The ebuild also works for hybrid configurations, such as new laptops with an integrated Intel card and a discrete AMD one. For such cases, make sure you activate the "hybrid" USE flag and take care of the necessary changes, explained below. - For hybrid configurations, in step 1, ensure that the VIDEO_CARDS variable includes the values needed for the integrated card. For example, if you have a laptop with an Intel Core i7 8550U, you will need VIDEO_CARDS="amdgpu radeonsi intel i965". To know what values to use, please refer to the relevant guide. - In step 5, make sure to specify the right spare region number for the MTRR in CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT. In the instructions, I used the value 2, but this may be different for your card. You can check the right region by running cat /proc/mtrr. Also, the CONFIG_EXTRA_FIRMWARE line is a correct example for an RX480 card. If your card is a different model, you must replace the file names with the appropriate firmware files. To find which firmware files to include, check the list here. However, note that the cards mentioned at this link are all desktop cards. If you are setting up a workstation or a laptop, you can check the type of microarchitecture of your card here and then refer to the previous list, considering that the driver works on cards starting from GCN first generation. Also, if your card is a Southern Islands or a Sea Islands card, then you must also have CONFIG_DRM_AMDGPU_SI=y or CONFIG_DRM_AMDGPU_CIK=y, respectively. - The ebuild assumes that the PCI bus of the card is 1:0:0. If this is not the case for your card, after step 7 is complete you must modify the file /etc/X11/xorg.conf.d/10-device.conf and replace the BusID value with the right one, which you can find using lspci. Also, optionally, you can modify the various identifiers in the same file as well as in /etc/X11/xorg.conf.d/10-monitor.conf and /etc/X11/xorg.conf.d/10-screen.conf to match those of your hardware (this has no effect whatsoever on the functioning of your card). Note that this step is not needed if you have a hybrid configuration; in fact, in this case, these files will not even be created.
Now, the actual step-by-step guide.
- First of all, make sure that in /etc/portage/make.conf you have the line VIDEO_CARDS="amdgpu radeonsi"
- Edit the file /etc/portage/package.mask and add the lines
- Mask old version of packages for AMDGPU-PRO
<sys-kernel/gentoo-sources-4.9.0
>=sys-kernel/gentoo-sources-4.11.0
x11-drivers/amdgpu-pro::farmboy0 - Then, update your system: emerge --update --deep --newuse -1 world
- When the system is properly updated, and any rebuilding and fixing is done, install the firmware package (if it is not already installed): emerge linux-firmware
- Next step is making sure the kernel has the right configuration. Note that you must ensure that you are running a 4.9 kernel, which may mean you must manually accept its keyword. At the moment, I tested it with the latest available kernel of the series, which is the 4.9.85, and which I use in the instructions below. In the kernel configuration, verify that the following options are as shown (please note that some must be modules):
CONFIG_MTRR = y # CONFIG_TRIM_UNUSED_KSYMS is not set CONFIG_MTRR_SANITIZER = y CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT = 1 CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT = 2 CONFIG_BINFMT_ELF=y CONFIG_COMPAT_BINFMT_ELF=y CONFIG_BINFMT_SCRIPT=y CONFIG_BINFMT_MISC=y CONFIG_FW_LOADER = y CONFIG_FIRMWARE_IN_KERNEL = y CONFIG_EXTRA_FIRMWARE = "amdgpu/polaris10_ce.bin amdgpu/polaris10_mc.bin amdgpu/polaris10_me.bin amdgpu/polaris10_mec2.bin amdgpu/polaris10_mec.bin amdgpu/polaris10_pfp.bin amdgpu/polaris10_rlc.bin amdgpu/polaris10_sdma1.bin amdgpu/polaris10_sdma.bin amdgpu/polaris10_smc.bin amdgpu/polaris10_smc_sk.bin amdgpu/polaris10_uvd.bin amdgpu/polaris10_vce.bin" CONFIG_EXTRA_FIRMWARE_DIR = "/lib/firmware" CONFIG_AGP = y CONFIG_VGA_SWITCHEROO = y CONFIG_DRM = y CONFIG_DRM_FBDEV_EMULATION = y CONFIG_DRM_AMDGPU = m CONFIG_DRM_AMDGPU_USERPTR = y CONFIG_FB = y CONFIG_FB_MODE_HELPERS = y CONFIG_FB_VESA = y # CONFIG_DRM_RADEON is not set # CONFIG_FB_RADEON is not set DEBUG_KERNEL = n
If needed, recompile the kernel and make sure modules, firmware and system map are installed: make make modules_install make firmware_install cp arch/x86/boot/bzImage /boot/kernel cp System.map /boot/System.map-4.9.85-gentoo
Reboot into the new kernel.
6. Next, install dkms. The easiest way is to use the farmboy0 overlay. Emerge layman (if it is not already installed), then do layman -a farmboy0 layman -S emerge dkms
7. Create a local overlay. I call mine parawlay. If you don't know how to do this, see here or here. Inside the overlay, create the category "x11-drivers", and inside this the directory "amdgpu-pro". Then, downoad this ebuild and put it inside this directory. Create the manifest: ebuild amdgpu-pro-17.40.492261-r2.ebuild manifest Install the various driver components: emerge amdgpu-pro Of course, you can choose whatever use flags you want/need, they are self-explanatory.
8. Now, create a directory in which you are going to extract the dkms code, patch it and compile it. For example: mkdir amdgpupro-17.40.492261_4.9.85 Go there, copy the source in it, extract it and go to the directory with the source code: cd amdgpupro-17.40.492261_4.9.85 cp /usr/portage/distfiles/amdgpu-pro-17.40-492261.tar.xz . tar xJf amdgpu-pro-17.40-492261.tar.xz rm amdgpu-pro-17.40-492261.tar.xz cd amdgpu-pro-17.40-492261/ ar x amdgpu-pro-dkms_17.40-492261_all.deb tar xJf data.tar.xz rm * cd usr/src/ Inside this directory you have the code for the module, which needs to be patched. To do so, download these patches and extract them where you are. Then, patch the code: cd amdgpu-17.40-492261/ for i in `seq 1 1 11`; do patch -p0 < ../patch${i}; done cd .. If (and only if) you are currently running an old version of the proprietary drive module, uninstall it. For example, if you are running the old driver version 17.10-401251, do dkms remove amdgpu-pro/17.10-401251 --all Then, install the new driver: dkms install amdgpu-17.40-492261 -k 4.9.85-gentoo --force
9. Run eselect opengl amdgpu-pro eselect opencl amdgpu-pro
10. Finally, if you intend to use the card for cryptocurrency mining, edit the file /etc/grub.d/40_custom and add the option amdgpu.vm_fragment_size=9 in the kernel line, and rebuild the grub config file (typically running grub-mkconfig -o /boot/grub/grub.cfg). Do not perform this step if you will use the card for regular gaming/rendering/computing jobs.
Reboot and you are done. In general, update and maintain your system (and overlays) as usual. However, if you recompile the kernel, you will need to reinstall the dkms module. Whenever a new version of the driver is released or there is some change in something, and I have time, I will update the guide.