You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MLflow Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the MLflow code base?
Yes. I can contribute a fix for this bug independently.
Yes. I would be willing to contribute a fix for this bug with guidance from the MLflow community.
No. I cannot contribute a bug fix at this time.
System information
Have I written custom code (as opposed to using a stock example script provided in MLflow): Yes
OS Platform and Distribution (e.g., Linux Ubuntu 18.04): Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux
MLflow installed from (source or binary): binary
MLflow version (run mlflow --version): 1.19.0
MLflow TorchServe Deployment plugin installed from (source or binary): binary
MLflow TorchServe Deployment plugin version (run mlflow deployments--version): 0.1.0
TorchServe installed from (source or binary): binary
TorchServe version (run torchserve --version): 0.4.2
I have trained a custom PyTorch models for an image classification problem. The model is logged to a Google Cloud Storage bucket. When I try to deploy the model to torchserve I get: ModuleNotFoundError: No module named 'models' error. From what I understand mlflow.pytorch.log_model() calls torch.save(model) internally. This creates a dependency on the directory structure 18325 .
Code to reproduce issue
I have saved the MLFlow model on GCS bucket using the below script: mlflow.pytorch.log_model(model, "{}_model".format('livenet'))
The model deployment is using the command below: mlflow deployments create -t torchserve -m gs://<model_bucket>/models/classnet/48d548cc841d4c2b9a06e975dec88c8e/artifacts/classnet_model --name classnet -C 'MODEL_FILE=models/classnet.py' -C 'HANDLER=model_handler.py' -C 'EXTRA_FILES=transforms.py,artifacts/models/desnse_depth.pt,models/dense_depth.py'
The text was updated successfully, but these errors were encountered:
akasantony
changed the title
MLFlow model deplyoments error when deploying PyTorch model - ModuleNotFoundError: No module named 'models'
MLFlow model deplyoments error when deploying PyTorch model from GCS bucket - ModuleNotFoundError: No module named 'models'
Aug 30, 2021
From the information you have shared, the model is saved using mlflow.pytorch.log_model and while loading the model, base handler is trying to load it as state dict.
mlflow.pytorch.log_model uses cloudpickle and saves the entire model structure using torch.save. To load the model, you can refer this custom handler IrisClassification example. In this example, the model is saved using mlflow.pytorch and loaded using torch.load.
Willingness to contribute
The MLflow Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the MLflow code base?
System information
mlflow --version
): 1.19.0mlflow deployments--version
): 0.1.0torchserve --version
): 0.4.2mlflow deployments create -t torchserve -m gs://<model_bucket>/models/classnet/48d548cc841d4c2b9a06e975dec88c8e/artifacts/classnet_model --name classnet -C 'MODEL_FILE=models/classnet.py' -C 'HANDLER=model_handler.py' -C 'EXTRA_FILES=transforms.py,artifacts/models/desnse_depth.pt,models/dense_depth.py'
Describe the problem
I have trained a custom PyTorch models for an image classification problem. The model is logged to a Google Cloud Storage bucket. When I try to deploy the model to torchserve I get:
ModuleNotFoundError: No module named 'models'
error. From what I understandmlflow.pytorch.log_model()
callstorch.save(model)
internally. This creates a dependency on the directory structure 18325 .Code to reproduce issue
I have saved the MLFlow model on GCS bucket using the below script:
mlflow.pytorch.log_model(model, "{}_model".format('livenet'))
The model deployment is using the command below:
mlflow deployments create -t torchserve -m gs://<model_bucket>/models/classnet/48d548cc841d4c2b9a06e975dec88c8e/artifacts/classnet_model --name classnet -C 'MODEL_FILE=models/classnet.py' -C 'HANDLER=model_handler.py' -C 'EXTRA_FILES=transforms.py,artifacts/models/desnse_depth.pt,models/dense_depth.py'
Other info / logs
What component(s) does this bug affect?
Components
area/deploy
: Main deployment plugin logicarea/build
: Build and test infrastructure for MLflow TorchServe Deployment Pluginarea/docs
: MLflow TorchServe Deployment Plugin documentation pagesarea/examples
: Example codeThe text was updated successfully, but these errors were encountered: