Skip to content

Instantly share code, notes, and snippets.

@augustin-laurent
Last active December 3, 2023 17:47
Show Gist options
  • Save augustin-laurent/5d27bf321cb90f1d8c97da712027bc42 to your computer and use it in GitHub Desktop.
Save augustin-laurent/5d27bf321cb90f1d8c97da712027bc42 to your computer and use it in GitHub Desktop.
My tutorial on how to install ROCm for RX 6900 XT, with Tensorflow on Ubuntu 22.04
December 3rd 2023

Introduction

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.

Prerequisites

  • A computer running Ubuntu 22.04 LTS
  • A compatible AMD GPU

Step-by-Step Guide

  1. Update Your System: First, make sure your system is up-to-date. Open your terminal and run:

    sudo apt update
    sudo apt upgrade
  2. 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).

  3. 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
  4. 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.

  5. 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
  6. Reboot:

    Once the installation is finished, reboot your system:

    sudo reboot
  7. 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.

  8. 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.

  9. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment