0

I want to deploy a successful custom training job on GCP using a prebuilt scikit-learn container. The model I am using is a scikit-learn RandomForestClassifier saved using joblib. The deployment fails with

message: "terminate called after throwing an instance of 'std::length_error'"

However, based on this question, I can make a prediction by accessing GCSFS with the following:

from io import BytesIO
import numpy
blob = bucket.blob('project/model/model.joblib')
model_file = BytesIO()
blob.download_to_file(model_file)
model = joblib.load(model_file)
# Predict with one sample
print(model.predict(numpy.array([1,1,24,1,0,211,2,31]).reshape(1,-1)))

It also runs with gcloud ai-platform local predict --model-dir gs://modeldir \ --json-instances input.json \ --framework scikit-learn

If it runs successfully locally, I don't understand why it fails in the prediction container.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy