tensorflow / quantum

Hybrid Quantum-Classical Machine Learning in TensorFlow

Home Page:https://www.tensorflow.org/quantum

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems with installing package from PyPI and Colab due to dependency conflicts

knaughttyanyon opened this issue · comments

This problem has been brought up repeatedly for a few months and it's a classic example of 'the solution is trivial and is left as an exercise for the reader'.

So I'm going to leave here some information that helped me resolve the dependency conflicts and build it from source on my device. Information is based on darwin-arm64v8 but should be applicable in general if one is building from source.

General notes:

  • the colab issue stems from the python version bump to newer versions that aren't supported by tensorflow-quantum yet and there is not direct option in colab to change the python version using the runtime type option (to my knowledge). follow the colab release notes if interested

  • for local installs using python 3.9 seems to be satisfying the strict version constraints of the conflicting dependencies.

If one isn't familiar with setting environment build variables etc and making sure the paths are pointing correctly to gcc etc.

  • just stick to python venv and python base versions installed using pyenv. (more details : just makes it easier to handle the dependency installations step from PyPi compared to using conda for this since the conda installs the suitable builds from architecture specific channels generally but won't always have the newest version of a package available in the channels and pip being pip causes conflicts. Mainly with protobuf and this is an important dependency.)

  • Protobuf was weird and might not have a required builder.py file leading to installation failure. If you also get an error, just copy the builder.py file from main branch of protobuf source and place it in the correct file path mentioned in the traceback message on your console. (See protobuf #9778 )

  • to avoid paths pointing in wrong places between tf and tfq: try to build both from source according to instructions. Refrain from installing tensorflow 2.11.0 (or tensorflow-macos) from PyPI followed by building tensorflow-quantum from source. Check your .bazelrc file during build to verify that the path is pointing to the correct site-package directories.

For arm Macs: I probably have the cached wheels of tensorflow quantum from my bazel build. If possible I can find a way to share them.

Unfortunately there are way too many duplicate issues around this with scattered workarounds and solutions. @MichaelBroughton or any of the active maintainers, please merge them if possible to reduce the clutter in this repository.

Hope the pointers would be helpful with installation until the dependency conflicts are resolved.

I don't believe there are any active maintainers of this repository

Are you aware of any mailing lists like the one for Cirq that one can sign up to follow any updates?

I am not aware of any. The last functional change was with the 0.6.0 release, Feb 3 2022.

This is such a mess. I have spent several days trying all sorts of fixes but can't get it to work. I've tried using TFQ on Windows with Anaconda and WSL, I've tried on a virtual machine of Ubuntu, I've tried with Google Colab, yet nothing works. If anyone who is involved in this project would consider creating a Docker container for this with the proper setup, similar to the one for TF, that would be a huge help. As of now, this is essentially unusable.

I've tried qbraid before (free tier) and had some success (https://www.qbraid.com/products). Ubuntu w/ python 3.8 and the right TF version should work (that's what I do), but there are a lot of difficulties I know. Imo TFQ should probably be on the https://killedbygoogle.com list.

I managed to install ,

  • tensorflow-quantum 0.3.0 with tensorflow 2.11.0 , python 3.8 locally on windows.
    I can import and use it , but most of the functionalities are not available in 0.3.0 version

  • tensorflow-quantum 0.7.2 with tensorflow 2.11.0 , python 3.8 on colab.
    but I can't import it now.

I managed to install ,

  • tensorflow-quantum 0.3.0 with tensorflow 2.11.0 , python 3.8 locally on windows.
    I can import and use it , but most of the functionalities are not available in 0.3.0 version
  • tensorflow-quantum 0.7.2 with tensorflow 2.11.0 , python 3.8 on colab.
    but I can't import it now.

Did you manage to resolve these issues? I'm also presently grappling with similar problems.

I managed to install ,

  • tensorflow-quantum 0.3.0 with tensorflow 2.11.0 , python 3.8 locally on windows.
    I can import and use it , but most of the functionalities are not available in 0.3.0 version
  • tensorflow-quantum 0.7.2 with tensorflow 2.11.0 , python 3.8 on colab.
    but I can't import it now.

Did you manage to resolve these issues? I'm also presently grappling with similar problems.

Nope , I even tried with qBraid , still same issue.

I managed to install ,

  • tensorflow-quantum 0.3.0 with tensorflow 2.11.0 , python 3.8 locally on windows.
    I can import and use it , but most of the functionalities are not available in 0.3.0 version
  • tensorflow-quantum 0.7.2 with tensorflow 2.11.0 , python 3.8 on colab.
    but I can't import it now.

Did you manage to resolve these issues? I'm also presently grappling with similar problems.

Nope , I even tried with qBraid , still same issue.

Hey so I figured out a stopgap solution - you can use GitHub Codespaces or even try locally on VSCode in Windows. These are the compatible versions: tensorflow v 2.7.0, tensorflow-quantum 0.7.2 and Python 3.8 (using venv). I'm sharing a video link that can help out understand the versioning problem:

https://www.youtube.com/watch?v=Kd8uJx-OLHg

Hi, I am trying to install tensorflow quantum and I am getting errors. I'm installing using python version 3.8, tensorflow version 2.7 and tensorflow quantum version 0.7. I don't know what to do.