Cannot run Google ML engine locally due to Tensorf

2019-03-04 02:07发布

问题:

I'm trying to run the Google Cloud ML engine locally for debugging purposes by running the command gcloud ml-engine local predict --model-dir=fasttext_cloud/ --json-instances=debug_instance.json. However, I'm getting the error: ERROR: (gcloud.ml-engine.local.predict) Cannot import Tensorflow.

This is strange as Tensorflow works fine on my machine. Even a simple example like python -c 'import tensorflow' has no issues whatsoever.

回答1:

Is TensorFlow installed in a virtual environment or a non-standard location that isn't on the Python path when running from gcloud?

Its a bit kludgy but I would do the following to check the Python path being used by gcloud. Modify the file

${GCLOUD_INSTALL_LOCATION}/google-cloud-sdk/lib/surface/ml_engine/__init__.py

At the top of the file add

import sys
print("\n".join(sys.path))

Then run

gcloud ml-engine

This should print out the python path and you can now check that it includes the location where TensorFlow is installed.



回答2:

Can you upgrade to the latest gcloud release (171.0.0) and retry? To upgrade, run

$ gcloud components update