{"id":24726,"library":"torchserve","title":"TorchServe","description":"TorchServe is a flexible and easy-to-use tool for serving PyTorch models for inference at scale. Current version 0.12.0, released as part of the PyTorch ecosystem, with releases roughly quarterly.","status":"active","version":"0.12.0","language":"python","source_language":"en","source_url":"https://github.com/pytorch/serve","tags":["pytorch","model-serving","inference","deep-learning","torchserve"],"install":[{"cmd":"pip install torchserve torch-model-archiver","lang":"bash","label":"Install TorchServe and model archiver"}],"dependencies":[{"reason":"PyTorch dependency for model serving","package":"torch","optional":false},{"reason":"Tool for archiving models for TorchServe","package":"torch-model-archiver","optional":true}],"imports":[{"note":"Main import for TorchServe package; typically not used directly in user code.","wrong":"","symbol":"torchserve","correct":"import torchserve"}],"quickstart":{"code":"# Create a model archive\ntorch-model-archiver --model-name my_model --version 1.0 --model-file model.py --serialized-file model.pt --handler image_classifier\n\n# Start TorchServe\ntorchserve --start --model-store model_store --models my_model=my_model.mar\n\n# Send inference request\ncurl -X POST http://localhost:8080/predictions/my_model -T input.jpg","lang":"python","description":"Basic workflow: archive a model, start TorchServe, and make a prediction."},"warnings":[{"fix":"Use `--sync` flag or set `sync: true` in config.properties.","message":"Default backend changed from synchronous to asynchronous in v0.9.0. If your code relies on immediate callback or synchronous response, you need to enable it explicitly.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Install both packages: pip install torchserve torch-model-archiver","message":"The 'torchserve' package does not include the CLI entry points; you must also install 'torch-model-archiver' for the `torch-model-archiver` command.","severity":"gotcha","affected_versions":"all"},{"fix":"Implement a handler class inheriting from `torchserve.base_handler.BaseHandler`.","message":"TorchServe uses a custom handler API. Using a standard `nn.Module.forward()` directly will not work; you must wrap it in a handler class with `preprocess`, `inference`, and `postprocess` methods.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `torch-model-archiver my_model --version 1.0 --model-file model.py ...` instead of `--model-name my_model`.","message":"The `--model-name` flag in `torch-model-archiver` is deprecated in favor of positional argument.","severity":"deprecated","affected_versions":">=0.10.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install torchserve and torch-model-archiver: pip install torchserve torch-model-archiver","cause":"The 'torchserve' command is not available because only the Python package was installed without the CLI.","error":"torchserve: error: unrecognized arguments: --model-store model_store"},{"fix":"Install torchserve: pip install torchserve","cause":"The torchserve package is not installed or is not importable in the current environment.","error":"ModuleNotFoundError: No module named 'torchserve'"},{"fix":"Start TorchServe with `torchserve --start --model-store model_store` and check the log for the port (default 8080).","cause":"TorchServe is not running or is running on a different port.","error":"Connection refused: POST http://localhost:8080/predictions/my_model"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}