Keras with GPU on Mac using PlaidML

Since Apple and nVidia broke up harshly a few years ago, the official support of all nVidia GPUs were stopped. Shortly after, all deep learning frameworks stopped their support of GPU acceleration on Mac. Now, there is finally a simple and productive solution: using Keras with PlaidML.

PlaidML provides backends for Keras without requiring CUDA and nVidia hardware. It event supports Metal on Mac to provide a great improvement of performance. Now we can utilize our AMD GPU on Mac to drive Keras!

Install PlaidML

PlaidML supports Python2, but Python3 is recommended.

  1. Setup a virtual environment
python3 -m venv plaidml-venv
source plaidml-venv/bin/activate
  1. Install PlaidML with Keras
pip install -U plaidml-keras
  1. Setup PlaidML
  1. Test
pip install plaidml-keras plaidbench
plaidbench keras mobilenet

Using Keras with PlaidML

The key step is to set the backend variable.

import os
os.environ[KERAS_BACKEND] = plaidml.keras.backend

Now, Keras is ready to go.


  1. PlaidML github
  2. The original blog recommended by Michael
  3. Another good guide
  4. A simple bechmarking
Bo Gao  2020-02-04
Edit on Github...