Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
YilingQiao committed Dec 19, 2024
1 parent 8fb9155 commit da5db77
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Start with a base image that includes CUDA
FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04

# Label the image
LABEL description="Python 3.11 with PyTorch, CUDA support, and a user named ci with sudo access"

# Install necessary packages for Python 3.11 and sudo
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common sudo && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y python3.11 python3.11-venv python3.11-dev python3-pip && \
rm -rf /var/lib/apt/lists/*

# Create a non-root user 'ci' with a password and give sudo privileges
RUN useradd -ms /bin/bash ci && \
echo 'ci:password' | chpasswd && \
echo 'ci ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/ci

# Switch to user 'ci'
USER ci
WORKDIR /home/ci

# Set up the virtual environment in user's home directory
RUN python3.11 -m venv venv
ENV PATH="/home/ci/venv/bin:$PATH"

# Install PyTorch with CUDA support
RUN pip install --no-cache-dir torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test-linux-gpu:
runs-on: self-hosted
strategy:
fail-fast: false
# matrix:
# python-version: ["3.9"]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Run Tests
run: |
docker run -u ci:ci --gpus all --rm -v ${{ github.workspace }}:/app cuda11_py11:latest \
bash -c "cd /app && \
sudo bash ./.github/workflows/setup_env.sh && \
pip install -e . && \
python -m unittest discover tests"
- name: Display Speed Test
run: cat speed_test.txt


- name: Upload Test Results as Artifact
uses: actions/upload-artifact@v3
with:
name: speed-test-results
path: speed_test.txt
2 changes: 2 additions & 0 deletions .github/workflows/setup_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apt-get update
apt-get install -y libx11-6 libgl1-mesa-glx libxrender1 libglu1-mesa libglib2.0-0 libegl1-mesa-dev libgles2-mesa-dev libosmesa6-dev

0 comments on commit da5db77

Please sign in to comment.