I have successfully trained a model on ML Engine. I can get the model.joblib
file from my Cloud Storage bucket and load it, and also get local predictions using gcloud
. However I can't create a model version.
JOB_DIR=$(gcloud ml-engine jobs describe "$JOB" \
--format="value(trainingInput.jobDir)")
gcloud ml-engine versions create "$VERSION" \
--model "$MODEL_NAME" \
--origin "$JOB_DIR" \
--framework scikit-learn \
--runtime-version 1.10 \
--python-version 3.5
Returns:
ERROR: (gcloud.ml-engine.versions.create) Bad model detected with error: "Failed to load model: Could not load the model: /tmp/model/0001/model.joblib. No module named 'trainer'. (Error code: 0)"
How can I fix this error?
My model is a sklearn Pipeline. It uses a FunctionTransformer
that calls a function in the trainer.model
module. I have wondered whether the VM that's serving predictions hasn't got that trainer
package installed. However I've been unable to confirm/reject this hypothesis or find a way in the documentation to point to the package.