Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorflow pluggable device #387

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Apurer
Copy link

@Apurer Apurer commented Oct 31, 2022

This is support for pluggable device using experimental TensorFlow feature.
Motivated by the desire to use the M1 Chip GPU cores.
Thanks to gists of @lnshi, @wangjia184 and my own trial and error.

@Apurer
Copy link
Author

Apurer commented Oct 31, 2022

Resolves issue 381.

@Apurer
Copy link
Author

Apurer commented Nov 1, 2022

In order for the experimental feature to work properly on an Apple M1 chip, it is necessary to satisfy these dependencies:

  1. libmetal_plugin.dylib library in lib path:
    • Setup TensorFlow metal
    • Search for location of libmetal_plugin.dylib by running: pip show tensorflow-metal
    • Copy displayed path after Location:
      • It could be /miniconda/lib/python3.9/site-packages
    • Add /tensorflow-plugins to the returned path and set env variable
      • Example export DYLD_LIBRARY_PATH=~/miniconda/lib/python3.9/site-packages/tensorflow-plugins:$DYLD_LIBRARY_PATH
  2. libtensorflow in lib path:
    • Install libtensorflow using brew brew install libtensorflow
    • Check path of installed package brew --cellar libtensorflow
      • Example path /opt/homebrew/Cellar/libtensorflow
    • Add libtensorflow to the lib path
      • Example export DYLD_LIBRARY_PATH=/opt/homebrew/Cellar/libtensorflow/2.10.0/lib:$DYLD_LIBRARY_PATH
    • Create soft symlink for file libtensorflow.so.{version}
      • Example ln -s /opt/homebrew/Cellar/libtensorflow/2.10.0/lib/libtensorflow.so.2.10.0 /opt/homebrew/Cellar/libtensorflow/2.10.0/lib/libtensorflow.dylib

@adamcrume
Copy link
Contributor

Please ensure that ./test-all succeeds.

@Apurer
Copy link
Author

Apurer commented Apr 7, 2023

Can you rerun the checks @adamcrume? I don't remember what was wrong :)

@Apurer
Copy link
Author

Apurer commented Apr 7, 2023

Closes #402

@Apurer
Copy link
Author

Apurer commented Apr 7, 2023

I tested code by running workflow in my repository.

@Apurer
Copy link
Author

Apurer commented Apr 7, 2023

I believe I resolved all the issues. Can you please trigger the workflow run, @adamcrume?

@Apurer
Copy link
Author

Apurer commented Apr 19, 2023

I am happy to see all the checks pass :)

@adamcrume
Copy link
Contributor

There was another pull request for this (#402), but it didn't have the macOS test. Could you rebase? It would still be nice to use this PR for the test.

@@ -59,6 +59,7 @@ compiled library will be picked up.

**macOS Note**: Via [Homebrew](https://brew.sh/), you can just run
`brew install libtensorflow`.
[tensorflow metal plugin]: https://developer.apple.com/metal/tensorflow-plugin/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't render properly (https://github.com/Apurer/rust/tree/feature/experimental/tensorflow-sys). It also needs some explanation. Do users need to follow that link and do anything specific?

Copy link
Author

@Apurer Apurer Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix the rendering issue. Yes, users need to click on the provided link to set up the TensorFlow plugin on Apple computers. I considered including the steps listed on developer.apple.com, but I was unsure if the steps would be updated.

@Apurer
Copy link
Author

Apurer commented Apr 22, 2023

There was another pull request for this (#402), but it didn't have the macOS test. Could you rebase? It would still be nice to use this PR for the test.

I will rebase my pull request and possibly refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants