tobegit3hub / simple_tensorflow_serving

Generic and easy-to-use serving service for machine learning models
https://stfs.readthedocs.io
Apache License 2.0
757 stars 192 forks source link

AttributeError: module 'tensorflow' has no attribute 'gfile' #45

Closed shravankumar9892 closed 5 years ago

shravankumar9892 commented 5 years ago

I trained a simple mnist model with tensorflow 2.0 on Google Colab and saved it in the .json format. Then on running the command

!simple_tensorflow_serving --model_base_path="/" --model_platform="tensorflow"

It is showing the error AttributeError: module 'tensorflow' has no attribute 'gfile'

tobegit3hub commented 5 years ago

What's the version of your tensorflow? It should has tf.gfile by default.

anyaozm commented 5 years ago

I had the same error. It's tensorflow 2.0 the new version.

tobegit3hub commented 5 years ago

It may be the API change from TensorFlow 2.0.

We may change the usage of this API for this newer version.

anyaozm commented 5 years ago

Thank you!

Tsakunelson commented 5 years ago

Hi @shravankumar9892 @anyaozm,

Could you solve the problem? My tensorflow version is 2.0.0-alpha0, but i still encounter the "AttributeError: module 'tensorflow' has no attribute 'gfile'" error after running the line ''' simple_tensorflow_serving --model_base_path="./models/tensorflow_template_application_model''' image

Thank you

anyaozm commented 5 years ago

Hi @tsakunelson, I uninstalled Tensorflow and all the files from the repository I pip installed. The installed TensorFlow and did the 2nd option and bazel built instead of doing the pip. It worked. You might wanna try pip3 if you’re using python 3. But the other setup worked for me.

Moadab-AI commented 5 years ago

any new update on tf.gfile issue ? if the API has changed what would be the new one in TF-2.0 ?

tobegit3hub commented 5 years ago

I will update this project for TensorFlow 2.0 when it's officially released. Any contribution is welcome if you are interested in this.

AlbertBJ commented 5 years ago

In tf2.0 , the gfile package has been moved into tf.io. so u can use tf.io.gfile

tobegit3hub commented 5 years ago

Thanks all. This have been resolved by https://github.com/tobegit3hub/simple_tensorflow_serving/commit/e9adcaa46d6af448321d70bcac0b4544eba4935f .

And we have done more code change to make STFS to run with TensorFlow 2.x now.

tobegit3hub commented 5 years ago

Related to https://github.com/tobegit3hub/simple_tensorflow_serving/commit/02f25974f48e9c07391c158e9c4c715ab943a998 .

Gurubux commented 5 years ago

Tensor-flow Version - 2.0.0-alpha0

Same error occurred while running a notebook from the Tensorflow site - Build a linear model with Estimators
Download the dataset:

from official.wide_deep import census_dataset
from official.wide_deep import census_main

census_dataset.download("/tmp/census_data/")

AttributeError Traceback (most recent call last)

in () 2 from official.wide_deep import census_main 3 ----> 4 census_dataset.download("/tmp/census_data/") /content/models/official/wide_deep/census_dataset.py in download(data_dir) 76 def download(data_dir): 77 """Download census data if it is not already present.""" ---> 78 **tf.gfile.MakeDirs(data_dir)** 79 80 training_file_path = os.path.join(data_dir, TRAINING_FILE) **AttributeError: module 'tensorflow' has no attribute 'gfile'**

The document suggests the following changes in the file.

_Should I go about making the following changes manually in the file censusdataset.py ?

WARNING: Logging before flag parsing goes to stderr. W0625 16:04:36.412110 139807458662144 deprecation_wrapper.py:119] From /tmpfs/src/temp/site/en/tutorials/estimators/models/official/wide_deep/census_dataset.py:78: The name tf.gfile.MakeDirs is deprecated. Please use tf.io.gfile.makedirs instead.

W0625 16:04:36.413802 139807458662144 deprecation_wrapper.py:119] From /tmpfs/src/temp/site/en/tutorials/estimators/models/official/wide_deep/census_dataset.py:81: The name tf.gfile.Exists is deprecated. Please use tf.io.gfile.exists instead.

W0625 16:04:38.253764 139807458662144 deprecation_wrapper.py:119] From /tmpfs/src/temp/site/en/tutorials/estimators/models/official/wide_deep/census_dataset.py:62: The name tf.gfile.Open is deprecated. Please use tf.io.gfile.GFile instead.

W0625 16:04:38.488776 139807458662144 deprecation_wrapper.py:119] From /tmpfs/src/temp/site/en/tutorials/estimators/models/official/wide_deep/census_dataset.py:73: The name tf.gfile.Remove is deprecated. Please use tf.io.gfile.remove instead.

tobegit3hub commented 5 years ago

@Gurubux It was resolved in this problem with new TensorFlow APIs.

Tarun3679 commented 4 years ago

Hi, I am still facing the same issue even after using tensorflow 2.2 and chaning the configuration as mentioned. Please look at image below. Screenshot from 2020-05-22 01-09-38

NidhiRustagi commented 4 years ago

Same here. Same issue still exists even with Tf2.2.0. The error comes while working with tokenization.FullTokenizer(vocab_file, do_lower_case) so we cant even go to the file and change it