diff --git a/.github/workflows/cuda/Linux-env.sh b/.github/workflows/cuda/Linux-env.sh new file mode 100644 index 0000000..d8aeb19 --- /dev/null +++ b/.github/workflows/cuda/Linux-env.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# From https://github.com/pyg-team/pyg-lib/ + +case ${1} in + cu121) + export CUDA_HOME=/usr/local/cuda-12.1 + export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} + export PATH=${CUDA_HOME}/bin:${PATH} + ;; + cu118) + export CUDA_HOME=/usr/local/cuda-11.8 + export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} + export PATH=${CUDA_HOME}/bin:${PATH} + ;; + cu117) + export CUDA_HOME=/usr/local/cuda-11.7 + export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} + export PATH=${CUDA_HOME}/bin:${PATH} + ;; + cu116) + export CUDA_HOME=/usr/local/cuda-11.6 + export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} + export PATH=${CUDA_HOME}/bin:${PATH} + ;; + cu115) + export CUDA_HOME=/usr/local/cuda-11.5 + export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} + export PATH=${CUDA_HOME}/bin:${PATH} + ;; + cu113) + export CUDA_HOME=/usr/local/cuda-11.3 + export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} + export PATH=${CUDA_HOME}/bin:${PATH} + ;; + cu102) + export CUDA_HOME=/usr/local/cuda-10.2 + export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} + export PATH=${CUDA_HOME}/bin:${PATH} + ;; + *) + ;; +esac \ No newline at end of file diff --git a/.github/workflows/cuda/Linux.sh b/.github/workflows/cuda/Linux.sh new file mode 100644 index 0000000..93f6262 --- /dev/null +++ b/.github/workflows/cuda/Linux.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +# Ubuntu version +UBUNTU_VER=${1} +OS=$(echo ${UBUNTU_VER} | tr -d '-' | tr -d '.') + +# CUDA major and minor version +CUDA_VER_FULL=${2} +CUDA_VER_ARR=($(echo ${CUDA_VER_FULL} | tr "." " ")) +CUDA_VER="${CUDA_VER_ARR[0]}.${CUDA_VER_ARR[1]}" +CUDA_VER_ID="${CUDA_VER_ARR[0]}_${CUDA_VER_ARR[1]}" +CUDA_VER_SHORT="cu${CUDA_VER_ARR[0]}${CUDA_VER_ARR[1]}" + +case ${CUDA_VER_SHORT} in + cu121) + CUDA=12.1 + APT_KEY=${OS}-${CUDA/./-}-local + FILENAME=cuda-repo-${APT_KEY}_${CUDA}.1-530.30.02-1_amd64.deb + URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.1/local_installers + ;; + cu118) + CUDA=11.8 + APT_KEY=${OS}-${CUDA/./-}-local + FILENAME=cuda-repo-${APT_KEY}_${CUDA}.0-520.61.05-1_amd64.deb + URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.0/local_installers + ;; + cu117) + CUDA=11.7 + APT_KEY=${OS}-${CUDA/./-}-local + FILENAME=cuda-repo-${APT_KEY}_${CUDA}.1-515.65.01-1_amd64.deb + URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.1/local_installers + ;; + cu116) + CUDA=11.6 + APT_KEY=${OS}-${CUDA/./-}-local + FILENAME=cuda-repo-${APT_KEY}_${CUDA}.2-510.47.03-1_amd64.deb + URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.2/local_installers + ;; + cu115) + CUDA=11.5 + APT_KEY=${OS}-${CUDA/./-}-local + FILENAME=cuda-repo-${APT_KEY}_${CUDA}.2-495.29.05-1_amd64.deb + URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.2/local_installers + ;; + cu113) + CUDA=11.3 + APT_KEY=${OS}-${CUDA/./-}-local + FILENAME=cuda-repo-${APT_KEY}_${CUDA}.0-465.19.01-1_amd64.deb + URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.0/local_installers + ;; + cu102) + CUDA=10.2 + APT_KEY=${CUDA/./-}-local-${CUDA}.89-440.33.01 + FILENAME=cuda-repo-${OS}-${APT_KEY}_1.0-1_amd64.deb + URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}/Prod/local_installers + ;; + *) + echo "Unrecognized CUDA_VERSION=${CUDA_VER_SHORT}" + exit 1 + ;; +esac + +wget -nv 2>&1 https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-${OS}.pin +sudo mv cuda-${OS}.pin /etc/apt/preferences.d/cuda-repository-pin-600 +wget -nv 2>&1 ${URL}/${FILENAME} +sudo dpkg -i ${FILENAME} + +if [ "${CUDA_VER_SHORT}" = "cu117" ] || [ "${CUDA_VER_SHORT}" = "cu118" ] || [ "${CUDA_VER_SHORT}" = "cu121" ]; then + sudo cp /var/cuda-repo-${APT_KEY}/cuda-*-keyring.gpg /usr/share/keyrings/ +else + sudo apt-key add /var/cuda-repo-${APT_KEY}/7fa2af80.pub +fi + +sudo apt-get -qq update +sudo apt install -y cuda-nvcc-${CUDA/./-} cuda-libraries-dev-${CUDA/./-} cuda-command-line-tools-${CUDA/./-} +sudo apt clean + +rm -f ${FILENAME} \ No newline at end of file diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..03fecce --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,77 @@ +name: Build Test (Ubuntu CUDA) + +on: + push: + branches: + - main + pull_request: + types: [ assigned, opened, synchronize, reopened ] + +jobs: + build: + name: ${{ matrix.os }}-cuda-${{ matrix.cuda-version }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04, ubuntu-20.04] + cuda-version: [11.8.0, 12.1.1] + env: + CCACHE_DIR: ${{ github.workspace }}/ccache + CCACHE_BASEDIR: ${{ github.workspace }} + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Ubuntu + run: | + sudo apt-get update + sudo apt-get install -y \ + build-essential \ + wget + wget -nv https://github.com/ccache/ccache/releases/download/v4.9.1/ccache-4.9.1-linux-x86_64.tar.xz + sudo tar xf ccache-4.9.1-linux-x86_64.tar.xz -C /usr/bin --strip-components=1 --no-same-owner ccache-4.9.1-linux-x86_64/ccache + rm -f ccache-*-linux-x86_64.tar.xz + ccache --version + + - name: Free disk space + if: ${{ matrix.os == 'ubuntu-20.04' }} + run: | + df -h + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/lib/php* /opt/ghc || true + df -h + + - name: Restore CUDA Cache + uses: actions/cache@v4 + id: cuda-cache + with: + key: cuda-${{matrix.cuda-version}}-ubuntu + path: | + /usr/local/cuda* + + - name: Install CUDA + if: ${{ steps.cuda-cache.outputs.cache-hit != 'true' }} + run: | + bash .github/workflows/cuda/${{ runner.os }}.sh ${{ matrix.os }} ${{ matrix.cuda-version }} + + - name: Cache Build + uses: actions/cache@v4 + id: cache-builds + with: + key: ${{ matrix.os }}-cuda-${{ matrix.cuda-version }}-ccache-${{ github.run_id }} + restore-keys: ${{ matrix.os }}-cuda-${{ matrix.cuda-version }}-ccache- + path: ${{ env.CCACHE_DIR }} + + - name: Build + run: | + source .github/workflows/cuda/${{ runner.os }}-env.sh + make clean + make -j$(nproc) + make test + + - name: Clean Compiler Cache + run: | + ccache --show-stats + ccache --evict-older-than 7d + ccache -s \ No newline at end of file