Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit adf54f6

Browse files
authored
Merge branch 'master' into issue_1107
2 parents 0deb350 + 3196b43 commit adf54f6

File tree

125 files changed

+2280
-749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+2280
-749
lines changed

.circleci/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Following _executors_ are available for job execution -
5454
2. ubuntu18-conda38-cpu-docker
5555
3. ubuntu18-pyenv37-cpu-docker
5656
4. ubuntu18-venv36-cpu-docker
57+
5. ubuntu18-conda39-cpu-docker
5758

5859
> Please check the _workflows_, _jobs_ and _executors_ section in _config.yml_ for an up to date list
5960
@@ -74,6 +75,7 @@ Available environment types are
7475
* `conda38`: python 3.8 with `conda` env
7576
* `pyenv37`: python 3.7 with `pyenv` env
7677
* `venv36`: python 3.6.9 with `venv` env
78+
* `conda39`: python 3.9 with `conda` env
7779
```
7880
./build_cci_image.sh --env_type <env-type>
7981
```

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ version: 2.1
33

44
executors:
55
# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY under 'Project Settings > Environment Variables' in CircleCI
6+
ubuntu18-conda39-cpu-docker:
7+
docker:
8+
- image: 630887156731.dkr.ecr.us-east-1.amazonaws.com/torchserve-build:ubuntu18-conda39-cpu
69
ubuntu18-pythn36-cpu-docker:
710
docker:
811
- image: 630887156731.dkr.ecr.us-east-1.amazonaws.com/torchserve-build:ubuntu18-pythn36-cpu
@@ -250,6 +253,7 @@ workflows:
250253
matrix: &matrix
251254
parameters:
252255
executor:
256+
- ubuntu18-conda39-cpu-docker
253257
- ubuntu18-pythn36-cpu-docker
254258
- ubuntu18-conda38-cpu-docker
255259
- ubuntu18-pyenv37-cpu-docker

.circleci/images/Dockerfile

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ RUN DEBIAN_FRONTEND=noninteractive \
1919
&& apt-get install --no-install-recommends -y \
2020
nodejs
2121

22+
# Install python 3.9 using conda env
23+
FROM compile-image as conda39-image
24+
ENV PATH ~/.local/bin/:$PATH
25+
ENV PATH=/miniconda/bin:${PATH}
26+
RUN curl -LO http://repo.continuum.io/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh \
27+
&& bash Miniconda3-py39_4.9.2-Linux-x86_64.sh -p /miniconda -b \
28+
&& rm Miniconda3-py39_4.9.2-Linux-x86_64.sh \
29+
&& rm -rf /var/lib/apt/lists/* \
30+
&& conda install -y conda-build
31+
2232
# Install python 3.8 using conda env
2333
FROM compile-image as conda38-image
2434
ENV PATH ~/.local/bin/:$PATH
@@ -39,7 +49,8 @@ RUN apt-get install --no-install-recommends -y \
3949
python3-setuptools \
4050
python3-wheel \
4151
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \
42-
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
52+
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 \
53+
&& pip3 install --upgrade pip
4354

4455
# Install python 3.7 using pyenv env
4556
FROM compile-image as pyenv37-image
@@ -50,7 +61,8 @@ RUN apt-get install --no-install-recommends -y libssl-dev zlib1g-dev libbz2-dev
5061
libsqlite3-dev libxml2-dev libxmlsec1-dev libffi-dev\
5162
&& curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash \
5263
&& pyenv install 3.7.0 \
53-
&& pyenv global 3.7.0
64+
&& pyenv global 3.7.0 \
65+
&& pip3 install --upgrade pip
5466

5567
# Install python 3.6 and venv env
5668
FROM compile-image as venv36-image
@@ -66,7 +78,8 @@ RUN apt-get install --no-install-recommends -y \
6678
python3-venv\
6779
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \
6880
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1\
69-
&& python3 -m venv $VIRTUAL_ENV
81+
&& python3 -m venv $VIRTUAL_ENV \
82+
&& pip3 install --upgrade pip
7083

7184

7285
FROM ${ENV_TYPE}-image AS final-image
@@ -103,9 +116,9 @@ RUN pip install --no-cache-dir \
103116
pytest-mock \
104117
requests \
105118
sentencepiece \
106-
torch==1.6.0 \
107-
torchaudio==0.6.0 \
108-
torchtext==0.7.0 \
109-
torchvision==0.7.0 \
110-
transformers\
111-
wheel
119+
torch==1.8.1 \
120+
torchaudio==0.8.1 \
121+
torchtext==0.9.1 \
122+
torchvision==0.9.1 \
123+
transformers==4.6.0 \
124+
wheel

.circleci/images/build_cci_image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ do
99
-h|--help)
1010
echo "options:"
1111
echo "-h, --help show brief help"
12-
echo "-e, --env_type specify env_type to use from { pythn36, conda38, pyenv37, venv36 }"
12+
echo "-e, --env_type specify env_type to use from { pythn36, conda38, pyenv37, venv36, conda39 }"
1313
echo "-t, --tag specify tag name for docker image \"<image>:<tag>\""
1414
exit 0
1515
;;

.circleci/scripts/linux_test_sanity.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source ts_scripts/install_utils
44

5-
MODELS=("fastrcnn" "fcn_resnet_101" "deeplabv3_resnet_101_eager" "my_text_classifier_v2" "resnet-18" "my_text_classifier_scripted_v2" "alexnet_scripted" "fcn_resnet_101_scripted"
5+
MODELS=("fastrcnn" "fcn_resnet_101" "deeplabv3_resnet_101_eager" "my_text_classifier_v4" "resnet-18" "my_text_classifier_scripted_v3" "alexnet_scripted" "fcn_resnet_101_scripted"
66
"deeplabv3_resnet_101_scripted" "distill_bert_qa_eager" "bert_token_classification_no_torchscript" "bert_seqc_without_torchscript")
77
MODEL_INPUTS=("examples/object_detector/persons.jpg,docs/images/blank_image.jpg" "examples/image_segmenter/persons.jpg" "examples/image_segmenter/persons.jpg"
88
"examples/text_classification/sample_text.txt" "examples/image_classifier/kitten.jpg" "examples/text_classification/sample_text.txt" "examples/image_classifier/kitten.jpg"

.github/workflows/doc-automation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [3.6]
10+
python-version: [3.8]
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v2

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ dist/
1010
.github/.DS_Store
1111
.DS_Store
1212
frontend/server/src/main/java/org/pytorch/serve/grpc/
13+
*.pem
14+
*.backup
1315

1416
# Postman files
1517
test/artifacts/
@@ -18,5 +20,10 @@ test/model_store/
1820
test/ts_console.log
1921
test/config.properties
2022

23+
2124
.vscode
2225
.scratch/
26+
27+
# Custom benchmark artifacts
28+
instances.yaml
29+
instances.yaml.backup

CONTRIBUTING.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ If you are interested in contributing to TorchServe, your contributions will fal
2121
```
2222
> Supported cuda versions as cu111, cu102, cu101, cu92
2323

24-
- Execute sanity suite
24+
- Run sanity suite
2525
```bash
26-
python ./torchserve_sanity.py
26+
python torchserve_sanity.py
2727
```
28+
- Run Regression test `python test/regression_tests.py`
2829
- For running individual test suites refer [code_coverage](docs/code_coverage.md) documentation
30+
- If you are updating an existing model make sure that performance hasn't degraded by running [benchmarks](https://github.com/pytorch/serve/tree/master/benchmarks) on the master branch and your branch and verify there is no performance regression
31+
- For large changes make sure to run the [automated benchmark suite](https://github.com/pytorch/serve/tree/master/test/benchmark) which will run the apache bench tests on several configurations of CUDA and EC2 instances
2932
- If you need more context on a particular issue, please create raise a ticket on [`TorchServe` GH repo](https://github.com/pytorch/serve/issues/new/choose) or connect to [PyTorch's slack channel](https://pytorch.slack.com/)
3033

3134
Once you finish implementing a feature or bug-fix, please send a Pull Request to https://github.com/pytorch/serve. Use this [template](pull_request_template.md) when creating a Pull Request.

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ TorchServe is a flexible and easy to use tool for serving PyTorch models.
2222
* [Serve a Model](#serve-a-model)
2323
* [Serve a Workflow](docs/workflows.md)
2424
* [Quick start with docker](#quick-start-with-docker)
25+
* [Highlighted Examples](#highlighted-examples)
26+
* [Featured Community Projects](#featured-community-projects)
2527
* [Contributing](#contributing)
2628

2729
## Install TorchServe and torch-model-archiver
@@ -43,22 +45,24 @@ TorchServe is a flexible and easy to use tool for serving PyTorch models.
4345
```bash
4446
python ./ts_scripts/install_dependencies.py --cuda=cu102
4547
```
48+
49+
Note: PyTorch 1.9+ will not support cu92 and cu101. So TorchServe only supports cu92 and cu101 up to PyTorch 1.8.1.
4650

4751
#### For Windows
4852

4953
Refer to the documentation [here](docs/torchserve_on_win_native.md).
5054

51-
2. Install torchserve and torch-model-archiver
55+
2. Install torchserve, torch-model-archiver and torch-workflow-archiver
5256

5357
For [Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install)
5458
Note: Conda packages are not supported for Windows. Refer to the documentation [here](docs/torchserve_on_win_native.md).
5559
```
56-
conda install torchserve torch-model-archiver -c pytorch
60+
conda install torchserve torch-model-archiver torch-workflow-archiver -c pytorch
5761
```
5862

5963
For Pip
6064
```
61-
pip install torchserve torch-model-archiver
65+
pip install torchserve torch-model-archiver torch-workflow-archiver
6266
```
6367

6468
Now you are ready to [package and serve models with TorchServe](#serve-a-model).
@@ -71,7 +75,7 @@ Ensure that you have `python3` installed, and the user has access to the site-pa
7175

7276
Run the following script from the top of the source directory.
7377

74-
NOTE: This script uninstalls existing `torchserve` and `torch-model-archiver` installations
78+
NOTE: This script uninstalls existing `torchserve`, `torch-model-archiver` and `torch-workflow-archiver` installations
7579

7680
#### For Debian Based Systems/ MacOS
7781

@@ -136,7 +140,7 @@ torchserve --start --ncs --model-store model_store --models densenet161.mar
136140

137141
After you execute the `torchserve` command above, TorchServe runs on your host, listening for inference requests.
138142

139-
**Note**: If you specify model(s) when you run TorchServe, it automatically scales backend workers to the number equal to available vCPUs (if you run on a CPU instance) or to the number of available GPUs (if you run on a GPU instance). In case of powerful hosts with a lot of compute resoures (vCPUs or GPUs), this start up and autoscaling process might take considerable time. If you want to minimize TorchServe start up time you should avoid registering and scaling the model during start up time and move that to a later point by using corresponding [Management API](docs/management_api.md#register-a-model), which allows finer grain control of the resources that are allocated for any particular model).
143+
**Note**: If you specify model(s) when you run TorchServe, it automatically scales backend workers to the number equal to available vCPUs (if you run on a CPU instance) or to the number of available GPUs (if you run on a GPU instance). In case of powerful hosts with a lot of compute resources (vCPUs or GPUs), this start up and autoscaling process might take considerable time. If you want to minimize TorchServe start up time you should avoid registering and scaling the model during start up time and move that to a later point by using corresponding [Management API](docs/management_api.md#register-a-model), which allows finer grain control of the resources that are allocated for any particular model).
140144

141145
### Get predictions from a model
142146

@@ -212,6 +216,11 @@ To stop the currently running TorchServe instance, run:
212216
torchserve --stop
213217
```
214218

219+
### Inspect the logs
220+
All the logs you've seen as output to stdout related to model registration, management, inference are recorded in the `/logs` folder.
221+
222+
High level performance data like Throughput or Percentile Precision can be generated with [Benchmark](benchmark/README.md) and visualized in a report.
223+
215224
### Concurrency And Number of Workers
216225
TorchServe exposes configurations that allow the user to configure the number of worker threads on CPU and GPUs. There is an important config property that can speed up the server depending on the workload.
217226
*Note: the following property has bigger impact under heavy workloads.*
@@ -239,9 +248,12 @@ Feel free to skim the full list of [available examples](examples/README.md)
239248
## Learn More
240249
241250
* [Full documentation on TorchServe](docs/README.md)
242-
* [Manage models API](docs/management_api.md)
251+
* [Model Management API](docs/management_api.md)
243252
* [Inference API](docs/inference_api.md)
253+
* [Metrics API](docs/metrics.md)
244254
* [Package models for use with TorchServe](model-archiver/README.md)
255+
* [Deploying TorchServe with Kubernetes](kubernetes/README.md)
256+
* [TorchServe Workflows](examples/Workflows/README.md)
245257
* [TorchServe model zoo for pre-trained and pre-packaged models-archives](docs/model_zoo.md)
246258
247259
## Contributing
@@ -255,4 +267,4 @@ To file a bug or request a feature, please file a GitHub issue. For filing pull
255267
## Disclaimer
256268
This repository is jointly operated and maintained by Amazon, Facebook and a number of individual contributors listed in the [CONTRIBUTORS](https://github.com/pytorch/serve/graphs/contributors) file. For questions directed at Facebook, please send an email to [email protected]. For questions directed at Amazon, please send an email to [email protected]. For all other questions, please open up an issue in this repository [here](https://github.com/pytorch/serve/issues).
257269
258-
*TorchServe acknowledges the [Multi Model Server (MMS)](https://github.com/awslabs/multi-model-server) project from which it was derived*
270+
*TorchServe acknowledges the [Multi Model Server (MMS)](https://github.com/awslabs/multi-model-server) project from which it was derived*

benchmarks/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ We currently support benchmarking with JMeter & Apache Bench. One can also profi
66

77
* [Benchmarking with JMeter](#benchmarking-with-jmeter)
88
* [Benchmarking with Apache Bench](#benchmarking-with-apache-bench)
9+
* [AutoBenchmarking Apachage Bench on AWS](#benchmarking-apache-bench-aws)
910
* [Profiling](#profiling)
1011

1112
# Benchmarking with JMeter
@@ -304,7 +305,7 @@ Note: These pre-defined parameters in test plan can be overwritten by cmd line a
304305
The reports are generated at location "/tmp/benchmark/"
305306
- CSV report: /tmp/benchmark/ab_report.csv
306307
- latency graph: /tmp/benchmark/predict_latency.png
307-
- torhcserve logs: /tmp/benchmark/logs/model_metrics.log
308+
- torchserve logs: /tmp/benchmark/logs/model_metrics.log
308309
- raw ab output: /tmp/benchmark/result.txt
309310

310311
### Sample output CSV
@@ -315,6 +316,9 @@ The reports are generated at location "/tmp/benchmark/"
315316
### Sample latency graph
316317
![](predict_latency.png)
317318

319+
# Benchmarking Apache Bench AWS
320+
If you're making a large change to TorchServe it's best to run an [automated benchmarking suite on AWS](https://github.com/pytorch/serve/tree/master/test/benchmark) so that you can test multiple CUDA versions and EC2 hardware configurations easily.
321+
318322
# Profiling
319323

320324
## Frontend

0 commit comments

Comments
 (0)