Skip to content

Commit

Permalink
feat: build gpu code dependent on OptiX, run opticks tests (#49)
Browse files Browse the repository at this point in the history
Resolves #50
  • Loading branch information
plexoos committed May 7, 2024
1 parent e45db58 commit c3ce14d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ jobs:
echo IMAGE_NAME=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo TAG=$(echo "PR-${{ github.event.pull_request.number }}") >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true

- name: Copy external assets
run: cp /home/runner/NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64.sh .

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

- name: Pull latest image as cache
run: docker pull ${{ env.IMAGE_NAME }}:latest

- name: Build image locally
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ env.IMAGE_NAME }}:${{ env.TAG }}
outputs: type=docker,dest=/tmp/esi-shell-${{ env.TAG }}.tar
cache-from: ${{ env.IMAGE_NAME }}:latest
Expand All @@ -39,7 +45,7 @@ jobs:
path: /tmp/esi-shell-${{ env.TAG }}.tar

test:
runs-on: ubuntu-latest
runs-on: [gpu]
needs: build
steps:
- name: Define environment variables
Expand All @@ -56,4 +62,5 @@ jobs:
- name: Run tests
run: |
docker load --input /tmp/esi-shell-${{ env.TAG }}.tar
docker run --rm ${{ env.IMAGE_NAME }}:${{ env.TAG }} bash -l -c opticks-info
rm -fr /tmp/esi-shell-${{ env.TAG }}.tar
docker run --rm ${{ env.IMAGE_NAME }}:${{ env.TAG }} bash -l -c 'HOME=$ESI_DIR opticks-full-prepare && HOME=$ESI_DIR opticks-t'
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
with:
fetch-depth: 0 # Important for Semantic Release to analyze all commits

- name: Copy external assets
run: cp /home/runner/NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64.sh .

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

Expand All @@ -31,14 +34,15 @@ jobs:
- name: Build image locally
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ env.IMAGE_NAME }}:latest
pull: true
load: true
cache-from: ${{ env.IMAGE_NAME }}:latest
cache-to: type=inline

- name: Run tests
run: docker run --rm ${{ env.IMAGE_NAME }}:latest curl --version
run: docker run --rm ${{ env.IMAGE_NAME }}:latest bash -l -c 'HOME=$ESI_DIR opticks-full-prepare && HOME=$ESI_DIR opticks-t'

- name: Declare latest and push
run: docker push ${{ env.IMAGE_NAME }}:latest
Expand Down
31 changes: 13 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,28 @@ RUN echo "module use --append /opt/modules" >> /etc/profile.d/z10_load_spack_mod
RUN spack module tcl loads geant4 clhep boost cmake nlohmann-json >> /etc/profile.d/z10_load_spack_modules.sh
RUN rm -fr /opt/spack/share/spack/modules/$(spack arch)

# create a placeholder dir for NVIDIA OptiX
RUN mkdir -p /usr/local/optix

ENV ESI_DIR=/esi-shell
ENV OPTICKS_HOME=$ESI_DIR/opticks
ENV ESI_DIR=/esi
ENV OPTIX_DIR=/usr/local/optix
ENV OPTICKS_HOME=${ESI_DIR}/opticks
ENV OPTICKS_PREFIX=/usr/local/opticks
ENV OPTICKS_CUDA_PREFIX=/usr/local/cuda
ENV OPTICKS_OPTIX_PREFIX=/usr/local/optix
ENV OPTICKS_OPTIX_PREFIX=${OPTIX_DIR}
ENV OPTICKS_COMPUTE_CAPABILITY=52
ENV PYTHONPATH=${OPTICKS_HOME}
ENV LD_LIBRARY_PATH=${OPTICKS_PREFIX}/lib/:$LD_LIBRARY_PATH

COPY epic $ESI_DIR/epic
COPY opticks $ESI_DIR/opticks
COPY .opticks $ESI_DIR/.opticks
WORKDIR $ESI_DIR

WORKDIR $OPTICKS_HOME
COPY epic epic
COPY opticks opticks
COPY .opticks .opticks
COPY NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64.sh .

RUN mkdir -p $ESI_DIR
COPY <<-"EOF" /etc/profile.d/z20_opticks.sh
source $OPTICKS_HOME/opticks.bash
opticks-
EOF

RUN opticks-full-externals
RUN <<EOF
source om.bash
om-(){ echo "skip sourcing om.bash"; }
om-subs--all(){ deps=(okconf sysrap ana analytic bin CSG qudarap gdxml u4); printf '%s\n' "${deps[@]}"; }
opticks-full-make
EOF
RUN mkdir -p $OPTIX_DIR && ./NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64.sh --skip-license --prefix=$OPTIX_DIR
RUN HOME=$ESI_DIR opticks-full
RUN rm -fr $OPTIX_DIR/* $ESI_DIR/NVIDIA-OptiX-SDK-7.6.0-linux64-x86_64.sh

0 comments on commit c3ce14d

Please sign in to comment.