Skip to content

Updated C wrapper wrt. Torch v1.10 #10

Updated C wrapper wrt. Torch v1.10

Updated C wrapper wrt. Torch v1.10 #10

Workflow file for this run

name: Build C Wrapper
on:
push:
branches:
- master
tags: ['*']
pull_request:
workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
build_cpu:
name: Build (CPU, 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
gcc_version:
- "8"
julia_version:
- "1.9"
os_version:
- "10"
torch_version:
- "1.10.2"
container:
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: |
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: 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 -
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 '.')"
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 -
export CMAKE_PREFIX_PATH=/usr/local/libtorch
cd deps/c_wrapper
cmake -S . -B build -DUSE_CUDA=$USE_CUDA
cmake --build build