Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to run on Jetson Xavier NX. #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deploy_trt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ max_size=640,640
# Force FP16 mode for building TensorRT engines, even if it's not supported.
# Please check that your GPU supports FP16, otherwise performance may drop.
# For GPUs supporting it gives about 2x performance boost.
force_fp16=False
force_fp16=True


# DET MODELS:
Expand Down Expand Up @@ -100,7 +100,7 @@ for i in $(seq 0 $(($n_gpu - 1)) ); do
docker rm $name;
echo --- Starting container $name with $device at port $port;
((p++));
docker run -p $port:18080\
docker run --runtime=nvidia -p $port:18080\
--gpus $device\
-d\
-e LOG_LEVEL=$log_level\
Expand Down
36 changes: 26 additions & 10 deletions src/Dockerfile_trt
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
FROM nvcr.io/nvidia/tensorrt:21.12-py3
FROM nvcr.io/nvidia/l4t-ml:r32.6.1-py3

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8

RUN apt-get update && apt-get install -y libgl1-mesa-glx protobuf-compiler libprotoc-dev libb64-0d libturbojpeg
ENV PIP_INSTALL="python -m pip --no-cache-dir install --upgrade"
RUN $PIP_INSTALL requests tqdm opencv-python scikit-image fastapi uvicorn ujson numba aiofiles python-multipart httpx cupy-cuda114 icc_rt
RUN $PIP_INSTALL onnx==1.8.0
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata --upgrade
RUN apt-get install -y libgl1-mesa-glx protobuf-compiler libprotoc-dev libb64-0d libturbojpeg python3-pip
ENV PIP_INSTALL="python3 -m pip --no-cache-dir install --upgrade"
RUN $PIP_INSTALL pip
RUN $PIP_INSTALL requests tqdm
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales

RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8

RUN $PIP_INSTALL scikit-image

RUN $PIP_INSTALL fastapi uvicorn ujson aiofiles python-multipart httpx
RUN apt-get install -y cmake git
RUN git clone --recursive https://github.com/onnx/optimizer onnxoptimizer && cd onnxoptimizer && pip3 install -e . && cd ~ && rm -rf onnxoptimizer
RUN $PIP_INSTALL onnx-simplifier
RUN $PIP_INSTALL nvidia-pyindex && pip install tritonclient[http,grpc]
RUN $PIP_INSTALL nvidia-pyindex
RUN $PIP_INSTALL tritonclient[http,grpc]
RUN $PIP_INSTALL git+git://github.com/lilohuang/PyTurboJPEG.git msgpack
RUN $PIP_INSTALL pynvjpeg

COPY Tegra_Multimedia_API_R32.2.1_aarch64.tbz2 /tmp
RUN tar xvjf /tmp/Tegra_Multimedia_API_R32.2.1_aarch64.tbz2 && rm /tmp/Tegra_Multimedia_API_R32.2.1_aarch64.tbz2
RUN mv tegra_multimedia_api /usr/src/jetson_multimedia_api
#RUN $PIP_INSTALL pynvjpeg

WORKDIR /app
COPY api_trt /app
Expand Down
4 changes: 2 additions & 2 deletions src/api_trt/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

echo Preparing models...
python prepare_models.py
python3 prepare_models.py

echo Starting InsightFace-REST using $NUM_WORKERS workers.
uvicorn app:app --port 18080 --host 0.0.0.0 --workers $NUM_WORKERS --timeout-keep-alive 20000
uvicorn app:app --port 18080 --host 0.0.0.0 --workers $NUM_WORKERS --timeout-keep-alive 20000
7 changes: 6 additions & 1 deletion src/api_trt/modules/utils/download_google.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests
import hashlib
from tqdm import tqdm

import re


def check_hash(filename, hash, algo='md5'):
Expand Down Expand Up @@ -48,6 +48,11 @@ def get_confirm_token(response):
if key.startswith('download_warning'):
return value

if 'text/html' in response.headers['Content-Type']:
m = re.search('.*confirm=([^\"]*)', response.text, re.M)
if m and m.groups():
return m.groups()[0]

return None

def save_response_content(response, destination):
Expand Down