forked from open-mmlab/mmpose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support torchserve (open-mmlab#979)
* Support torchserve * add torchserve model conversion tool and model handler * add test script for model server * modify inference interface * fix requirements * fix bugs * fix unittest * add docs for model serving * fix NOTE in docs * fix doc format
- Loading branch information
Showing
18 changed files
with
561 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
ARG PYTORCH="1.6.0" | ||
ARG CUDA="10.1" | ||
ARG CUDNN="7" | ||
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel | ||
|
||
ENV PYTHONUNBUFFERED TRUE | ||
|
||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||
ca-certificates \ | ||
g++ \ | ||
openjdk-11-jre-headless \ | ||
# MMDet Requirements | ||
ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV PATH="/opt/conda/bin:$PATH" | ||
RUN export FORCE_CUDA=1 | ||
|
||
|
||
# MMLAB | ||
ARG PYTORCH | ||
ARG CUDA | ||
RUN ["/bin/bash", "-c", "pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu${CUDA//./}/torch${PYTORCH}/index.html"] | ||
RUN pip install mmpose | ||
|
||
# TORCHSEVER | ||
RUN pip install torchserve torch-model-archiver | ||
|
||
RUN useradd -m model-server \ | ||
&& mkdir -p /home/model-server/tmp | ||
|
||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
||
RUN chmod +x /usr/local/bin/entrypoint.sh \ | ||
&& chown -R model-server /home/model-server | ||
|
||
COPY config.properties /home/model-server/config.properties | ||
RUN mkdir /home/model-server/model-store && chown -R model-server /home/model-server/model-store | ||
|
||
EXPOSE 8080 8081 8082 | ||
|
||
USER model-server | ||
WORKDIR /home/model-server | ||
ENV TEMP=/home/model-server/tmp | ||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
CMD ["serve"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
ARG PYTORCH="1.6.0" | ||
ARG CUDA="10.1" | ||
ARG CUDNN="7" | ||
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel | ||
|
||
ARG MMCV="1.3.8" | ||
ARG MMCLS="0.16.0" | ||
|
||
ENV PYTHONUNBUFFERED TRUE | ||
|
||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||
ca-certificates \ | ||
g++ \ | ||
openjdk-11-jre-headless \ | ||
# MMDet Requirements | ||
ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV PATH="/opt/conda/bin:$PATH" | ||
RUN export FORCE_CUDA=1 | ||
|
||
# TORCHSEVER | ||
RUN pip install torchserve torch-model-archiver | ||
|
||
# MMLAB | ||
ARG PYTORCH | ||
ARG CUDA | ||
RUN ["/bin/bash", "-c", "pip install mmcv-full==${MMCV} -f https://download.openmmlab.com/mmcv/dist/cu${CUDA//./}/torch${PYTORCH}/index.html"] | ||
RUN pip install mmcls==${MMCLS} | ||
|
||
RUN useradd -m model-server \ | ||
&& mkdir -p /home/model-server/tmp | ||
|
||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
||
RUN chmod +x /usr/local/bin/entrypoint.sh \ | ||
&& chown -R model-server /home/model-server | ||
|
||
COPY config.properties /home/model-server/config.properties | ||
RUN mkdir /home/model-server/model-store && chown -R model-server /home/model-server/model-store | ||
|
||
EXPOSE 8080 8081 8082 | ||
|
||
USER model-server | ||
WORKDIR /home/model-server | ||
ENV TEMP=/home/model-server/tmp | ||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
CMD ["serve"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
inference_address=http://0.0.0.0:8080 | ||
management_address=http://0.0.0.0:8081 | ||
metrics_address=http://0.0.0.0:8082 | ||
model_store=/home/model-server/model-store | ||
load_models=all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [[ "$1" = "serve" ]]; then | ||
shift 1 | ||
torchserve --start --ts-config /home/model-server/config.properties | ||
else | ||
eval "$@" | ||
fi | ||
|
||
# prevent docker exit | ||
tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.