Title | Install Tensorflow 2 for AMD GPUs by Eric Ngo Analytics Vidhya Medium |
---|---|
Author | Juan Carlos Alvarez Villca |
Course | Inteligencia Artificial |
Institution | Universidad Mayor de San Andrés |
Pages | 6 |
File Size | 270.3 KB |
File Type | |
Total Downloads | 29 |
Total Views | 115 |
instalando tensorflow...
6/9/2021
Install Tensorflow 2 for AMD GPUs | by Eric Ngo | Analytics Vidhya | Medium
This is your last free member-only story this month. Sign up for Medium and get an extra one
Install Tensorflow 2 for AMD GPUs Eric Ngo
Follow
Dec 6, 2020 · 3 min read
AMD has released ROCm, a Deep Learning driver to run Tensorflow-written scripts on AMD GPUs. However, many owners and I have encountered many challenges in installing Tensorflow on AMD GPUs. Hence, I provided the installation instructions of Tensorflow for AMD GPUs below.
In this post, I guided you to install ROCm (AMD GPU driver) and Tensorflow ROCm (version compatible with AMD hardware) from Debian repository on Ubuntu. At the https://medium.com/analytics-vidhya/install-tensorflow-2-for-amd-gpus-87e8d7aeb812
1/6
6/9/2021
Install Tensorflow 2 for AMD GPUs | by Eric Ngo | Analytics Vidhya | Medium
moment this post published, ROCm runs only on Linux-like platforms (e.g. Ubuntu, Centos). To run Deep Learning with AMD GPUs on MacOS, you can use PlaidML owned and maintained by PlaidML. So far, I have not seen packages to run AMD-based Deep Learning on Windows. Updated on March. 1, 2021
Installation steps: Install GPU driver, ROCm Install AMD-compatible Tensorflow version, Tensorflow ROCm Notice: there is often a version mismatch between ROCm and TF-ROCm, and therefore, please check this link to find the compatible ROCm and TF-ROCm versions.
Prerequisites Operating Systems: Ubuntu 18.04.5 (Kernel 5.4) and other supported OSs. Hardware: Radeon VII (I owned it) and other supported hardware (e.g. Vega 64, RX580).
Install ROCm Notes: to install ROCm successfully, ensure the fresh installation (aka OS reboot) or clearly remove ROCm-related packages. Update the OS
sudo apt update sudo apt dist-upgrade sudo apt install libnuma-dev sudo reboot
https://medium.com/analytics-vidhya/install-tensorflow-2-for-amd-gpus-87e8d7aeb812
2/6
6/9/2021
Install Tensorflow 2 for AMD GPUs | by Eric Ngo | Analytics Vidhya | Medium
Add the ROCm apt repository The next code block is to install the latest ROCm version.
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 is often updated before the Tensorflow ROCm. Hence, there is usually the version mismatch between ROCm and Tensorflow ROCm. The version-mismatch error code is “stack smashing detected”. To solve the problem, you can install older ROCm versions by slightly modifying the above code block. Also, check this link to find the ROCm version matched for the Tensorflow 2.x.x. version you want to install.
wget -q -O - https://repo.radeon.com/rocm/apt/x.x.x/rocm.gpg.key | sudo apt-key add echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/x.x.x/ xenial main' | sudo tee /etc/apt/sources.list.d/rocm.list
that x.x.x is replaced by the ROCm version number. For example, x.x.x is replaced by 3.9.1 or x.x.x is replaced by 3.9 (0 is degraded from 3.9.0) Install ROCm meta-packages
sudo apt update sudo apt install rocm-dkms && sudo reboot
Add users to video & render groups
sudo usermod -a -G video $LOGNAME sudo usermod -a -G render $LOGNAME https://medium.com/analytics-vidhya/install-tensorflow-2-for-amd-gpus-87e8d7aeb812
3/6
6/9/2021
Install Tensorflow 2 for AMD GPUs | by Eric Ngo | Analytics Vidhya | Medium
echo 'ADD_EXTRA_GROUPS=1' | sudo tee -a /etc/adduser.conf echo 'EXTRA_GROUPS=video' | sudo tee -a /etc/adduser.conf echo 'EXTRA_GROUPS=render' | sudo tee -a /etc/adduser.conf sudo reboot
Notes: ‘render’ is only supported on Ubuntu 20.x.x and above. Verify ROCm installation
/opt/rocm/bin/rocminfo /opt/rocm/opencl/bin/clinfo
If both two commands show the same GPU device, ROCm is successfully installed. Add ROCm binary path
echo 'export PATH=$PATH:/opt/rocm/bin:/opt/rocm/rocprofiler/bin:/opt/rocm/op
Remove ROCm packages
sudo apt autoremove rocm-opencl rocm-dkms rocm-dev rocm-utils rm -rf /opt/rocm* sudo reboot
Install dependency packages according to shawonashraf
sudo apt install rocm-libs hipcub miopen-hip
Ensure that you remove all rocm* packages in /opt folder
Install Tensorflow-ROCm https://medium.com/analytics-vidhya/install-tensorflow-2-for-amd-gpus-87e8d7aeb812
4/6
6/9/2021
Install Tensorflow 2 for AMD GPUs | by Eric Ngo | Analytics Vidhya | Medium
By typing
pip3 install tensorflow-rocm
Now, you may encounter errors of missing packages (e.g. hipsparse, rccl). To solve the errors, you should repeat the following commands to install missing packages as long as the errors disappear.
sudo apt install sudo ldconfig
Yup. That’s it. I tested the above commands on Ubuntu 18.04.5 (kernel 5.4) and Radeon VII. For CentosOS, follow this issue #1196. Hopefully, this post is helpful to you. If you have questions & comments for me, please leave comments or ping me. Have fun training Deep Learning models on AMD GPUs.
Sign up for Analytics Vidhya News Bytes https://medium.com/analytics-vidhya/install-tensorflow-2-for-amd-gpus-87e8d7aeb812
5/6
6/9/2021
Install Tensorflow 2 for AMD GPUs | by Eric Ngo | Analytics Vidhya | Medium
By Analytics Vidhya
Latest news from Analytics Vidhya on our Hackathons and some of our best articles!Take a look.
Your email Get this newsletter By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.
TensorFlow
Amd
Gpu
Rocm
Deep Learning
https://medium.com/analytics-vidhya/install-tensorflow-2-for-amd-gpus-87e8d7aeb812
6/6...