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 : ( , .. )
:
sudo apt update && sudo apt dist-upgrade && sudo apt install libnuma-dev && sudo reboot
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
, :
sudo dpkg -i *.deb
5.6, GRUB. 5.8:
sudo apt-get purge *5.8.0*
.
:
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
ROCm:
sudo apt update && sudo apt install rocm-dkms && sudo reboot
:
sudo usermod -a -G video $LOGNAME sudo usermod -a -G render $LOGNAME
. , GPU:
/opt/rocm/bin/rocminfo /opt/rocm/opencl/bin/clinfo
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
:
sudo apt install rocm-libs miopen-hip rccl
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.