Quick PlaidML MacOS Installation Guide

Kenny Lim
3 min readNov 5, 2020
credits: appleinsider

Let’s say it. We miss cuda. So in light of this, I went searching for solutions to and came across PlaidML. This guide allows you to use your macbook GPU in Jupyter Notebook. As the title suggests, the installation steps are laid out below in 7 simple steps.

Terminal Commands

  1. Set up a virtual environment using either venv or conda. I prefer conda. To set up conda environment, follow these steps:
    1. Open terminal (command + space)
    2. type: conda create -n [insert envt name] python=3
    3. type: conda activate [inset envt name]
  2. Install plaidml (this comes with keras, but not tensorflow)
    In terminal, type: pip install plaidml-keras plaidbench
  3. Install tensorflow
    In terminal, type: conda install tensorflow
  4. Install jupyter
    In terminal, type: conda install jupyter labs
  5. Set up plaidml
    In terminal, type: plaidml-setup
plaidml-setup

When prompted for experimental devices, type: n. When prompted for graphics card, choose whichever you like (I chose amd_radeon). Finally, save settings by entering ‘y’. This brings you out of the PlaidML setup.

Jupyter Notebook

  1. Import PlaidML
    type: import plaidml.keras
    plaidml.keras.install_backend()
    import os
    os.environ[“KERAS_BACKEND”] = “plaidml.keras.backend”
  2. Once you have built and compiled the model, you should see this:
    INFO:plaidml:Opening device “metal_intel(r)_hd_graphics_530.0”

3. Run model and see results

gpu vs cpu

Here you can see that we have reduced the wall time to only 1/3 of the time taken by the cpu, from 9 mins to 3 mins.

Tips:

For anyone unsure if it is working for you. Check GPU acitvity using activity monitor. Launch activity monitor -> Go to window -> gpu history

you can the see gpu fired up in the “AMD Radeon Pro 450” window

Conclusion:

Well, as promised a quick and fuss free guide to installing and using to utilising the GPU on your macbook in jupyter notebook. Feel free to leave a comment if anything doesn’t work out. Oh yes, the codes used in this story can be found on my github: https://github.com/kennylimyx/plaidml

--

--

Kenny Lim

I am an old soul with a childlike curiosity. I am all about productivity, with bouts of procrastination. Oh, I do some data science projects too.