Skip to content

Commit

Permalink
WIP CUDA-part Added GitHub Actions workflow for building C Wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
stemann committed Apr 27, 2024
1 parent 56610be commit c97bf22
Showing 1 changed file with 105 additions and 3 deletions.
108 changes: 105 additions & 3 deletions .github/workflows/BuildCWrapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
build:
build_cpu:
name: Build (CPU, GCC ${{ matrix.gcc_version }}, Torch ${{ matrix.torch_version }})
runs-on: ubuntu-latest
timeout-minutes: 60
Expand All @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
arch:
- "x64"
- x64
gcc_version:
- "8"
julia_version:
Expand All @@ -39,7 +39,9 @@ jobs:
image: debian:${{ matrix.os_version }}
env:
GCC_VERSION: ${{ matrix.gcc_version }}
TORCH_VARIANT: cpu
TORCH_VERSION: ${{ matrix.torch_version }}
USE_CUDA: "OFF"
steps:
- name: Install dependencies
run: |
Expand All @@ -60,7 +62,107 @@ jobs:
- name: build
run: |
cd /usr/local
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-$TORCH_VERSION%2Bcpu.zip
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-$TORCH_VERSION%2B$TORCH_VARIANT.zip
unzip -q libtorch-*.zip
rm libtorch-*.zip
cd -
export CMAKE_PREFIX_PATH=/usr/local/libtorch
cd deps/c_wrapper
cmake -S . -B build -DUSE_CUDA=$USE_CUDA
cmake --build build
build_cuda:
name: Build (CUDA ${{ matrix.cuda_version }}, CUDNN ${{ matrix.cudnn_version }}, GCC ${{ matrix.gcc_version }}, Torch ${{ matrix.torch_version }})
runs-on: ubuntu-latest
timeout-minutes: 60
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
actions: write
contents: read
strategy:
fail-fast: false
matrix:
arch:
- x64
cuda_version:
- "11.3.1"
cudnn_version:
- "8.2.4"
gcc_version:
- "8"
julia_version:
- "1.9"
os_version:
- "10"
torch_version:
- "1.10.2"
container:
image: debian:${{ matrix.os_version }}
env:
CUDA_VERSION: ${{ matrix.cuda_version }}
CUDNN_VERSION: ${{ matrix.cudnn_version }}
GCC_VERSION: ${{ matrix.gcc_version }}
TORCH_VERSION: ${{ matrix.torch_version }}
USE_CUDA: "ON"
steps:
- name: Install dependencies
run: |
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
jq \
unzip \
wget
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia_version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- name: Install CUDA SDK ${{ matrix.cuda_version }} and CUDNN ${{ matrix.cudnn_version }}
run: |
CUDA_VERSION_MAJOR_MINOR=$$(echo $$CUDA_VERSION | cut -d . -f 1-2)
TMP_PROJECT=$$(mktemp -d)
cd $$TMP_PROJECT
touch Project.toml
cat <<EOT > LocalPreferences.toml
[CUDA_Runtime_jll]
version = "$$CUDA_VERSION_MAJOR_MINOR"
EOT
CUDA_ROOT=$$(julia --project --eval '
using Pkg
CUDA_VERSION = VersionNumber(ENV["CUDA_VERSION"])
CUDA_SDK_jll_pkg = :CUDA_SDK_jll
if CUDA_VERSION < v"11.4"
CUDA_SDK_jll_pkg = :CUDA_full_jll
end
Pkg.add(name=string(CUDA_SDK_jll_pkg), version=ENV["CUDA_VERSION"])
@eval using $$CUDA_SDK_jll_pkg
println(@eval $$CUDA_SDK_jll_pkg.artifact_dir)
')
ln -s $$CUDA_ROOT/cuda /usr/local/cuda
export PATH=$$PATH:/usr/local/cuda/bin
export CUDNN_ROOT=$$(julia --project --eval '
using Pkg;
CUDA_VERSION = VersionNumber(ENV["CUDA_VERSION"])
if CUDA_VERSION < v"11"
Pkg.add(name="CUDA_Runtime_jll", version="0.2")
elseif CUDA_VERSION < v"11.4"
Pkg.add(name="CUDA_Runtime_jll", version="0.7")
else
Pkg.add(name="CUDA_Runtime_jll")
end
Pkg.add(name="CUDNN_jll", version=ENV["CUDNN_VERSION"]);
using CUDNN_jll;
println(CUDNN_jll.artifact_dir)')
for F in $$CUDNN_ROOT/include/cudnn*.h; do ln -sf $$F /usr/local/cuda/include/$$(basename $$F); done
for F in $$CUDNN_ROOT/lib/libcudnn*; do ln -sf $$F /usr/local/cuda/lib64/$$(basename $$F); done
cd -
export TORCH_VARIANT="cu$(echo $$CUDA_VERSION | cut -d . -f 1-2 | tr -d '.')"
- name: build
run: |
cd /usr/local
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-$TORCH_VERSION%2B$TORCH_VARIANT.zip
unzip -q libtorch-*.zip
rm libtorch-*.zip
cd -
Expand Down

0 comments on commit c97bf22

Please sign in to comment.