serve icon indicating copy to clipboard operation
serve copied to clipboard

ModuleNotFoundError: No module named demo_service

Open ddevanir opened this issue 6 years ago • 3 comments

While I was setting up custome service defined here - https://github.com/pytorch/serve/blob/master/docs/custom_service.md

This is the command I ran to create the model archive - torch-model-archiver --model-name demo -v 1.0 --serialized-file demo_model.pt --handler demo_service:handle

  1. I get the error saying the handler should be part of py if not default "Handler should be one of the default TorchServe handlers [{0}] or a py file to handle custom TorchServe inference logic"

But the file is demo_service.py so it is part of .py extension. So I don’t understand why this error or if I am missing something

  1. I am able to register the model correctly but when I try to scale the worker for the model, I get an error "ModuleNotFoundError: No module named ‘demo_service'" org.pytorch.serve.wlm.WorkerLifeCycle - ModuleNotFoundError: No module named 'demo_service'

This is the MANIFEST file of the model archieve - { "runtime": "python", "model": { "modelName": "demo", "serializedFile": "demo_model.pt", "handler": "demo_service:handle", "modelVersion": "1.0" }, "modelServerVersion": "1.0", "implementationVersion": "1.0", "specificationVersion": "1.0" }

Only difference I see is that the mar file of torchserve has: MAR-INF ovl_model.pt Whereas the mar file of MMS has: MAR-INF 0038.params mms_service.py

So the MMS has the handler file as well which is missing in torchserve

I had used MMS before, and I was able to get started with it correctly. I see that this is similar to MMS. Is there something else I am missing?

ddevanir avatar Jun 16 '20 17:06 ddevanir

@ddevanir There seems to be a bug in the model-archiver utility. As a workaround, please use --handler demo_service.py instead of --handler demo_service:handle

The mar creation should have failed. Have you created mar file manually to register it? Asking this questions since you are able to register model?

I am able to register the model correctly but when I try to scale the worker for the model, I get an error "ModuleNotFoundError: No module named ‘demo_service'"
org.pytorch.serve.wlm.WorkerLifeCycle - ModuleNotFoundError: No module named 'demo_service'

NOTE if you are planning to create mar file for torch eager mode models then you will have to provide --model-file as well. Refer mar doc

codinnvrends avatar Jun 16 '20 18:06 codinnvrends

I have fixed the bug locally and was able to pass the creation of mar. I was able to get it working end to end. Thanks.

Another question: I see that we can serve the model in MMS as well. What is the advantage of TorchServe over MMS?

ddevanir avatar Jun 17 '20 05:06 ddevanir

@ddevanir TorchServe as the name indicates is a model serving component for PyTorch and hence provides some specific features/examples for pytorch. e.g. default handlers are not there in mms or versioning/snapshot are some of the other features not part of mms. And is driven by the PyTorch community. Overall framework has been derived from mms.

codinnvrends avatar Jun 17 '20 05:06 codinnvrends