tensorflow/quantum

Installation Issues on Apple M1 device

Closed

#655 opened on Jan 18, 2022

 (4 comments) (1 reaction) (1 assignee)Python (662 forks)github user discovery
area/docsarea/installationhelp wantedkind/bug-reportplatform/macpriority/p3skill-level/intermediate

Repository metrics

Stars
 (2,180 stars)
PR merge metrics
 (Avg merge 13d 10h) (2 merged PRs in 30d)

Description

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 via pip or building from source:

  • installation via pip requires tensorflow==2.4.1, but Tensorflow for M1 chips comes at least at >v2.5.0;
  • installing from source yields errors due to missing recognized Tensorflow package (configure.sh looks for tensorflow but tensorflow-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.md

  git clone https://github.com/tensorflow/tensorflow.git
  cd tensorflow
  git checkout v2.7.0 (same version obtained with   python -m pip tensorflow-macos)

  pip install -U pip six numpy wheel setuptools mock 'future>=0.17.1'
  pip install -U keras_applications --no-deps
  pip install -U keras_preprocessing --no-deps
  pip install numpy==1.19.5  (fails to compile wheels, must install with conda install numpy=1.19.5 instead)

  ./configure


WARNING: Package(s) not found: tensorflow
WARNING: Package(s) not found: tf-nightly
WARNING: Package(s) not found: tensorflow-cpu
WARNING: Package(s) not found: tf-nightly-cpu
Installing tensorflow .....\n
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow

If modifying the configure.sh by having it look for tensorflow-macos (instead of tensorflow), 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 like numpy, grpcio, h5f, ...), and doesn't feel like the best way to proceed.

Is there a workaround or fix? How should one proceed? Thanks!

Contributor guide