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

Check for package tensorflow-macos #28

Closed
wants to merge 1 commit into from

Conversation

phzeller
Copy link

Similar to this pull request for nengo-dl, keras-spiking does not detect TensorFlow's installation ("tensorflow-macos") on Apple silicon chips yet.

Thus, I've used the same implementation as in nengo-dl to support Apple silicon chips. This includes the detection of tensorflow-gpu, and nightly builds. However, this may not be the desired default behavior according to the documentation.

Quoting from the docs:

Installing TensorFlow

Use pip install tensorflow to install the latest version of TensorFlow. GPU support is included in this package as of version 2.1.0.

Note that if you are using one of the non-standard TensorFlow packages (e.g. tensorflow-gpu, tensorflow-cpu, or tf-nightly), then pip install keras-spiking will install the tensorflow package over top of your existing TensorFlow installation, which is probably not what you want. To avoid this, you can install with the --no-deps option:

pip install --no-deps keras-spiking

Is there any specific reason for this default behavior?

@drasmuss
Copy link
Member

The logic from NengoDL for looking up the installed tensorflow version is pretty hacky, involving parsing sys.path to figure out the location of the site-packages directory and then manually looking through that directory to find a tensorflow distribution. We've kept it there for historical reasons, since that behaviour is now expected by NengoDL users. But in general I think that it's better to leave those issues up to the packaging systems, and not have our libraries try to hackily modify that behaviour behind the scenes. So in more recently created libraries, like this one, we've opted for keeping our setup requirements simple, and leaving it up to the TensorFlow ecosystem to sort out their packaging.

For example, when you pip install tensorflow on Windows it installs a tensorflow-intel package (as of TF 2.10), which is the main code, but it also installs the tensorflow package so tensorflow>=x dependencies are resolved correctly. That's a much more robust solution. tensorflow-macos could do something similar, and may do so in an upcoming release. So in general I think it's better for us to leave that up to the other tensorflow packages to sort out, rather than trying to provide an unreliable stop-gap fix on our end.

@phzeller
Copy link
Author

Thanks for the clarification and I totally agree: pip install tensorflow should default to install tensorflow-macos on Apple silicon machines. I'll keep my fingers crossed to see this behavior in one of the upcoming releases. Thus, I'm perfectly fine with not changing anything in the existing code.

@phzeller phzeller closed this Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants