Keras without Nvidia GPUs with PlaidML (and AMD GPU)

Vatsal Srivastava
1 min readSep 11, 2018

--

Keras is an open source neural network library written in Python. Most of the people run it over TensorFlow or Theano. Running it over TensorFlow usually requires Cuda which in turn requires a Nvidia GPU.

Recently Vertex.AI, which is a part of Intel’s Artificial Intelligence Products Group, released PlaidML, an “open source portable deep learning engine”, that “runs on most existing PC hardware with OpenCL-capable GPUs from NVIDIA, AMD, or Intel”.

It also allows you to use your AMD GPUs or Intel HD graphics for accelerating your performance. I recently bought a laptop with a 2GB AMD Radeon RX 550, and I was a little worried about if I could really train or run a deep learning model (or inference) on it.

The PlaidML really surprised me with its ease of installation, performance and substantial documentation. There are also two open-source projects for developing vision applications (plaidvision) and performance bench-marking (plaidbench).

The only extra line that you need to add in your existing Keras programs is:

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

This will override the default back-end option which is usually TensorFlow.

You can get running within a couple of minutes by following the installation instructions here: https://github.com/plaidml/plaidml/blob/master/docs/installing.md

You can also find a sample program here: https://github.com/plaidml/plaidml

I must say that this project not only makes the domain of deep learning accessible to a wider variety of people but also helps reduce the demand, and hopefully the price, of GPUs.

Good luck with your training :)

--

--