Open stfnmangini opened 2 years ago
I can't check what works (the only mac I have access to has an i9), but if the problem for pip installing is TF == 2.4.1, could you work with the nightly build? That has TF 2.7. The nightly pip install also break?
I can't check what works (the only mac I have access to has an i9), but if the problem for pip installing is TF == 2.4.1, could you work with the nightly build? That has TF 2.7. The nightly pip install also break?
Hi Owen, thanks for the suggestion! I've just tried installing tfq-nightly using stadard pip install tfq-nightly
in the conda environment with the M1-optimized tensorflow, but it yields the following error
ERROR: Could not find a version that satisfies the requirement tfq-nightly (from versions: none)
ERROR: No matching distribution found for tfq-nightly
Again, this must have something to do with tfq-nightly looking for package tensorflow
instead of tensorflow-macos
. Also, having a look at the tfq-nightly wheels (https://pypi.org/project/tfq-nightly/#files) they are for x86_64 architecture, and not M1-arm64 one. Though, I know very little about architectures, compilations and builds, so I may be getting something wrong.
However, after digging some more I found a way to install it using the x86_64 architecure! I don't know exactly if it is the minimal (or most efficient) solution, but it worked for me (at least for installation and import, haven't tested it in detail yet).
tensorflow-quantum
with x86_64 architecture on M1 deviceInstall Rosetta: run on terminal softwareupdate --install-rosetta
Create a Rosetta-Terminal: go to Application folder and duplicate the Terminal (or iTerm) app. Open the "Get info" tab of the duplicate terminal, and check the "Open with Rosetta" option. Rename the duplicate app (like "Rosetta-iTerm") to distinguish it from the original one (M1 arm64-based).
Create Environment: create a python environment using the default python3
distribution (not using conda). Open the just created Rosetta-terminal, and run
python3 -m venv ~/tensorflow-env
source ~/tensorflow-env/bin/activate
python -m pip install -U pip
Install Tensorflow: following https://github.com/tensorflow/tensorflow/issues/46044#issuecomment-828347288,
download the wheels for tensorflow v2.4.1 from the provided link, and run pip install /position/of/file/tensorflow-2.4.1-py3-none-any.whl
Install Tensorflow Quantum: just pip install tensorflow-quantum
Note: always use the Rosetta enabled-terminal for activating the environment and using these tensorflow installations, otherwise you receive compatibility errors.
My default version of python3
is Python 3.8.9. Follwing these steps I could install all packages without errors, and import them as well. I still haven't tested in detail the performances and functionalities. Also, it remains to be understood how to set up tfq
with the optimized M1 tensorflow distribution.
Hope this works for others as well!
I followed these steps and still get the error:
ERROR: Could not find a version that satisfies the requirement tensorflow-quantum (from versions: none) ERROR: No matching distribution found for tensorflow-quantum
I got the same error, too.
I'm having troubles installing
tensorflow-quantum
on an Apple M1 device.Tensorflow installation is fine following Apple's official guide (https://developer.apple.com/metal/tensorflow-plugin/), though I am not able to install
tfq
, either viapip
or building from source:pip
requirestensorflow==2.4.1
, but Tensorflow for M1 chips comes at least at >v2.5.0;configure.sh
looks fortensorflow
buttensorflow-macos
is installed instead), and also due to Bazel, as the required version (3.7.2) is not available for M1 architectures.Step to reproduce the problem:
First install Tensorflow following Apple's guide, then follow
tfq
installation procedure https://github.com/tensorflow/quantum/blob/master/docs/install.mdIf modifying the
configure.sh
by having it look fortensorflow-macos
(instead oftensorflow
), then problems occur when building with Bazel (the required distribution 3.7.2 is not available for M1 architecture). Installing from source also Tensorflow itself comes with its own bag of installation issues (versions incompatibilities, problems with packages likenumpy
,grpcio
,h5f
, ...), and doesn't feel like the best way to proceed.Is there a workaround or fix? How should one proceed? Thanks!