From 4b4a074e633d6ae07b6a626bc1705502e195a7fb Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Wed, 15 Nov 2023 22:58:05 +0000 Subject: [PATCH] build Orin torchserve. --- .github/workflows/docker-extras.yml | 34 +++++++++++++++++++++++++++ .github/workflows/docker-test.yml | 20 ++++++++++++++++ .github/workflows/docker.yml | 1 - docker/Dockerfile.orin-torchserve | 9 +++++++ tests/test_torchserve.sh | 3 ++- torchserve/install-orin-torchserve.sh | 23 ++++++++++++++++++ 6 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 docker/Dockerfile.orin-torchserve create mode 100755 torchserve/install-orin-torchserve.sh diff --git a/.github/workflows/docker-extras.yml b/.github/workflows/docker-extras.yml index 3a5fee81..30cff735 100644 --- a/.github/workflows/docker-extras.yml +++ b/.github/workflows/docker-extras.yml @@ -40,6 +40,40 @@ jobs: push: true tags: iqtlabs/gamutrf-torchserve:${{ steps.change_version.outputs.VERSION }} if: github.repository == 'iqtlabs/gamutrf' && github.event_name == 'push' + buildx-orin-torchserve: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + - name: Change for main + id: change_version + run: if [ "${{ steps.get_version.outputs.VERSION }}" == "main" ]; then echo ::set-output name=VERSION::latest; else echo ::set-output name=VERSION::${{ steps.get_version.outputs.VERSION }}; fi + - name: Set up qemu + uses: docker/setup-qemu-action@v3 + with: + platforms: all + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + - name: Docker Login + env: + DOCKER_PASSWORD: ${{ secrets.DOCKER_TOKEN }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin + if: github.repository == 'iqtlabs/gamutrf' && github.event_name == 'push' + - name: Build and push platforms + uses: docker/build-push-action@v5 + with: + context: . + file: docker/Dockerfile.orin-torchserve + platforms: linux/arm64 + push: true + tags: iqtlabs/gamutrf-orin-torchserve:${{ steps.change_version.outputs.VERSION }} + if: github.repository == 'iqtlabs/gamutrf' && github.event_name == 'push' buildx-cuda-torchserve: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 9a01443a..15b2c905 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -1,6 +1,26 @@ name: docker-test on: [push, pull_request] jobs: + test-orin-torchserve: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up qemu + uses: docker/setup-qemu-action@v3 + with: + platforms: all + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + - name: Build + uses: docker/build-push-action@v5 + with: + context: . + file: docker/Dockerfile.orin-torchserve + platforms: linux/arm64 + push: false test-gamutrf-torchserve-image: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8354b4f2..62d8feff 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -75,7 +75,6 @@ jobs: run: | echo "${DOCKER_PASSWORD}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin if: github.repository == 'iqtlabs/gamutrf' && github.event_name == 'push' - - name: Build and push platforms uses: docker/build-push-action@v5 with: diff --git a/docker/Dockerfile.orin-torchserve b/docker/Dockerfile.orin-torchserve new file mode 100644 index 00000000..06b71db0 --- /dev/null +++ b/docker/Dockerfile.orin-torchserve @@ -0,0 +1,9 @@ +FROM nvcr.io/nvidia/l4t-pytorch:r35.2.1-pth2.0-py3 +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /root +COPY torchserve/install-orin-torchserve.sh /torchserve/install-orin-torchserve.sh +RUN /torchserve/install-orin-torchserve.sh +RUN /usr/local/bin/torchserve --help +COPY torchserve/config.properties /torchserve/config.properties +COPY torchserve/torchserve-entrypoint.sh /torchserve/torchserve-entrypoint.sh +CMD ["/torchserve/torchserve-entrypoint.sh"] diff --git a/tests/test_torchserve.sh b/tests/test_torchserve.sh index f9d26817..269dacca 100755 --- a/tests/test_torchserve.sh +++ b/tests/test_torchserve.sh @@ -12,7 +12,8 @@ wget https://raw.githubusercontent.com/pytorch/serve/master/examples/object_dete torch-model-archiver --force --model-name yolov8n --version 1.0 --serialized-file yolov8n.pt --handler custom_handler.py -r requirements.txt rm -rf model_store && mkdir model_store mv yolov8n.mar model_store/ -docker run -v $(pwd)/model_store:/model_store --net host --entrypoint timeout -d iqtlabs/gamutrf-torchserve 180s /torchserve/torchserve-entrypoint.sh --models yolov8n=yolov8n.mar +# TODO: --runtime nvidia is required for Orin +docker run -v $(pwd)/model_store:/model_store -p 8080:8080 --rm --name testts --entrypoint timeout -d iqtlabs/gamutrf-torchserve 180s /torchserve/torchserve-entrypoint.sh --models yolov8n=yolov8n.mar # TODO: use gamutRF test spectogram image wget https://github.com/pytorch/serve/raw/master/examples/object_detector/yolo/yolov8/persons.jpg wget -q --retry-connrefused --retry-on-host-error --body-file=persons.jpg --method=PUT -O- --header='Content-Type: image/jpg' http://127.0.0.1:8080/predictions/yolov8n | jq diff --git a/torchserve/install-orin-torchserve.sh b/torchserve/install-orin-torchserve.sh new file mode 100755 index 00000000..d481d73a --- /dev/null +++ b/torchserve/install-orin-torchserve.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e +apt-get update && \ + apt-get install -y \ + git \ + python3-pip \ + openjdk-17-jdk \ + wget \ + numactl + apt-get purge -y opencv-python && \ + pip install "opencv-python<4.8.0.76" && \ + echo /usr/local/lib/python3.8/dist-packages/opencv_python.libs > /etc/ld.so.conf.d/opencv.conf && \ + ldconfig && \ + pip config set global.no-cache-dir false && \ + git clone https://github.com/pytorch/serve -b v0.9.0 && \ + cd serve && \ + pip install -r requirements/common.txt && \ + pip install -r requirements/common_gpu.txt && \ + pip install -r requirements/torch_common.txt && \ + pip install . && \ + cd .. && \ + rm -rf serve