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
1 2 3 | conda install -c conda-forge tensorflow conda install -c conda-forge keras |
Step 2: Install PlaidML
Continue using the command below
1 2 | pip install plaidml-keras plaidbench |
Step 3: PlaidML Setup
Once installed, PlaidML needs to be reconfigured to match the hardware. Use the command
1 2 | plaidml-setup |
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
1 2 3 | import plaidml.keras plaidml.keras.install_backend() |
You can use the code train a simple convnet on MNIST dataset in github to see the change