Getting past the NVIDIA monopoly

NVIDIA has been the best option for machine learning on GPUs for a very long time. This is because their proprietary CUDA architecture is supported by almost all machine learning frameworks. But, what if you already have an AMD GPU and don’t want to spend hundreds of dollars simply because of compatibility issues? Well, there are some options for AMD, as they have been trying to work their way into machine learning market. They have developed their own architecture called RocM. However, they only offer it for Linux, so Windows users are at a loss. I have decided to write this article because when I was trying to figure out solutions to this problem, the resources were very limited and I spent a lot of time attempting to get my AMD GPU to work. After about a week, I have done some experimenting and found what I consider the best way to utilize an AMD GPU on Windows for machine learning.

Image for post

There are many third party projects that attempt to fix this problem, but I have found that PlaidML is both the most promising and the easiest to implement. PlaidML is owned by Intel and is an ongoing project. Currently it only works with Keras on Windows, so you will need to be familiar with the library in order to use this method. These are the steps that I went through to get this to work:

  1. Create a new virtual environment
  2. Install the PlaidML package within the environment
  3. Setup PlaidML by choosing a device
  4. Run Benchmarks to verify that your GPU is working properly

I recommend doing these steps within Anaconda using Python3, but other versions are supported too. The first thing that you want to do is create a fresh new environment because previous installations and dependencies can mess with the installation process. In Anaconda, you can do this from the Anaconda Navigator Environments tab. Next, you will want to open a Powershell command window within the Environment.

Then, install PlaidML using this command:

$ pip install -U plaidml-keras

After this is finished installing, run the setup command:

$ plaidml-setup

PlaidML will then ask you:

Enable experimental device support? (y,n)[n]:

If you have an AMD GPU, then the device will not be experimental and you can answer “n” to this because they are all supported. The console also prints out a list of the connected devices and whether they are experimental or not, so you can decide whether you need experimental device support.

Then it will ask:

Default device? (1,2)[1]:

The console will print out all of the devices available and their assigned number. Simply select the number associated with the device that you want to use. PlaidML will usually assign your CPU to device 1 and GPU to device 2, so unless you have more devices connected, you will want to use device 2. If you cannot figure out which device you should use, look for the device with OpenCL in its name or just test them all using the benchmark program below and select the fastest one.

#machine-learning #artificial-intelligence #python #amd #ai #deep learning

How to Use AMD GPUs for Machine Learning on Windows
6.45 GEEK