Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Universal Sentence Encoder load error "Error: SavedModel file does not exist at..."

I installed Uiniversal Sentence Encoder (Tensorflow 2) in 2 virtual environment with Ananconda. One is on Mac, anther is on Ubuntu.

All worked with following:

  module_url = "https://tfhub.dev/google/universal-sentence-encoder/4" 
  model = hub.load(module_url)

Installed with:

conda create -n my-tf2-env python=3.6 tensorflow
conda init bash
conda activate my-tf2-env
conda install -c conda-forge tensorflow-hub

But, for unknown reason after 3 weeks, Mac does not work with following error which fails at:

model = hub.load(module_url)

Error: SavedModel file does not exist at: /var/folders/99/8rwn_9hx3jj9x3qz6yf0j2f00000gp/T/tfhub_modules/063d866c06683311b44b4992fd46003be952409c/{saved_model.pbtxt|saved_model.pb}

On Mac, I recreated new env with same procedure but has same error.

On Ubuntu, all works well.

I want to know how to fix Mac. Thank you for help.

What I attempted on Mac is that I tried to download "https://tfhub.dev/google/universal-sentence-encoder/4" to local drive and load it from local drive in future, not from web url. This process was not finished and not successful yet. I don't remember if there is anything downloaded to Mac with this attempt, that might corrupted Tensorflow-hub on login user account of my Mac.

like image 367
user3792705 Avatar asked Oct 28 '25 13:10

user3792705


1 Answers

This error usually occurs when the saved_model.pb is not present in the path specified in the module_url.

For example, if we consider the Folder structure as shown in the screenshot below,

enter image description here

The code,

import tensorflow_hub as hub

module_url = "https://tfhub.dev/google/universal-sentence-encoder/4" 
model = hub.load(module_url)

and

import tensorflow_hub as hub

module_url = "/home/mothukuru/Downloads/Hub" 
model = hub.load(module_url)

work successfully.

But if saved_model.pb is not present in that Folder as shown below,

enter image description here

Executing the code,

import tensorflow_hub as hub

module_url = "/home/mothukuru/Downloads/Hub" 
model = hub.load(module_url)

results in the below error,

OSError: SavedModel file does not exist at: /home/mothukuru/Downloads/Hub/{saved_model.pbtxt|saved_model.pb}

In your specific case, executing the code while the Download of the Model was in progress might have resulted in the error.

As stated in the comment, deleting the Downloaded File can fix the problem.

Please let me know if this answer has not resolved your issue and I will be happy to modify it accordingly.