Is there life without Nvidia? Launching TensorFlow on the Radeon RX 580

Background

At the new workplace, they put me at a PC equipped with a Ryzen 2600 processor and a Radeon RX 580 video card. Having tried to train neural networks on the processor, I realized that this was not the case: the process was too slow. After a bit of research, I found out that there are at least 2 ways to run modern machine learning libraries on Radeon graphics cards: PlaidML and ROCm. I tried both and want to share the results.





PlaidML: cross-platform at the forefront

TensorFlow Keras, , GPU. , Nvidia CUDA.





PlaidML - Keras OpenCL. Keras , AMD. Windows, Linux Mac.





UPD: MikeLP , :





Keras . , PlaidML CUDA. , , Keras Tensorflow. โ€” ยซ ยป. PlaidML Keras, a tf.Keras โ€” API . C PlaidML, Keras API Tensorflow. PlaidML ( Intel) roadmap .





, PlaidML , .. Keras Tensorflow API . Keras+PlaidML .





PlaidML . Python- :





 pip install plaidml-keras && plaidml-setup
      
      



PlaidML :





os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"
      
      



. :





plaidbench keras mobilenet
      
      



. RX 580 Ryzen 2600 , :

















Radeon RX 580





6.14s





6.51s





Radeon Vega Frontier Edition





4.56s





5.50s





GeForce GTX 1080 TI





2.52s





4.83s





Intel HD Graphics 5500





36.64s





755.23s





AMD Ryzen 2600 (CPU)





5.04s





254.70s





AMD Nvidia. , . Intel HD Graphics: PlaidML Intel .





ROCm:

Radeon Open Compute Platform (ROCm), AMD GPU . ROCm NVIDIA CUDA. UNIX-.





ROCm . , ~2 , PlaidML, , PlaidML Out Of Memory.





Ubuntu 20.04 LTS. ROCm : ( , .. )





  1. :





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



  2. 5.8 5.6. http://kernel.ubuntu.com/~kernel-ppa/mainline/ :





    linux-headers-VERSION-NUMBER_all.deb
    linux-headers-VERSION-NUMBER_amd64.deb
    linux-image-VERSION-NUMBER_amd64.deb
    linux-modules-VERSION-NUMBER_amd64.deb
          
          



  3. , :





    sudo dpkg -i *.deb
          
          



  4. 5.6, GRUB. 5.8:





    sudo apt-get purge *5.8.0*
          
          



  5. .





  6. :





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



  7. ROCm:





    sudo apt update && sudo apt install rocm-dkms && sudo reboot
          
          



  8. :





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



  9. . , GPU:





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



  10. ROCm PATH:





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



  11. :





    sudo apt install rocm-libs miopen-hip rccl
          
          



  12. Pip TensorFlow:





    sudo apt install python3-pip
    pip3 install --user tensorflow-rocm
          
          



! TensorFlow GPU:





:





python3 ./tf_cnn_benchmarks.py --num_gpus=1 --batch_size=64 --model=resnet50
      
      



RX 580 , :









/ (ResNet 50)





AMD Radeon VII





284





AMD Radeon RX Vega 56





131





AMD Radeon RX 580





92





Nvidia GeForce 2080 Ti





293





Nvidia GeForce GTX 1070





126





Nvidia GeForce RTX 3080 10GB





396





2021 , . AMD Nvidia, . , Radeon , .





If you already have a graphics card from AMD, then perhaps for development purposes you will not need to change it to an Nvidia graphics card. I consider the ROCm framework to be the optimal choice for machine learning on Radeon video cards. It provides decent performance and allows TensorFlow 2.2.0 and Keras to run.












All Articles