Skip to content

Commit

Permalink
Merge branch 'stage_release' into issue_98
Browse files Browse the repository at this point in the history
  • Loading branch information
harshbafna committed Apr 1, 2020
2 parents d6763b5 + 5960409 commit 89602d0
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pip install .
*Install torch-model-archiver as follows:
```bash
cd serve/model-archiver
cd model-archiver
pip install .
```
Expand All @@ -132,7 +132,7 @@ torchserve --help
For this quick start, we'll skip over most of the features, but be sure to take a look at the [full server docs](docs/server.md) when you're ready.
Here is an easy example for serving an object classification model:
Here is an easy example for serving an object classification model (make sure to run it at the root of the repository):
```bash
wget https://download.pytorch.org/models/densenet161-8d451a50.pth
torch-model-archiver --model-name densenet161 --version 1.0 --model-file examples/image_classifier/densenet_161/model.py --serialized-file densenet161-8d451a50.pth --extra-files examples/image_classifier/index_to_name.json --handler image_classifier
Expand Down
12 changes: 3 additions & 9 deletions ci/buildspec.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build Spec for AWS CodeBuild CI

version: 0.1
version: 0.2

phases:
install:
Expand All @@ -15,17 +15,11 @@ phases:
- pip install twine
- pip install pytest-mock -U
- pip install requests
- pip install -U -e .
- pip install torch
- pip install torchvision
- cd model-archiver/ && pip install -U -e . && cd ../
- pip install psutil

build:
commands:
- frontend/gradlew -p frontend build
- python -m pytest ts/tests/unit_tests
- cd model-archiver/ && python -m pytest model_archiver/tests/unit_tests && cd ../
- cd model-archiver/ && python -m pytest model_archiver/tests/integ_tests && cd ../
- ./torchserve_sanity.sh
- cd serving-sdk/ && mvn clean deploy && cd ../

artifacts:
Expand Down
42 changes: 42 additions & 0 deletions codebuild/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM ubuntu:18.04

ENV PYTHONUNBUFFERED TRUE

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
fakeroot \
ca-certificates \
dpkg-dev \
g++ \
python3-dev \
curl \
vim \
openjdk-11-jdk \
&& rm -rf /var/lib/apt/lists/* \
&& cd /tmp \
&& curl -O https://bootstrap.pypa.io/get-pip.py \
&& python3 get-pip.py

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
RUN update-alternatives --install /usr/local/bin/pip pip /usr/local/bin/pip3 1

RUN pip install torch torchvision -f https://download.pytorch.org/whl/torch_stable.html

ENV JAVA_VERSION=11 \
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" \
JDK_HOME="/usr/lib/jvm/java-11-openjdk-amd64" \
JRE_HOME="/usr/lib/jvm/java-11-openjdk-amd64" \
ANT_VERSION=1.10.3 \
MAVEN_HOME="/opt/maven" \
MAVEN_VERSION=3.5.4 \
MAVEN_CONFIG="/root/.m2" \
MAVEN_DOWNLOAD_SHA1="22cac91b3557586bb1eba326f2f7727543ff15e3"

# Install Maven
RUN set -ex \
&& mkdir -p $MAVEN_HOME \
&& curl -LSso /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz https://apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
&& echo "$MAVEN_DOWNLOAD_SHA1 /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz" | sha1sum -c - \
&& tar xzvf /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz -C $MAVEN_HOME --strip-components=1 \
&& update-alternatives --install /usr/bin/mvn mvn /opt/maven/bin/mvn 10000 \
&& mkdir -p $MAVEN_CONFIG
42 changes: 42 additions & 0 deletions codebuild/Dockerfile.gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM nvidia/cuda:10.1-cudnn7-runtime-ubuntu18.04

ENV PYTHONUNBUFFERED TRUE

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
fakeroot \
ca-certificates \
dpkg-dev \
g++ \
python3-dev \
curl \
vim \
openjdk-11-jdk \
&& rm -rf /var/lib/apt/lists/* \
&& cd /tmp \
&& curl -O https://bootstrap.pypa.io/get-pip.py \
&& python3 get-pip.py

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
RUN update-alternatives --install /usr/local/bin/pip pip /usr/local/bin/pip3 1

RUN pip install torch torchvision

ENV JAVA_VERSION=11 \
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" \
JDK_HOME="/usr/lib/jvm/java-11-openjdk-amd64" \
JRE_HOME="/usr/lib/jvm/java-11-openjdk-amd64" \
ANT_VERSION=1.10.3 \
MAVEN_HOME="/opt/maven" \
MAVEN_VERSION=3.5.4 \
MAVEN_CONFIG="/root/.m2" \
MAVEN_DOWNLOAD_SHA1="22cac91b3557586bb1eba326f2f7727543ff15e3"

# Install Maven
RUN set -ex \
&& mkdir -p $MAVEN_HOME \
&& curl -LSso /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz https://apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
&& echo "$MAVEN_DOWNLOAD_SHA1 /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz" | sha1sum -c - \
&& tar xzvf /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz -C $MAVEN_HOME --strip-components=1 \
&& update-alternatives --install /usr/bin/mvn mvn /opt/maven/bin/mvn 10000 \
&& mkdir -p $MAVEN_CONFIG
2 changes: 1 addition & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Metrics are collected by default at:
* System metrics - log_directory/ts_metrics.log
* Custom metrics - log directory/model_metrics.log

The location of log files and metric files can be configured at [log4j.properties](https://github.com/pytorch/serve/blob/master/frontend/server/src/main/resources/log4j.properties) file.
The location of log files and metric files can be configured at [log4j.properties](https://github.com/pytorch/serve/blob/master/frontend/server/src/main/resources/log4j.properties) file


## System Metrics
Expand Down
2 changes: 1 addition & 1 deletion docs/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The rest of this topic focus on serving of model files without much discussion o

```bash
$ torchserve --help
usage: torechserve [-h] [-v | --version]
usage: torchserve [-h] [-v | --version]
[--start]
[--stop]
[--ts-config TS_CONFIG]
Expand Down
2 changes: 1 addition & 1 deletion examples/text_to_speech_synthesizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pip install librosa --user
* Download the checkpoint for NVIDIA WaveGlow model :

```bash
https://api.ngc.nvidia.com/v2/models/nvidia/waveglowpyt_fp32/versions/1/files/nvidia_waveglowpyt_fp32_20190306.pth
wget https://api.ngc.nvidia.com/v2/models/nvidia/waveglowpyt_fp32/versions/1/files/nvidia_waveglowpyt_fp32_20190306.pth
```

* Create a torch model archive using the torch-model-archiver utility to archive the above files.
Expand Down
4 changes: 4 additions & 0 deletions serving-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<!--TODO - The compiler needs to change to use Java 11 in the future-->
<configuration>
<source>8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
119 changes: 119 additions & 0 deletions torchserve_sanity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash
set -euxo pipefail

cleanup()
{
torchserve --stop

rm -rf model_store

rm -rf logs
}

pip install mock pytest==3.6 pylint pytest-mock pytest-cov

cd frontend

if ./gradlew clean build;
then
echo "Frontend build suite execution successfully"
else
echo "Frontend build suite execution failed!!! Check logs for more details"
exit 1
fi

cd ..
if python -m pytest --cov-report html:htmlcov --cov=ts/ ts/tests/unit_tests/;
then
echo "Backend test suite execution successfully"
else
echo "Backend test suite execution failed!!! Check logs for more details"
exit 1
fi

pip uninstall --yes torchserve
pip uninstall --yes torch-model-archiver

if pip install .;
then
echo "Successfully installed TorchServe"
else
echo "TorchServe installation failed"
exit 1
fi

cd model-archiver

if python -m pytest --cov-report html:htmlcov --cov=model_archiver/ model_archiver/tests/unit_tests/;
then
echo "Model-archiver UT test suite execution successfully"
else
echo "Model-archiver UT test suite execution failed!!! Check logs for more details"
exit 1
fi

if pip install .;
then
echo "Successfully installed torch-model-archiver"
else
echo "torch-model-archiver installation failed"
exit 1
fi

if python -m pytest --cov-report html:htmlcov --cov=model_archiver/ model_archiver/tests/integ_tests/;
then
echo "Model-archiver IT test suite execution successful"
else
echo "Model-archiver IT test suite execution failed!!! Check logs for more details"
exit 1
fi

cd ..

mkdir model_store

echo "Starting TorchServe"
torchserve --start --model-store model_store &
pid=$!
count=$(ps -A| grep $pid |wc -l)
if [[ $count -eq 1 ]]
then
if wait $pid; then
echo "Successfully started TorchServe"
else
echo "TorchServe start failed (returned $?)"
exit 1
fi
else
echo "Successfully started TorchServe"
fi

sleep 10

echo "Registering resnet-18 model"
response=$(curl --write-out %{http_code} --silent --output /dev/null --retry 5 -X POST "http://localhost:8081/models?url=https://torchserve.s3.amazonaws.com/mar_files/resnet-18.mar&initial_workers=1&synchronous=true")

if [ ! "$response" == 200 ]
then
echo "Failed to register model with torchserve"
cleanup
exit 1
else
echo "Successfully registered resnet-18 model with torchserve"
fi

echo "Running inference on resnet-18 model"
response=$(curl --write-out %{http_code} --silent --output /dev/null --retry 5 -X POST http://localhost:8080/predictions/resnet-18 -T examples/image_classifier/kitten.jpg)

if [ ! "$response" == 200 ]
then
echo "Failed to run inference on resnet-18 model"
cleanup
exit 1
else
echo "Successfully ran infernece on resnet-18 model."
fi

cleanup

echo "CONGRATULATIONS!!! YOUR BRANCH IS IN STABLE STATE"

0 comments on commit 89602d0

Please sign in to comment.