Use Keras on AMD GPU

Tram Ho

As you know Keras only supports CUDA on NVIDIA GPUs, what about other GPUs? Thankfully, Vertex AI created PlaidML as a “tensor compiler” that allows us to run Deeplearing frameworks on multiple platforms, such as Keras, which can be used on GPUs that do not require CUDA but are still maintained. equivalent performance maintenance. Configuration of the machine you are using:

  • Windows 10
  • AMD Adeon RX 560X GPU

Step 1: Install Tensorflow and Keras

Turn on Anaconda Prompt (Run as Administrator)

Use the command

Step 2: Install PlaidML

Continue using the command below

Step 3: PlaidML Setup

Once installed, PlaidML needs to be reconfigured to match the hardware. Use the command

Here, it will show all the hardware options that Keras can run on it (here my machine has 3 options: CPU, GPU onboard and Radeon RX 560x GPU)

PlaidML will ask you: Enable experimental device support? (y, n). Choose Yes

Here you choose the hardware for Keras to run on (I choose number 2 means Radeon RX 560x GPU)

So you can run Keras on AMD GPU already ??

Step 4: Code only

Add the following code line to the beginning

You can use the code train a simple convnet on MNIST dataset in github to see the change

Share the news now

Source : Viblo