6

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)

Mining15
  • 83
  • 1
  • 6

5 Answers5

3

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.

  • 3
    so I did all that and it still gives me the same error when I run `plaidml-setup` – Mining15 Jul 18 '19 at 17:10
  • I have those in the share directory with the same prefix, it still doesn't work. I created an environment through conda. – Nasif Imtiaz Ohi Mar 29 '20 at 18:48
  • my files are in ~/.local/share and I set RUNFILES_DIR= to that directory. Still gives cannot find error I have looked into site packages settings.py into line 28 should I write the location there ? . I dont understand ... – Gediz GÜRSU Apr 14 '22 at 08:02
2

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

bikram
  • 7,127
  • 2
  • 51
  • 63
0

I'm facing the same problem and answers online are not very helpful. In this case, I'd suggest debugging yourself.

Since this is where the problem is:

File "/usr/local/lib/python3.7/site-packages/plaidml/settings.py", line 30, in _setup_config
'Could not find PlaidML configuration file: "{}".'.format(filename))

You can vim /usr/local/lib/python3.7/site-packages/plaidml/settings.py, and read the code. Basically it's trying to use function _find_config to get config files.

After cfg_path = os.path.join(prefix, 'share', 'plaidml', name), I added print(cfg_path) to see what path it's looking for. And I got:

/usr/local/Caskroom/miniconda/base/share/plaidml/experimental.json
/usr/local/Caskroom/miniconda/base/share/plaidml/config.json

This is why it's hard to tell you where to put the files: it depends on your system setup. Not everyone is using cask and conda like me, so I assume it should be different in your OS.

@Denise Kutnick: thanks for your hard work, maybe either print cfg_path when there's a problem, or try to add . as a search path, so that it would be easier for users to get some clue?

superarts.org
  • 7,009
  • 1
  • 58
  • 44
0

As I wrote here: https://superuser.com/questions/1404114/traceback-error-during-plaidml-installation/1488059#1488059

the file plaidml/settings.py uses variable sys.prefix which for a reason has wrong value for my system: it contains /usr instead of ~/.local so it tries to load /usr/share/plaidml/experimental.json instead of ~/.local/share/plaidml/experimental.json I don't know how to fix the value of sys.prefix yet and whether plaidml will be able to find it's so file...

A. Genchev
  • 369
  • 3
  • 7
0

Within the plaidml share directory, there should be a few files: at a minimum, config.json and experimental.json

usr/local/lib/python3.8/site-packages/plaidml

++

do the followings:

export PLAIDML_NATIVE_PATH=/usr/local/lib/libplaidml.dylib export RUNFILES_DIR=/usr/local/share/plaidml.

Pedram
  • 53
  • 6