I have saved a classifier model with pickle using the following code-
import pickle
with open('skm.pickle', 'wb') as fid:
pickle.dump(clf, fid)
Now, during deployment, when I try to load this same model, it is giving an error-
Error:
{
"code": "AciDeploymentFailed",
"statusCode": 400,
"message": "Aci Deployment failed with exception: Error in entry script, FileNotFoundError: [Errno 2] No such file or directory: './skm.pickle', please run print(service.get_logs()) to get details.",
"details": [
{
"code": "CrashLoopBackOff",
"message": "Error in entry script, FileNotFoundError: [Errno 2] No such file or directory: './skm.pickle', please run print(service.get_logs()) to get details."
}
]
}
This is the score.py file where I am loading the pickle model and the same file is called during deployment. Also note that, all these files (code, pickle file and related files) are in the same directory.
%%writefile sklearnscore.py
import json
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from sklearn.ensemble import RandomForestClassifier
import pickle
# Initialize the deployment environment
def init():
# read in the model file
from sklearn.pipeline import Pipeline
global obj
with open('./skm.pickle', 'rb') as f:
obj = pickle.load(f)
I am registering the model using- model = Model.register(ws, model_name="utility15", model_path="./skm.pickle")
And the deployment code is-
service_name = 'my-custom-env-service-4'
sklearn_env = Environment.from_conda_specification(name='sklearn-env', file_path='Sklearn.yaml')
inference_config = InferenceConfig(entry_script='sklearnscore.py', environment=sklearn_env)
aci_config = AciWebservice.deploy_configuration(cpu_cores=1, memory_gb=4,tags={'Createdby':'xyz'})
service = Model.deploy(workspace=ws,
name=service_name,
models=[model],
inference_config=inference_config,
deployment_config=aci_config,
overwrite=True)
service.wait_for_deployment(show_output=True)
When this script is run, it calls the score.py file and the file not found error comes up for pickle file. I have even tried loading the model without the ./ thing, but the same error comes up.