google-deepmind / sonnet

TensorFlow-based neural network library
https://sonnet.dev/
Apache License 2.0
9.78k stars 1.3k forks source link

Cannot install sonnet on mac m1 #246

Open maryamastero opened 2 years ago

maryamastero commented 2 years ago

I install dm-sonnet and I see: Requirement already satisfied: sonnet in

/Users/maryamkia/Homebrew/Caskroom/miniforge/base/envs/pytorch_x86/lib/python3.8/site-packages (0.1.6)
Requirement already satisfied: networkx==1.8.1 in /Users/maryamkia/Homebrew/Caskroom/miniforge/base/envs/pytorch_x86/lib/python3.8/site-packages (from sonnet) (1.8.1)

Note: you may need to restart the kernel to use updated packages.

after reseting kernel and running:

import sonnet as snt
print("Sonnet version {}".format(snt.__version__))

I got:

AttributeError: module 'tensorflow' has no attribute 'GraphKeys' I work on mac M1

tomhennigan commented 2 years ago

Hi @maryamkiashemshaki it sounds like you've got Sonnet 1.0 installed alongside TensorFlow 2.X.

If you want to use TensorFlow 2, then you need to use Sonnet 2.0 (released in March 2020). You can find installation instructions here: https://github.com/deepmind/sonnet#installation

If you need to use Sonnet 1.X (for example to work with some legacy code) then please install TensorFlow 1. If you are using pip I think you can use: pip install "tensorflow<2".

maryamastero commented 2 years ago

I cannot install Sonnet 2.0 or Tensorflow<2 on my mac M1.

I cannot have a working pair of TensorFlow and sonnet on my mac. However, I could install them on colab by:

pip install "tensorflow-gpu<2" "dm-sonnet<2" "tensorflow-probability==0.7.0"

tomhennigan commented 2 years ago

I'm afraid I don't have an M1 to test on, I'm glad you got things working in Colab and I hope that unblocks you.

Sonnet 1 is in maintenance mode only at this point (there have been no changes in v1 for 2 years), we recommend all users migrate to TensorFlow 2 and Sonnet 2 (or to JAX + Haiku if you prefer).

I would expect Sonnet 2 to "just work" on M1 (if you pip install --upgrade "dm-sonnet>=2") since it is a pure Python library with no native code.

drscotthawley commented 11 months ago

I cannot install Sonnet 2.0 or Tensorflow<2 on my mac M1.

I cannot have a working pair of TensorFlow and sonnet on my mac. However, I could install them on colab by:

pip install "tensorflow-gpu<2" "dm-sonnet<2" "tensorflow-probability==0.7.0"

Trying this pip install on Colab no longer works (at least for me):

ERROR: Could not find a version that satisfies the requirement tensorflow-gpu<2 (from versions: 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.10.0rc0, 2.10.0rc1, 2.10.0rc2, 2.10.0rc3, 2.10.0, 2.10.1, 2.11.0rc0, 2.11.0rc1, 2.11.0rc2, 2.11.0, 2.12.0)
ERROR: No matching distribution found for tensorflow-gpu<2
tomhennigan commented 11 months ago

Hi @drscotthawley , I replied on your other thread which should help unblock you with Sonnet 2.