当前版本堆栈:
python 3.5
tensorflow 1.14.0
tensorflow-estimator 1.14.0
tensorflow-gpu 1.14.0
tensorflow-tensorboard 0.1.8
protobuf 3.9.1
Keras 2.2.4
Keras-Applications 1.0.7
Keras-Preprocessing 1.0.9
驱动程序和机器:
Ubuntu 16.04 , NVIDIA-SMI 396.54 , CUDA - 9.0 , CuDnn 7 , libcudnn - 7.4.1
摘要-
无法从tensorflow.python.keras._impl.keras.backend上的Abs导入
tensorflow-gpu == 1.14.0
并且无法在tensorflow-gpu == 1.8.0上获取CheckpointableBase属性
哪个tensorflow-gpu和keras版本同时支持CheckpointableBase属性和tensorflow.python.keras._impl.keras.backend中的'abs'?
详细信息-
我目前正在用Keras == 2.2.4训练问题端口掩码rcnn。根据一些threads的说法,为了获得Abs,我尝试将tensorflow-gpu更新为1.8.0,并更新了protobuf。虽然我当时能够导入abs,但最终在tensorflow-gpu上收到“ AttributeError:模块'tensorflow.python.training.checkpointable'没有属性'CheckpointableBase'”到1.8.0。然后为了获取CheckpointableBase,再次指向一些线程更新tensorflow-gpu == 1.14.0。
跟踪:
Traceback (most recent call last):
File "/home/kalpit/Desktop/palash/m-rcnn-traning/data/libraries/bacteria_rcnn_train.py", line 53, in <module>
import keras
File "/usr/local/lib/python3.5/dist-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/usr/local/lib/python3.5/dist-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/usr/local/lib/python3.5/dist-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/usr/local/lib/python3.5/dist-packages/keras/backend/__init__.py", line 84, in <module>
from .tensorflow_backend import *
File "/usr/local/lib/python3.5/dist-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 83, in <module>
from tensorflow.python import keras
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/__init__.py", line 26, in <module>
from tensorflow.python.keras import activations
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/activations/__init__.py", line 22, in <module>
from tensorflow.python.keras._impl.keras.activations import elu
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/_impl/keras/__init__.py", line 21, in <module>
from tensorflow.python.keras._impl.keras import activations
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/_impl/keras/activations.py", line 23, in <module>
from tensorflow.python.keras._impl.keras import backend as K
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/_impl/keras/backend.py", line 38, in <module>
from tensorflow.python.layers import base as tf_base_layers
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/layers/base.py", line 25, in <module>
from tensorflow.python.keras import backend
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/backend/__init__.py", line 22, in <module>
from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'
答案 0 :(得分:2)
嗨,
我能够通过从dist-packages目录本身中删除所有tensorFlow和keras python3软件包,使用pip3卸载并再次安装tensorflow == 1.8.0
来解决此问题。
tensorflow-gpu == 1.8.0,Keras == 2.2.4
(引起此特定错误的潜在原因是python在解包目录中引用了多个tensoflow-gpu,keras版本的软件包文件。尽管通过pip3安装了特定的tensoflow-gpu,keras版本应该理想地删除先前的现有版本。但是就我而言,这没有发生。)
解决方案:
$ locate --basename '\tensorflow'
命令(如果您使用的是Ubuntu)在dist-packages目录中找到tensorflow和keras软件包。就我而言,是$查找--basename'\ tensorflow'
输出-
/usr/local/lib/python3.5/dist-packages/tensorflow
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow
/usr/share/nginx/html/projects/python/machine-learning/objectDetection/models-master/research/syntaxnet/tensorflow
&
$查找--basename'\ keras'
输出-
/usr/local/lib/python3.5/dist-packages/keras
/usr/local/lib/python3.5/dist-packages/tensorflow/keras
/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/keras
/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/keras/api/keras
/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras
/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/_impl/keras
/usr/local/lib/python3.5/dist-packages/tensorflow/tools/api/generator/api/keras
/usr/share/nginx/html/projects/python/Playground/lambda/testkeras/keras
删除目录
sudo rm -R /usr/local/lib/python3.5/dist-packages/tensorflow/
sudo rm -R /usr/share/nginx/html/projects/python/machine-learning/objectDetection/models-master/research/syntaxnet/tensorflow
sudo rm -R /usr/local/lib/python3.5/dist-packages/keras/
sudo rm -R /usr/share/nginx/html/projects/python/Playground/lambda/testkeras/keras
使用pip3卸载
sudo pip3 uninstall tensorflow
sudo pip3 uninstall tensorflow-gpu
sudo pip3 uninstall keras
再次安装tensorflow,tensorflow-gpu,keras
sudo pip3 install tensorflow == 1.8.0
须藤pip3 install tensorflow-gpu == 1.8.0
sudo pip3 install Keras == 2.2.4