当我尝试运行import tensorflow_quantum
时,我得到以下错误:
2021-08-19 11:03:01.024791: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-08-19 11:03:01.024808: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow_quantum/core/ops/load_module.py", line 42, in load_module
return load_library.load_op_library(path)
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow/python/framework/load_library.py", line 58, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: /home/sam/.local/lib/python3.9/site-packages/tensorflow_quantum/core/ops/_tfq_simulate_ops.so: undefined symbol: _ZN10tensorflow6StatusC1ENS_5error4CodeEN4absl14lts_2020_09_2311string_viewEOSt6vectorINS_10StackFrameESaIS7_EE
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow_quantum/__init__.py", line 18, in <module>
from tensorflow_quantum.core import (append_circuit, get_expectation_op,
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow_quantum/core/__init__.py", line 17, in <module>
from tensorflow_quantum.core.ops import (get_expectation_op,
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow_quantum/core/ops/__init__.py", line 18, in <module>
from tensorflow_quantum.core.ops.circuit_execution_ops import (
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow_quantum/core/ops/circuit_execution_ops.py", line 20, in <module>
from tensorflow_quantum.core.ops import (cirq_ops, tfq_simulate_ops,
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow_quantum/core/ops/tfq_simulate_ops.py", line 19, in <module>
SIM_OP_MODULE = load_module("_tfq_simulate_ops.so")
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow_quantum/core/ops/load_module.py", line 46, in load_module
return load_library.load_op_library(path)
File "/home/sam/.local/lib/python3.9/site-packages/tensorflow/python/framework/load_library.py", line 58, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: /home/sam/anaconda3/envs/quantum-env/lib/python3.9/site-packages/tensorflow_quantum/core/ops/_tfq_simulate_ops.so: undefined symbol: _ZN10tensorflow6StatusC1ENS_5error4CodeEN4absl14lts_2020_09_2311string_viewEOSt6vectorINS_10StackFrameESaIS7_EE
似乎有一些未定义的符号
ZN10tensorflow6StatusC1ENS_5error4CodeEN4absl14lts_2020_09_2311string_viewEOSt6vectorINS_10StackFrameESaIS7_EE
但是我真的不知道这是什么意思。
我用的是Pop!_OS 21.04, Tensorflow 2.6.0, Tensorflow Quantum 0.6.0, python 3.9.5。我根据本页的说明安装了Tensorflow Quantum,但我仍然无法在python中导入它。当我尝试通过命令行或在Spyder或Jupyter笔记本中运行python时,我也会得到同样的错误。
我真的不知道这是怎么回事。我已经设法在这里找到了一些类似的问题/答案,但最有希望的只是链接到一个页面的说明,目前只是给出了一个404错误。如有任何帮助,我将不胜感激。
这个问题在TF 2.5、2.6中再次出现。在2.4.1中尝试,编辑代码:(请在python 3.7/3.8中尝试)
pip install -q tensorflow==2.4.1
pip install -q tensorflow-quantum
import tensorflow as tf
import tensorflow_quantum as tfq
提供参考依据