December 3rd 2023
In this post, I will provide the solution that worked on my system on how to install Radeon Open Compute (ROCm) on Ubuntu 22.04 for RX 6900 XT (Should work on other 6000 series). ROCm is an open-source software platform that allows GPU-accelerated computation. This tool is a prerequist to use GPU Acceleration on TensorFlow or PyTorch.
- A computer running Ubuntu 22.04 LTS
- A compatible AMD GPU
-
Update Your System: First, make sure your system is up-to-date. Open your terminal and run:
sudo apt update sudo apt upgrade
-
Identify the newest version of ROCm:
You can find the link for the AMD ROCm repository here: Repo ROCm.
In my case the version of ROCm that is supported by PyTorch is 5.6 and the apt repo name is amdgpu-install_5.7.50702-1_all.deb (TensorFlow-ROCm worked for me with 5.7.2).
-
Add the ROCm Repository:
Add the ROCm apt repository to your system by replacing 5.X.Y and amdgpu-install_5.X.Y.Z-1_all.deb with the version number and repo name you need (see step 2) in the following commands:
wget https://repo.radeon.com/amdgpu-install/5.X.Y/ubuntu/jammy/amdgpu-install_5.X.Y.Z-1_all.deb
-
Install ROCm: Install ROCm by modifying the following command with your needed version number:
sudo apt install ./amdgpu-install_5.X.Y.Z-1_all.deb sudo amdgpu-install --usecase=dkms,graphics,multimedia,opencl,hip,hiplibsdk,rocm
Be sure to use a version that is compatible with your system to not break graphics.
-
Assign yourself to render and video group:
To assign yourself to groups use these commands :
sudo usermod -a -G render $USER sudo usermod -a -G video $USER
-
Reboot:
Once the installation is finished, reboot your system:
sudo reboot
-
Verify Installation:
After rebooting, you can verify the installation by running the
rocminfo
command:sudo /opt/rocm/bin/rocminfo
If you see information about your GPU, congratulations! You have successfully installed ROCm on your Ubuntu 22.04 system, now there is one last step to use TensorFlow ROCm.
-
Add ROCM_PATH:
Now open your .bashrc (or .zshrc if you use ZSH) and add this at the end of the file with your favorite editor :
export ROCM_PATH=/opt/rocm
Now you should be able to use TensorFlow ROCm with your AMD GPU, keep in mind ROCm is not as good as CUDA yet and you will have to tinker a bit to be able to run some models.
-
Install TensorFlow ROCm: Now simply install the library in pip
pip install --user tensorflow-rocm
Install these tools if you dont have them yet
sudo apt install rocm-libs rccl
And you're good to go, enjoy tinkering with ROCm, hope theses steps that work for me work for you too!