1

長い話: 私は Amazon EC2 インスタンスを使用しており、TensorFlow(TF) を内部的に使用する Ampligraph と呼ばれるこのパッケージを使用しようとしていました。このインストール ガイドを使用して、PIP 経由でインストールしました。以下のスクリプトを実行して、モデルをシステムにロードしました。

from ampligraph.utils import restore_model
model = restore_model(model_name_path = model_path)

「AttributeError: module 'tensorflow' has no attribute '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(最終行)であることがわかりました。

繰り返しますが、ピップ経由で TF をインストールしました。

sudo pip3 install tensorflow==1.13.1

正常にインストールされます。ただし、コマンドを実行して TF のバージョンを確認すると、上記と同じメッセージが表示され、バージョンはまだ 1.0.1 です。

私は何を間違っていますか?

長文すみませんありがとうございます!

4

1 に答える 1