Date of the guide : December 17, 2023
In this post, I will provide the solution that worked on my system on how to install Radeon Open Compute (ROCm) on Arch (linux-6.6.7.arch1-1) 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. In this guide I will use Paru as my AUR package helper, feel free to use any other (https://wiki.archlinux.org/title/AUR_helpers). I will assume you have a working operating system and know what you do with it (Otherwise Arch will be painfull for you).
- A computer running Arch
- Access to AUR
- A compatible AMD GPU
-
Update Your System: First, make sure your system is up-to-date. Open your terminal and run:
sudo pacman -Syu paru -Syu (or yay -Syu, depends on which AUR package helper you use)
-
Install prerequisites: You will need some packages to fetch and compile ROCm In the terminal run :
paru -S wget make curl gperftools
-
Install PyEnv: I choose to install PyEnv to manage my Python version, you can directly install Python if the version you use is compatible with ROCm
curl https://pyenv.run | bash `` Add theses lines to your .bashrc (located in your /home/username folder) : ```bash vim ~/.bashrc (or nano ~/.bashrc)
export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init --path)" eval "$(pyenv virtualenv-init -)"
Now refresh the shell by either closing and reopening your terminal or execute this :
exec $SHELL
Now to be sure PyEnv is installed run :
pyenv
If the commands list is printed in your terminal, then you managed to installed otherwise go to PyEnv wiki to try fix the install : (https://github.com/pyenv/pyenv/wiki)
-
Install Python:
Now that we have PyEnv we can install Python, in this guide, I will use Python 3.10.13 (Lateset version supported at the date I'm writing this guide).
pyenv install 3.10.13
PyEnv have installed the 3.10.13 version, now we need to tell our system to use this version.
pyenv global 3.10.13
To ensure we have the right version execute :
python --version
If the command return 3.10.13 then you have the version you just installed as the version your system will use.
-
Install ROCm:
Now that we have everything setup we can install ROCm, in your terminal run :
paru -S rocm-hip-sdk rocm-opencl-sdk
You now have ROCm installed, but we need a bit more step to make it work.
-
Configuring stuff:
You will need to had your session to user groups.
sudo gpasswd -a username render sudo gpasswd -a username video
Then you will have to edit .bashrc again, add this :
export ROCM_PATH=/opt/rocm export HSA_OVERRIDE_GFX_VERSION=10.3.0
If you have a GPU that are from 7XXX series, then you need to change the 10.3.0 value to 11.0.0. From there you basically should have a working environnement with ROCm, next steps is try it.
-
Testing ROCm with Tensorflow:
Now simply install the library with pip.
pip install --user tensorflow-rocm
git clone https://github.com/mpeschel10/test-tensorflow-rocm.git
CD into the folder just cloned.
cd test-tensorflow-rocm
And run the .py file
python test_tensorflow.py
If it's running 5 Epochs and printing the time your GPU made to pass the test, congratulations ! You now have a working ROCm environnement ! For numbers here are my result with a RX 6900XT :
313/313 - 0s - loss: 0.0657 - accuracy: 0.9808 - 249ms/epoch - 795us/step Your run took 9.433697 seconds. // This stat below are from the author of the test. My GPU takes 14 seconds. My CPU takes 74 seconds. Your mileage may vary.
@augustin-laurent Greetings from Tampa-Florida! You have a typo here:
paru -S rocm-hip-sdk rocm-opencl-sdkk
You have an extra k in the word sdk which is making the packager manager not to find the package.