Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install plaidML / plaidML-keras

So I am trying to install plaidML-keras so I can do tensor-flow stuff on my MacBookPro's gpu (radeon pro 560x). From my research, it can be done using plaidML-Keras (instalation instrutions). When I run pip install -U plaidml-keras it works fine, but the next step, plaidml-setup returns the following error.

Traceback (most recent call last):
  File "/usr/local/bin/plaidml-setup", line 6, in <module>
    from plaidml.plaidml_setup import main
  File "/usr/local/lib/python3.7/site-packages/plaidml/__init__.py", line 50, in <module>
    import plaidml.settings
  File "/usr/local/lib/python3.7/site-packages/plaidml/settings.py", line 33, in <module>
    _setup_config('PLAIDML_EXPERIMENTAL_CONFIG', 'experimental.json')
  File "/usr/local/lib/python3.7/site-packages/plaidml/settings.py", line 30, in _setup_config
    'Could not find PlaidML configuration file: "{}".'.format(filename))
plaidml.exceptions.PlaidMLError: Could not find PlaidML configuration file: "experimental.json".

From my limited understanding of the error message, it is saying that I am missing a conifuration file, but I don't know where to put it, or what to put in it. I am guessing that it has something to do with the following (vague) line from the instructions.

Finally, set up PlaidML to use a preferred computing device

But how do I specify that I want it to use the radeon pro 560x. Also, I did check and my mac is compatible with openCL 1.2 (required for plaidML)

like image 325
Mining15 Avatar asked Jul 10 '19 14:07

Mining15


2 Answers

Disclaimer: I'm on the PlaidML team, and we're actively working to improve the setup experience and documentation around it. We're sorry you were stuck on this. For now, here's some instructions to get you back on track.

  1. Find out where plaidml-setup was installed. Typically, this is some variant of /usr/local/bin or a path to your virtual environment. The prefix of this path (i.e. /usr/local) is important to note for the next step.
  2. Find the plaidml share directory. It's within the same prefix as plaidml-setup, i.e. /usr/local/share/plaidml.
  3. Within the plaidml share directory, there should be a few files: at a minimum, config.json and experimental.json should be in there. If they're not in there, you can copy the files here to your plaidml share directory.

After copying those json files over, you should be able to run plaidml-setup with no issue.

like image 192
Denise Kutnick Avatar answered Nov 05 '22 17:11

Denise Kutnick


You need to set plaidml and libplaidml.dylib path correctly in environment.

Possible paths for plaidml

  1. /Library/Frameworks/Python.framework/Versions/3.7/share/plaidml
  2. /usr/local/share/plaidml
  3. Some other location. Search it.

Possible paths for libplaidml.dylib

  1. /Library/Frameworks/Python.framework/Versions/3.7/lib/libplaidml.dylib
  2. /usr/local/lib/libplaidml.dylib
  3. Some other location. Search it.

Example: In your code set environment variable:

import os
os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"
os.environ["RUNFILES_DIR"] = "/Library/Frameworks/Python.framework/Versions/3.7/share/plaidml"
os.environ["PLAIDML_NATIVE_PATH"] = "/Library/Frameworks/Python.framework/Versions/3.7/lib/libplaidml.dylib"

For complete steps to setup opencl and plaidml. See this.

Note: This is for macOS/Linux

like image 40
bikram Avatar answered Nov 05 '22 19:11

bikram