AttributeError: module 'tensorflow._api.v1.io' has no attribute 'gfile'
According to readme in the models/research/efficient-hrl folder, I run: python scripts/local_train.py test1 hiro_orig ant_maze base_uvf suite
but it tells the problem: "AttributeError: module 'tensorflow._api.v1.io' has no attribute 'gfile'' This is on tensorflow 1.12.0
if I change the version of tensorflow, it will be other questions : AttributeError: module 'tensorflow.io' has no attribute 'gfile' (tf1.11.0)
AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2' (tf1.13.1)
AttributeError: module 'tensorflow' has no attribute 'io' (tf1.5.0) Does anyone know how to solve it? Thanks!
Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. What is the top-level directory of the model you are using Have I written custom code OS Platform and Distribution TensorFlow installed from TensorFlow version Bazel version CUDA/cuDNN version GPU model and memory Exact command to reproduce
Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. What is the top-level directory of the model you are using --/home Have I written custom code --no OS Platform and Distribution --ubuntu16.04 LTS TensorFlow installed from --pip or conda TensorFlow version --tensorflow 1.12.0 , other versions have also been tried. Bazel version --not clear CUDA/cuDNN version --CUDA9.0 , cuDNN7.1 GPU model and memory --Two TITAN Xp, 12196MiB,I use tensorflow(not tensorflow-gpu), If necessary, I can also use tensorflow-gpu Exact command to reproduce --Don't quite understand this.
https://github.com/tensorflow/models/tree/master/research/efficient-hrl Run command: python scripts/local_train.py test1 hiro_orig ant_maze base_uvf suite Then the above error will occur.
Now, I installed tensorflow1.12.0 by running: pip install tensorflow==1.12.0 In this way, the code can run more, reach line 29 of run_train.py. But it still occurs error.
`
Traceback (most recent call last):
File ".//run_train.py", line 49, in
` Anyone know how to solve it?
Hello, I got same error when I run tensorflow 1.9.0. I am trying to run tensorflow object detection api, but it is not loading graph.
OS Platform and Distribution : Windows 10 TensorFlow installed from : Tensorflow 1.9.0 ( pip install tensorflow==1.9.0) TensorFlow version : 1.9.0 Bazel version : not sure CUDA/cuDNN version : CPU GPU model and memory : I don't use GPU. Exact command to reproduce There is the code:
with detection_graph_below.as_default():
od_graph_def = tf.GraphDef()
with tf.io.gfile.GFile(PATH_TO_CKPT_BELOW, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
And the error message:
with tf.io.gfile.GFile(PATH_TO_CKPT_BELOW, 'rb') as fid:
AttributeError: module 'tensorflow' has no attribute 'io'
What is the solution? Thank you
hello, I am getting the same error when I run the tensorflow 2.0. I am trying to load the inception model, but it is not loading.
OS platform and distribution: macOS catalina v0.15.2
Tensorflow installed from: pip3
tensorflow version: 2.0
bazel version: unclear
CUDA/cuDNN version: CPU
GPU: NA
code snippet:
with tf.io.gfile.FastGFile(path, 'rb') as file:
and the error message:
AttributeError: module 'tensorflow_core._api.v2.io.gfile' has no attribute 'FastGFile'
how to solve this?
Thank you
regards
jayesh
same error as above. Haven't found resolution yet
Maybe using tf.compat.v1.gfile.FastGFile instead of tf.gfile.FastGFile resolves your issue. It's just a guess :)
The attribute was resolvable for me in 2.2.0rc4:
$ pip list | grep tensorflow
tensorflow 2.2.0rc4
tensorflow-estimator 2.2.0
https://www.tensorflow.org/api_docs/python/tf/compat/v1/gfile/FastGFile
I will respond to the original query from Muguangfeng (the other issues I am not sure on and may be best created as separate issues). It seems the underlying issue is with CriticalSection, and the fact that the alias for it has changed in tf1.12. Try replacing that call with tf.CriticalSection and see what happens.
GUYS! For tensorflow-gpu=2.2
I replaced this: { detection_graph = tf.Graph() with detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') } with: { detection_graph = tf.compat.v1.Graph() with detection_graph.as_default(): od_graph_def = tf.compat.v1.GraphDef() with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') }
And it is working perfect!