Skip to content

Commit

Permalink
minor fix to ros-images and added pytorch image for r36.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KalanaRatnayake committed Aug 6, 2024
1 parent 075fb3e commit be6486c
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/r3271-pytorch113.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
file: ./pytorch-images/r3271.113.Dockerfile
push: true
platforms: linux/arm64
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:1-13-buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:1-13-buildcache,mode=max
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:r3271-1-13-buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:r3271-1-13-buildcache,mode=max
tags: |
${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:1.13-r32.7.1
70 changes: 70 additions & 0 deletions .github/workflows/r3630-pytorch204.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Jetson Pytorch 2.4.0 r36.3.0

on:
workflow_dispatch:

push:
branches:
- main
paths:
- ".github/workflows/r3630-pytorch204.yml"
- "pytorch-images/r3630.204.Dockerfile"

pull_request:
branches:
- main
paths:
- ".github/workflows/r3630-pytorch204.yml"
- "pytorch-images/r3630.204.Dockerfile"

env:
REGISTRY: ghcr.io
OWNER: kalanaratnayake
IMAGE_NAME: jetson-pytorch

# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: write
packages: write

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
run: |
docker login --username ${{ env.OWNER }} --password ${{ secrets.GH_PAT }} ghcr.io
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

-
name: Build and Push image
uses: docker/build-push-action@v5
with:
context: .
file: ./pytorch-images/r3630.204.Dockerfile
push: true
platforms: linux/arm64
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:r3630-2-4-buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:r3630-2-4-buildcache,mode=max
tags: |
${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:2.4-r36.3.0
65 changes: 65 additions & 0 deletions pytorch-images/r3630.204.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#---------------------------------------------------------------------------------------------------------------------------
#----
#---- Start base image
#----
#---------------------------------------------------------------------------------------------------------------------------

FROM nvcr.io/nvidia/l4t-base:r36.2.0 AS base

WORKDIR /

######################################################################################
## Install dependencies
######################################################################################

RUN apt-get update -y
RUN apt-get install -y --no-install-recommends python3-pip \
libpython3-dev \
libjpeg-dev \
libopenblas-dev \
libopenmpi-dev \
libomp-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
zlib1g-dev

RUN python3 -m pip install --no-cache-dir future \
wheel \
mock \
pillow \
testresources \
setuptools==58.3.0 \
Cython \
gdown \
protobuf

#####################################################################################
## Install PyTorch 1.13.0
#####################################################################################

RUN python3 -m pip install --no-cache-dir torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121

#####################################################################################
##
## Remove dev packages to reduce size
##
#####################################################################################

RUN apt-get update -y

RUN apt-get autoremove -y

RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
RUN apt-get clean

#---------------------------------------------------------------------------------------------------------------------------
#----
#---- Start final release image
#----
#---------------------------------------------------------------------------------------------------------------------------

FROM scratch as final

COPY --from=base / /
29 changes: 29 additions & 0 deletions pytorch-images/r3630.204.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## jetson-pytorch:2.4-r36.3.0

### Pull or Build

Pull the docker container
```bash
docker pull ghcr.io/kalanaratnayake/jetson-pytorch:2.4-r36.3.0
```

Build the docker container
```bash
docker buildx build --load --platform linux/arm64 -f pytorch-images/r3630.204.Dockerfile -t jetson-pytorch:2.4-r36.3.0 .
```

### Start

Start the docker container

```bash
docker run --rm -it --runtime nvidia --network host --gpus all -e DISPLAY ghcr.io/kalanaratnayake/jetson-pytorch:2.4-r36.3.0 bash
```

### Test

Run the following commands inside the docker container to confirm that the container is working properly.
```bash
python3 -c "import torch; print(torch.__version__)"
python3 -c "import torchvision; print(torchvision.__version__)"
```
2 changes: 1 addition & 1 deletion ros-images/r3630.humble_base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ RUN python3 -m pip install --no-cache-dir numpy \

RUN add-apt-repository universe

RUN sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \
http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
Expand Down
2 changes: 1 addition & 1 deletion ros-images/r3630.humble_core.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ RUN python3 -m pip install --no-cache-dir numpy \

RUN add-apt-repository universe

RUN sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \
http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
Expand Down

0 comments on commit be6486c

Please sign in to comment.