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

Trouble importing tensorflow_quantum #777

Closed
hchalfin opened this issue Jun 7, 2023 · 3 comments
Closed

Trouble importing tensorflow_quantum #777

hchalfin opened this issue Jun 7, 2023 · 3 comments

Comments

@hchalfin
Copy link

hchalfin commented Jun 7, 2023

I believe my issue may be similar to #771, which doesn't look like it has been resolved yet.

I am trying to install and use tensorflow-quantum but am having no luck. (For reference, I am using MacOS Ventura 13.4) Thus far, I have tried a variety of methods, none of which have worked.

Method 1: Pip package (my preferred method)

I set up and activate a virtual environment tfqenv and then followed the website instructions as closely as possible. I ran the following commands:

pip3 install --upgrade pip
pip3 install tensorflow==2.11.0
pip3 install -U tensorflow-quantum

My error message is in the screenshots below. It appears there is some issue with the file _tfq_simulate_ops.so. Namely, the symbol __ZN10tensorflow12OpDefBuilder10SetShapeFnENSt3__18functionIFNS_6StatusEPNS_15shape_inference16InferenceContextEEEE cannot be found.

err_msg_screenshot_#1 err_msg_screenshot_#2 err_msg_screenshot_#3 err_msg_screenshot_#4

For reference, here are the package versions installed in my environment:

pip_list_screenshot_#1 pip_list_screenshot_#2 pip_list_screenshot_#3 pip_list_screenshot_#4 pip_list_screenshot_#5

As you can see, I am using tensorflow=2.11.0 and tensorflow-quantum=0.7.2.

Also, I am using Python version 3.8.3:

python_version_screenshot

Considering that it seems like others may have encountered similar issues recently, I am wondering if TFQ is in need of an upgrade. It looks like it hasn't been updated since July 2022.

I will post my questions about the other two methods I've tried soon. But for now, this pip package method is the one I care most about.

@lockwo
Copy link
Contributor

lockwo commented Jun 7, 2023

The _ZN10tensor sort of error has come up multiple times, not just #771 but the linked issues in my responses, #602, #714, #180, #711. The solution in those cases would appear to be the same solution here. This is usually the result of a version mismatch, make sure to check the version of the associated release (since you are not installing the nightly build), TFQ 0.7.2 has TF 2.7.0 as a requirement, not 2.11 (v0.7.2...master#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552L8). The full list of requirements is:

cirq-core==0.13.1
cirq-google==0.13.1
sympy==1.8
numpy==1.19.5  # TensorFlow can detect if it was built against other versions.
nbformat==4.4.0
pylint==2.4.4
yapf==0.28.0
tensorflow==2.7.0
# Needed for compatibility with cirq program protos.
googleapis-common-protos==1.52.0
google-api-core==1.21.0
google-auth==1.18.0
google-api-python-client==1.8.0
grpcio==1.34.1
protobuf==3.17.3

With python3.8 and a branch new environment, I can install using pip and run with no problems with TF 2.7:

Screenshot 2023-06-07 at 4 47 53 PM

@hchalfin
Copy link
Author

hchalfin commented Jun 8, 2023

I have implemented your suggested solution and, at least thus far, everything appears to be working very smoothly. I am feeling delighted. Thank you so much!

It turns out that sharing my questions about the two other methods would be little more than a moot point at this stage.

@fabiosanger
Copy link

the issue still persist, solution to install tf 2.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants