Skip to content

Commit

Permalink
Add isaaclab docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Jul 30, 2024
1 parent 36f4632 commit 9a99d80
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Ref: https://docs.docker.com/build/ci/github-actions/
name: Build Docker Images Upon New Git Tag
name: Build Docker Image for omni-farm-isaac

on:
push:
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/build_isaaclab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Ref: https://docs.docker.com/build/ci/github-actions/
name: Build Docker Image for omni-farm-isaaclab

on:
push:
branches:
- master
tags:
- v*
paths:
- .github/workflows/build_isaaclab.yaml
- thirdparty/**
- scripts/docker/run.sh
- Dockerfile.isaaclab
- .dockerignore

jobs:
docker:
if: github.repository == 'j3soon/omni-farm-isaac'
runs-on: ubuntu-latest
steps:
-
name: Maximize build space
uses: easimon/maximize-build-space@master
with:
build-mount-path: /var/lib/docker/
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
-
name: Restart docker
run: sudo service docker restart
-
name: Checkout
uses: actions/checkout@v3
-
# Ref: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token
name: Prepare tag name as environment variable
run: |
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "master" ] && VERSION=latest
# Output the environment variable
# Ref: https://stackoverflow.com/a/57989070
echo "VERSION=$VERSION" >> $GITHUB_ENV
-
name: Docker meta
id: meta
# Ref: https://github.com/docker/metadata-action
uses: docker/metadata-action@v5
with:
# Link: https://hub.docker.com/repository/docker/j3soon/omni-farm-isaaclab/tags
images: ${{ secrets.DOCKERHUB_USERNAME }}/omni-farm-isaaclab
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=${{ env.VERSION }}
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to nvcr.io
uses: docker/login-action@v2
with:
registry: nvcr.io
username: ${{ secrets.NVCRIO_USERNAME }}
password: ${{ secrets.NVCRIO_TOKEN }}
-
name: Pull Isaac Sim Docker Image
run: docker pull nvcr.io/nvidia/isaac-sim:4.1.0
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.isaaclab
push: true
tags: ${{ steps.meta.outputs.tags }}
69 changes: 69 additions & 0 deletions Dockerfile.isaaclab
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# A lightweight Docker image for running Isaac Lab 1.1.0
# Please refer to the official documentation for the officlal docker usages.
FROM nvcr.io/nvidia/isaac-sim:4.1.0

# Install Conda
# Ref: https://github.com/conda-forge/miniforge-images/blob/484f385f409e75a194dbe48633d8662d389ad748/ubuntu/Dockerfile
# > Starting with the 22.11 PyTorch NGC container, miniforge is removed and all Python packages are installed in the default Python environment...
# > See: https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel-24-01.html
ARG MINIFORGE_NAME=Miniforge3
ARG MINIFORGE_VERSION=24.3.0-0
ARG TARGETPLATFORM

ENV CONDA_DIR=/opt/conda
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV PATH=${CONDA_DIR}/bin:${PATH}

# 1. Install just enough for conda to work
# 2. Keep $HOME clean (no .wget-hsts file), since HSTS isn't useful in this context
# 3. Install miniforge from GitHub releases
# 4. Apply some cleanup tips from https://jcrist.github.io/conda-docker-tips.html
# Particularly, we remove pyc and a files. The default install has no js, we can skip that
# 5. Activate base by default when running as any *non-root* user as well
# Good security practice requires running most workloads as non-root
# This makes sure any non-root users created also have base activated
# for their interactive shells.
# 6. Activate base by default when running as root as well
# The root user is already created, so won't pick up changes to /etc/skel
RUN apt-get update > /dev/null && \
apt-get install --no-install-recommends --yes \
wget bzip2 ca-certificates \
git \
tini \
> /dev/null && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
wget --no-hsts --quiet https://github.com/conda-forge/miniforge/releases/download/${MINIFORGE_VERSION}/${MINIFORGE_NAME}-${MINIFORGE_VERSION}-Linux-$(uname -m).sh -O /tmp/miniforge.sh && \
/bin/bash /tmp/miniforge.sh -b -p ${CONDA_DIR} && \
rm /tmp/miniforge.sh && \
conda clean --tarballs --index-cache --packages --yes && \
find ${CONDA_DIR} -follow -type f -name '*.a' -delete && \
find ${CONDA_DIR} -follow -type f -name '*.pyc' -delete && \
conda clean --force-pkgs-dirs --all --yes && \
echo ". ${CONDA_DIR}/etc/profile.d/conda.sh && conda activate base" >> /etc/skel/.bashrc && \
echo ". ${CONDA_DIR}/etc/profile.d/conda.sh && conda activate base" >> ~/.bashrc

ENTRYPOINT ["tini", "--"]
CMD [ "/bin/bash" ]

# Install and Setup Isaac Lab 1.1.0
# Ref: https://isaac-sim.github.io/IsaacLab/source/setup/installation/binaries_installation.html
RUN apt-get update \
&& apt-get install -y \
cmake \
build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/isaac-sim/IsaacLab.git ~/IsaacLab \
&& cd ~/IsaacLab \
&& git checkout v1.1.0
WORKDIR /root/IsaacLab
RUN ln -s /isaac-sim _isaac_sim
RUN ./isaaclab.sh --conda
RUN . /opt/conda/etc/profile.d/conda.sh \
&& conda activate isaaclab \
&& ./isaaclab.sh --install
RUN echo "conda activate isaaclab" >> ~/.bashrc

# Tools and scripts for Omniverse Farm
COPY thirdparty/omnicli /omnicli
COPY scripts/docker/run.sh /run.sh
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Running Isaac Sim Workloads on Omniverse Farm

[<img src="https://img.shields.io/badge/dockerhub-image-important.svg?logo=docker">](https://hub.docker.com/r/j3soon/omni-farm-isaac/tags)
| Docker Image | Docker Hub Link |
|--------------|-----------------|
| `j3soon/omni-farm-isaac` | [<img src="https://img.shields.io/badge/dockerhub-image-important.svg?logo=docker">](https://hub.docker.com/r/j3soon/omni-farm-isaac/tags) |
| `j3soon/omni-farm-isaaclab` | [<img src="https://img.shields.io/badge/dockerhub-image-important.svg?logo=docker">](https://hub.docker.com/r/j3soon/omni-farm-isaaclab/tags) |

## Installing Omniverse Farm

Expand Down Expand Up @@ -265,6 +268,8 @@ For headless tasks, simply follow [the official guide](https://docs.omniverse.nv

If your task requires a GUI during development, see [this guide](https://github.com/j3soon/isaac-extended#docker-container-with-display).

Refer to [scripts/docker](scripts/docker) for potential useful scripts for running Isaac Sim tasks locally.

## Developer Notes

- The job definitions used above contains minimal configuration. You can include more configuration options by referring to the [Job Definition Docs](https://docs.omniverse.nvidia.com/farm/latest/guides/creating_job_definitions.html) and the [Farm Examples](https://docs.omniverse.nvidia.com/farm/latest/farm_examples.html).
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$DIR/../.."
docker build . -t j3soon/omni-farm-isaac
docker build -t j3soon/omni-farm-isaac:local .
5 changes: 5 additions & 0 deletions scripts/docker/build_docker_isaaclab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$DIR/../.."
docker build -f Dockerfile.isaaclab -t j3soon/omni-farm-isaaclab:local .
2 changes: 1 addition & 1 deletion scripts/docker/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ docker run --name isaac-sim --entrypoint bash -it --gpus all -e "ACCEPT_EULA=Y"
-v ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw \
-v ~/docker/isaac-sim/documents:/root/Documents:rw \
-v "$DIR/../..":/workspace:rw \
j3soon/omni-farm-isaac
j3soon/omni-farm-isaac:local
16 changes: 16 additions & 0 deletions scripts/docker/run_docker_isaaclab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_container.html#container-deployment
docker run --name isaac-sim -it --gpus all -e "ACCEPT_EULA=Y" --rm --network=host \
-e "PRIVACY_CONSENT=Y" \
-v ~/docker/isaac-sim/cache/kit:/isaac-sim/kit/cache:rw \
-v ~/docker/isaac-sim/cache/ov:/root/.cache/ov:rw \
-v ~/docker/isaac-sim/cache/pip:/root/.cache/pip:rw \
-v ~/docker/isaac-sim/cache/glcache:/root/.cache/nvidia/GLCache:rw \
-v ~/docker/isaac-sim/cache/computecache:/root/.nv/ComputeCache:rw \
-v ~/docker/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw \
-v ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw \
-v ~/docker/isaac-sim/documents:/root/Documents:rw \
-v "$DIR/../..":/workspace:rw \
j3soon/omni-farm-isaaclab:local

0 comments on commit 9a99d80

Please sign in to comment.