Home > database >  Using tf.saved_model.save() to save a model to GCS bucket from local
Using tf.saved_model.save() to save a model to GCS bucket from local

Time:03-01

I'm trying to save a tensorflow model to a GCS bucket from my local machine(Jupyter Notebook). I do have the google cloud storage credentails json. How do I save the model to the bucket since Tensorflow supports gcs links in saved_model

I used it as follows: tf.saved_model.save(model, "gs://your_bucket")

This throws the following error:

PermissionDeniedError: Error executing an HTTP request: HTTP response code 401 with body
Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.",

How do I use my credentials json I have ?

Edit: How to authenticate tf.saved_model.save() before calling it. I have the following service account credentials as a json.

CodePudding user response:

In the Python Script os.environ["GOOGLE_APPLICATION_CREDENTIALS"]='credentials.json' and then model.save('gs://your_model_path_in_bucket') works

  • Related