diff --git a/.github/workflows/Dockerfile b/.github/workflows/Dockerfile new file mode 100644 index 00000000..7924b9c0 --- /dev/null +++ b/.github/workflows/Dockerfile @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..2ec7d230 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/setup_env.sh b/.github/workflows/setup_env.sh new file mode 100644 index 00000000..56a65c09 --- /dev/null +++ b/.github/workflows/setup_env.sh @@ -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