Setting up your AMD GPU for Tensorflow in Ubuntu (Updated for 20.04)

Check Device & Latest Update

Gungle
1 min readNov 19, 2023
glxinfo | grep "Device"
AMD Radeon RX 5600 XT (NAVI10, DRM 3.37.0, 5.4.0-42-generic, LLVM 10.0.0) (0x731f)

sudo apt update
sudo apt dist-upgrade

Install the dependency libnuma-dev for ROCm.

sudo apt install libnuma-dev

Once libnuma-dev gets installed, add the official ROCm repos to apt

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 the ROCm kernel

sudo apt update
sudo apt install rocm-dkms

Add your user to the VIDEOGROUP

sudo usermod -a -G video $LOGNAME
sudo usermod -a -G render $LOGNAME

Open /etc/adduser.conf and add these lines

sudo nano /etc/adduser.conf
ADD_EXTRA_GROUPS=1
EXTRA_GROUPS="render,video"

Open /etc/udev/rules.d/70-kfd.rules and add the following

sudo nano /etc/udev/rules.d/70-kfd.rules
SUBSYSTEM=="kfd", KERNEL=="kfd", TAG+="uaccess", GROUP="video"

Install libtinfo5

sudo apt install libtinfo5

Add ROCm binaries to your path (bash or zsh whichever you use)

echo 'export PATH=$PATH:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin/' | sudo tee -a /etc/profile.d/rocm.sh

Test if your installation was successful or not. If your installation was successful, you should be able to see the supported GPUs installed on your system in the output.

import os

# IMPORTANT: PATH MIGHT BE DIFFERENT. CHECK IT!
os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"

--

--

No responses yet