Skip to content

Commit 9901466

Browse files
committed
Sample Docker Push Action
1 parent 6920876 commit 9901466

File tree

3 files changed

+115
-26
lines changed

3 files changed

+115
-26
lines changed

.github/workflows/docker_builder.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# name: 'Torch-TRT Docker'
2+
3+
# on:
4+
# pull_request:
5+
# types: [opened, synchronize, ready_for_review, review_requested, reopened]
6+
7+
# ##### Adapted from https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
8+
9+
# # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
10+
# env:
11+
# REGISTRY: ghcr.io
12+
# IMAGE_NAME: ${{ github.repository }}
13+
14+
# # There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
15+
# jobs:
16+
# build-and-push-image:
17+
# runs-on: ubuntu-latest
18+
# # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
19+
# permissions:
20+
# contents: read
21+
# packages: write
22+
# steps:
23+
# - name: Checkout repository
24+
# uses: actions/checkout@v3
25+
# # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
26+
# - name: Log in to the Container registry
27+
# uses: docker/login-action@v2
28+
# with:
29+
# registry: ${{ env.REGISTRY }}
30+
# username: ${{ github.actor }}
31+
# password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
# - name: Reclaim space
34+
# run: |
35+
# rm -rf /usr/share/dotnet
36+
# rm -rf /opt/ghc
37+
# rm -rf "/usr/local/share/boost"
38+
# rm -rf /usr/local/cuda/cuda-*
39+
40+
# - name: ssh
41+
# uses: appleboy/ssh-action@master
42+
# with:
43+
# host: ${{ secrets.HOST }}
44+
# username: ${{ secrets.USERNAME }}
45+
# password: ${{ secrets.PASSWORD }}
46+
# port: ${{ secrets.PORT }}
47+
48+
# # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
49+
# # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
50+
# # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
51+
# - name: Build and push Docker image
52+
# uses: docker/build-push-action@v4
53+
# with:
54+
# context: .
55+
# push: true
56+
# tags: torch_tensorrt:main
57+
# file: docker/Dockerfile
58+
# build-args: |
59+
# TENSORRT_VERSION=8.6
60+
# CUDNN_VERSION=8.8
61+
# shm-size: 4g
62+
63+
64+
name: 'Torch-TRT Docker'
65+
66+
on:
67+
pull_request:
68+
types: [opened, synchronize, ready_for_review, review_requested, reopened]
69+
70+
jobs:
71+
72+
build:
73+
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout repository
77+
uses: actions/checkout@v3
78+
79+
- name: Build the Docker image
80+
run: DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=8.6 --build-arg CUDNN_VERSION=8.8 -f docker/Dockerfile --tag torch_tensorrt_main:$(date +%s) .

docker/Dockerfile

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,38 +77,46 @@ RUN cp ./docker/WORKSPACE.docker WORKSPACE
7777
RUN mkdir -p "/opt/python3/" &&\
7878
ln -s "`pyenv which python | xargs dirname | xargs dirname`/lib/python$PYTHON_VERSION/site-packages" "/opt/python3/"
7979

80-
# Extract base image cuda version (everything after :, before -, before final ., in BASE_IMG)
81-
# Ensure the default cuda folder agrees with the version in the base image
82-
RUN CUDA_BASE_IMG_VERSION_INTERMEDIATE=`echo ${BASE_IMG#*:}` &&\
83-
CUDA_BASE_IMG_VERSION=`echo ${CUDA_BASE_IMG_VERSION_INTERMEDIATE%%-*}` &&\
84-
CUDA_MAJOR_MINOR_VERSION=`echo ${CUDA_BASE_IMG_VERSION%.*}` &&\
85-
rm -fr /usr/local/cuda &&\
86-
ln -s /usr/local/cuda-${CUDA_MAJOR_MINOR_VERSION} /usr/local/cuda
80+
RUN rm -rf /usr/share/dotnet
81+
RUN rm -rf /opt/ghc
82+
RUN rm -rf "/usr/local/share/boost"
83+
RUN rm -rf /usr/local/cuda/cuda-*
84+
RUN apt-get clean
8785

88-
ENV CUDA_HOME=/usr/local/cuda
86+
RUN pip install tensorrt
8987

90-
# This script builds both libtorchtrt bin/lib/include tarball and the Python wheel, in dist/
91-
RUN bash ./docker/dist-build.sh
88+
# # Extract base image cuda version (everything after :, before -, before final ., in BASE_IMG)
89+
# # Ensure the default cuda folder agrees with the version in the base image
90+
# RUN CUDA_BASE_IMG_VERSION_INTERMEDIATE=`echo ${BASE_IMG#*:}` &&\
91+
# CUDA_BASE_IMG_VERSION=`echo ${CUDA_BASE_IMG_VERSION_INTERMEDIATE%%-*}` &&\
92+
# CUDA_MAJOR_MINOR_VERSION=`echo ${CUDA_BASE_IMG_VERSION%.*}` &&\
93+
# rm -fr /usr/local/cuda &&\
94+
# ln -s /usr/local/cuda-${CUDA_MAJOR_MINOR_VERSION} /usr/local/cuda
9295

93-
# Copy and install Torch-TRT into the main container
94-
FROM base as torch-tensorrt
96+
# ENV CUDA_HOME=/usr/local/cuda
9597

96-
COPY . /opt/torch_tensorrt
98+
# # This script builds both libtorchtrt bin/lib/include tarball and the Python wheel, in dist/
99+
# RUN bash ./docker/dist-build.sh
97100

98-
# Symlink the path pyenv is using for python with the /opt directory for package sourcing
99-
RUN mkdir -p "/opt/python3/" &&\
100-
ln -s "`pyenv which python | xargs dirname | xargs dirname`/lib/python$PYTHON_VERSION/site-packages" "/opt/python3/"
101+
# # Copy and install Torch-TRT into the main container
102+
# FROM base as torch-tensorrt
103+
104+
# COPY . /opt/torch_tensorrt
105+
106+
# # Symlink the path pyenv is using for python with the /opt directory for package sourcing
107+
# RUN mkdir -p "/opt/python3/" &&\
108+
# ln -s "`pyenv which python | xargs dirname | xargs dirname`/lib/python$PYTHON_VERSION/site-packages" "/opt/python3/"
101109

102-
COPY --from=torch-tensorrt-builder /workspace/torch_tensorrt/src/py/dist/ .
110+
# COPY --from=torch-tensorrt-builder /workspace/torch_tensorrt/src/py/dist/ .
103111

104-
RUN cp /opt/torch_tensorrt/docker/WORKSPACE.docker /opt/torch_tensorrt/WORKSPACE
105-
RUN pip install -r /opt/torch_tensorrt/py/requirements.txt
106-
RUN pip install tensorrt==${TENSORRT_VERSION}.*
107-
RUN pip install *.whl && rm -fr /workspace/torch_tensorrt/py/dist/* *.whl
112+
# RUN cp /opt/torch_tensorrt/docker/WORKSPACE.docker /opt/torch_tensorrt/WORKSPACE
113+
# RUN pip install -r /opt/torch_tensorrt/py/requirements.txt
114+
# RUN pip install tensorrt==${TENSORRT_VERSION}.*
115+
# RUN pip install *.whl && rm -fr /workspace/torch_tensorrt/py/dist/* *.whl
108116

109-
WORKDIR /opt/torch_tensorrt
117+
# WORKDIR /opt/torch_tensorrt
110118

111-
ENV LD_LIBRARY_PATH /opt/python3/site-packages/torch/lib:/opt/python3/site-packages/torch_tensorrt/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}
112-
ENV PATH /opt/python3/site-packages/torch_tensorrt/bin:${PATH}
119+
# ENV LD_LIBRARY_PATH /opt/python3/site-packages/torch/lib:/opt/python3/site-packages/torch_tensorrt/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}
120+
# ENV PATH /opt/python3/site-packages/torch_tensorrt/bin:${PATH}
113121

114122
CMD /bin/bash

docker/dist-build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ fi
1010

1111
cd ${TOP_DIR} \
1212
&& mkdir -p dist && cd py \
13-
&& pip install -r requirements.txt \
14-
&& pip install wheel
13+
&& pip install wheel \
14+
&& apt-get clean \
15+
&& pip install -r requirements.txt
1516

1617
# Build Torch-TRT
1718
MAX_JOBS=1 LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 ${BUILD_CMD} $* || exit 1

0 commit comments

Comments
 (0)