Python 导致问题的Tensorflow的多个版本
说来话长:我使用了一个AmazonEC2实例,并试图使用这个名为Ampligraph的包,它在内部使用TensorFlow(TF)。我用这个通过PIP安装了它。我运行下面的脚本将模型加载到系统中Python 导致问题的Tensorflow的多个版本,python,python-3.x,tensorflow,pip,knowledge-graph,Python,Python 3.x,Tensorflow,Pip,Knowledge Graph,说来话长:我使用了一个AmazonEC2实例,并试图使用这个名为Ampligraph的包,它在内部使用TensorFlow(TF)。我用这个通过PIP安装了它。我运行下面的脚本将模型加载到系统中 from ampligraph.utils import restore_model model = restore_model(model_name_path = model_path) 它给了我'AttributeError:模块'tensorflow'没有'random'属性 我关注了多个Sta
from ampligraph.utils import restore_model
model = restore_model(model_name_path = model_path)
它给了我'AttributeError:模块'tensorflow'没有'random'属性
我关注了多个StackOverFlow帖子,比如,我知道我的TF版本有问题
当我运行下面的命令检查TF版本时
python3 -c 'import tensorflow as tf; print(tf.__version__)'
这就是我得到的:
I tensorflow/stream_executor/dso_loader.cc:126] Couldn't open CUDA library libcudnn.so.5. LD_LIBRARY_PATH: /usr/local/cuda/lib64:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
I tensorflow/stream_executor/cuda/cuda_dnn.cc:3517] Unable to load cuDNN DSO
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:455: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:456: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:457: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:458: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:459: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
1.0.1
所以,我知道TF的版本是1.0.1(最后一行)
同样,我通过pip安装了TF:
sudo pip3 install tensorflow==1.13.1
它安装成功。但是,当我运行命令检查TF版本时,它显示与上面相同的消息,并且版本仍然是1.0.1
我做错了什么
抱歉发了这么长的邮件
谢谢 首先,检查
pip3
是否与别名为python3
的解释器匹配:run
$ pip3 --version
并检查解释器版本是否为3.5。示例输出:
pip 19.3.1 from /usr/lib64/python3.5/site-packages/pip (python 3.5)
并检查是否列出了tensorflow
。如果是,请仅卸载一个用户:
$ pip3 uninstall tensorflow --user
或者升级并卸载全局版本:
$ pip3 install tensorflow --upgrade --user
$ sudo pip3 uninstall tensorflow -y
首先,检查
pip3
是否与别名为python3
的解释器匹配(运行pip3--version
并检查解释器版本是否为3.5)。其次,您可能同时为同一个解释器安装了两个版本的tensorflow
——全局版本(通过sudo-pip3-install-tensorflow
安装)和用户版本(通过pip3-install-tensorflow-user
安装,注意没有使用sudo
)。要检查这一点,请运行pip3 list--user
并检查是否列出了tensorflow
。如果是,请仅卸载一个用户(pip3 uninstall tensorflow--user
)或对其进行升级。请将此添加为答案。这对我来说很好,我愿意接受。非常感谢。我做了第一步:pip3——版本,得到了类似的输出。但是,对于同一个用户,我有两个版本的tensorflow,gpu和cpu版本。删除了gpu版本并开始工作。很高兴我能帮上忙!
$ pip3 install tensorflow --upgrade --user
$ sudo pip3 uninstall tensorflow -y