Install ROCm driver on ubuntu 18.04

1 minute read

Published:

You can following the installation manual

The OS used is ubuntu 18.04 with kernel 4.15.0-48-generic

update system

sudo apt update
sudo apt dist-upgrade
sudo apt install libnuma-dev
sudo reboot

Add the ROCm apt repository

wget -qO - http://repo.radeon.com/rocm/apt/debian/rocm.gpg.key | sudo apt-key add -
echo 'deb [arch=amd64] http://repo.radeon.com/rocm/apt/debian/ xenial main' | sudo tee /etc/apt/sources.list.d/rocm.list

install rocm

sudo apt update
sudo apt install rocm-dkms
sudo apt-get install dkms rock-dkms rocm-opencl-dev

add current user to the video group

sudo usermod -a -G video $LOGNAME 

echo 'ADD_EXTRA_GROUPS=1' | sudo tee -a /etc/adduser.conf
echo 'EXTRA_GROUPS=video' | sudo tee -a /etc/adduser.conf

export path in ~/.bashrc

  export PATH=$PATH:/opt/rocm/bin
  export PATH=$PATH:/opt/rocm/opencl/include
  export PATH=$PATH:/opt/rocm/opencl/bin/x86_64
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/lib:/opt/rocm/opencl/lib/x86_64:/opt/rocm/hip/lib
  export AMDAPPSDKROOT=/opt/rocm/opencl

test basic installation

/opt/rocm/bin/rocminfo 
/opt/rocm/opencl/bin/x86_64/clinfo 

Issue 1 : dkms.conf missing

leiming@pangu:~$ dkms status
amdgpu, 2.3-14, 4.15.0-48-generic, x86_64: installedError! Could not locate dkms.conf file.
File:  does not exist.

find out which amdgpu driver is available

leiming@pangu:/var/lib/dkms/amdgpu/2.3-14/4.15.0-48-generic/x86_64/log$ locate dkms.conf  | grep amd
/usr/src/amdgpu-2.0-89/dkms.conf
/usr/src/amdgpu-2.0-89/amd/dkms/dkms.conf
...

add amdgpu to driver

sudo dkms add -m amdgpu -v 2.0-89

Issue 2 : clinfo error

Error Message

leiming@pangu:~$ /opt/rocm/opencl/bin/x86_64/clinfo 
ERROR: clGetPlatformIDs(-1001)

check icd file

leiming@pangu:~/files_on_pangu/test_rocm/clARMOR/tests/good_cl_mem$ for i in `ls -1 /etc/OpenCL/vendors`; do echo -n "$i : "; cat /etc/OpenCL/vendors/$i; done
nvidia.icd : libnvidia-opencl.so.1

add the missing amdocl64.icd

echo 'libamdocl64.so' | sudo tee /etc/OpenCL/vendors/amdocl64.icd

check again using clinfo

/opt/rocm/opencl/bin/x86_64/clinfo

It should print the gpu info on the platform.

For additional tests

Please refer to this post : https://github.com/RadeonOpenCompute/ROCm/issues/511

References:

  • https://rocm.github.io/install.html
  • https://github.com/RadeonOpenCompute/ROCm/issues/511