question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MaskRCNN not serving when using PyTorchServe Docker

See original GitHub issue

Steps which led me to the bug

  1. I downloaded PyTorch Serve Docker image from here --> https://hub.docker.com/r/pytorch/torchserve
  2. Downloaded https://download.pytorch.org/models/maskrcnn_resnet50_fpn_coco-bf2d0c1e.pth to my computer in folder C:/examples
  3. Downloaded https://github.com/pytorch/serve/tree/master/examples/ to my computer in folder C:/examples
  4. Created empty folder called model-store here --> C:/model-store
  5. Run the command docker run -it -p 8080:8080 -p 8081:8081 --name mar -v C:/model-store:/home/model-server/model-store -v C:/examples:/home/model-server/examples pytorch/torchserve:latest
  6. Run the command docker exec -it <container_name> /bin/bash
  7. From inside the container bash torch-model-archiver --force --model-name maskrcnn --version 1.0 --model-file /home/model-server/examples/object_detector/maskrcnn/model.py --serialized-file /home/model-server/examples/maskrcnn_resnet50_fpn_coco-bf2d0c1e.pth --handler object_detector --export-path /home/model-server/model-store --extra-files /home/model-server/examples/object_detector/index_to_name.json
  8. From inside the container bash torchserve --start --model-store /home/model-server/model-store --models maskrcnn=maskrcnn.mar
  9. Download persons.jpg to my desktop from here --> https://github.com/pytorch/serve/tree/master/examples/object_detector/maskrcnn
  10. From my desktop (host machine) curl http://127.0.0.1:8080/predictions/maskrcnn -T persons.jpg
  11. I am getting the following error { "code": 404, "type": "ModelNotFoundException", "message": "Model not found: maskrcnn" }

Note :- I followed the same steps for Densenet image classifier (from the examples from the repo) and it worked perfectly fine. MaskRCNN doesn’t work however

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
dhanainmecommented, Jan 29, 2021

A good place to debug would be to do a list model to confirm that the model has been registered.

curl -X GET http://127.0.0.1:8081/models should tell you if the model is registered.

2reactions
nagamanikandankcommented, Feb 4, 2021

@alvarobartt I had to redownload the image and it worked !!!

Attaching all the steps that worked for me. Thanks a lot !!!

docker pull ubuntu:18.04
docker run -it -p 9080:8080 -p 9081:8081 -p 9082:8082 -p 9070:7070 -p 9071:7071 --name maskrcnn_pytorch ubuntu:18.04
cd home/
apt-get update
apt-get install python3 python3-dev python3-pip openjdk-11-jre-headless git wget curl -y
python3 -m pip install torch --no-cache-dir
python3 -m pip install torchvision --no-cache-dir
python3 -m pip install torch-model-archiver --no-cache-dir
python3 -m pip install torchserve==0.2.0 --no-cache-dir
pip3 show torch
pip3 show torchvision
pip3 show torchserve
git clone https://github.com/pytorch/serve
wget https://download.pytorch.org/models/maskrcnn_resnet50_fpn_coco-bf2d0c1e.pth
torch-model-archiver --model-name maskrcnn --version 1.0 --model-file /home/serve/examples/object_detector/maskrcnn/model.py --serialized-file /home/maskrcnn_resnet50_fpn_coco-bf2d0c1e.pth --handler object_detector --extra-files /home/serve/examples/object_detector/index_to_name.json
mkdir model_store
mv maskrcnn.mar model_store/
python3 -m pip install opencv-python pillow requests --no-cache-dir
torchserve --start --model-store /home/model_store --models maskrcnn=maskrcnn.mar

===================================
In a New Docker cli of maskrcnn_pytorch container :-
===================================
curl -X GET http://127.0.0.1:8081/models
cd /home/serve/examples/object_detector
curl -X POST http://127.0.0.1:8080/predictions/maskrcnn -T persons.jpg
Read more comments on GitHub >

github_iconTop Results From Across the Web

Min requirements for torchserve - deployment - PyTorch Forums
What is the min requirements for deploying torchserve? My current system isnt low spec but seems to be hanging every time i up...
Read more >
Model Deployment using TorchServe | by Kaustav Mandal
TorchServe is a framework for serving pyTorch trained models in a seamless, performant manner. In this tutorial, we will walk though the steps...
Read more >
Log Analysis — MMDetection 2.26.0 documentation
3. Run mmdet-serve ¶. Check the official docs for running TorchServe with docker. In order to run in GPU, you need to install...
Read more >
Accelerating Inference Up to 6x Faster in PyTorch with Torch ...
A Linux machine with an NVIDIA GPU, compute architecture 7 or earlier; Docker installed, 19.03 or later; A Docker container with PyTorch, Torch- ......
Read more >
[WIP] Documentation fixes and enhancements (#584) (bacdf0a6 ...
This section shows a simple example of serving a model with TorchServe. To complete this example, ... Refer https://github.com/pytorch/serve/docker or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found