diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8a36c3689..542168889 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,9 @@ updates: update-types: [major] minor-patch: update-types: [minor, patch] + - package-ecosystem: docker + directory: "/docker" + schedule: + interval: "weekly" + ignore: + - update-types: [ "version-update:semver-major" ] diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index c85cd063d..8376332ed 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -36,6 +36,8 @@ jobs: - os: windows-latest # This probably requires arm64 Windows agents arch: aarch64 runs-on: ${{ matrix.os }} # One day, we could run them on native agents. Azure supports this now but it's planned only for Q3 2023 for hosted agents + env: + CUDA_VERSION: notset steps: # Check out code - uses: actions/checkout@v4 @@ -81,7 +83,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] arch: [x86_64, aarch64] - cuda_version: ['12.1.0'] + cuda_version: ['12'] exclude: - os: windows-latest # This probably requires arm64 Windows agents arch: aarch64 @@ -90,6 +92,13 @@ jobs: # Check out code - uses: actions/checkout@v4 # Linux: We use Docker to build cross platform Cuda (aarch64 is built in emulation) + - name: Set CUDA version + shell: bash + run: | + cuda_version=$(scripts/get_docker_info.py -v docker/cuda.Dockerfile cuda${{ matrix.cuda_version }}) + echo "CUDA version to use is $cuda_version" + echo "CUDA_VERSION=$cuda_version" >> $GITHUB_ENV + # On Linux we use CMake within Docker - name: Set up Docker multiarch if: startsWith(matrix.os, 'ubuntu') uses: docker/setup-qemu-action@v2 @@ -104,7 +113,7 @@ jobs: if: startsWith(matrix.os, 'windows') id: cuda-toolkit with: - cuda: ${{ matrix.cuda_version }} + cuda: ${{ env.CUDA_VERSION }} method: 'network' sub-packages: '["nvcc","cudart","cusparse","cublas","thrust","nvrtc_dev","cublas_dev","cusparse_dev"]' linux-local-args: '["--toolkit"]' @@ -123,7 +132,7 @@ jobs: [[ "${{ matrix.os }}" = windows-* ]] && python3 -m pip install ninja for NO_CUBLASLT in ON OFF; do if [ ${build_os:0:6} == ubuntu ]; then - image=nvidia/cuda:${{ matrix.cuda_version }}-devel-ubuntu22.04 + image=nvidia/cuda:${{ env.CUDA_VERSION }}-devel-ubuntu22.04 echo "Using image $image" docker run --platform linux/$build_arch -i -w /src -v $PWD:/src $image sh -c \ "apt-get update \ @@ -140,7 +149,7 @@ jobs: - name: Upload build artifact uses: actions/upload-artifact@v4 with: - name: shared_library_cuda_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.cuda_version }} + name: shared_library_cuda_${{ matrix.os }}_${{ matrix.arch }}_${{ env.CUDA_VERSION }} path: output/* retention-days: 7 build-wheels: diff --git a/docker/cuda.Dockerfile b/docker/cuda.Dockerfile new file mode 100644 index 000000000..86f8a8116 --- /dev/null +++ b/docker/cuda.Dockerfile @@ -0,0 +1,7 @@ +# Note: This Dockerfile is currently not used for building an image, but +# for extracting the current version of CUDA to use. +# By using a Dockerfile, it is possible to automatically upgrade CUDA +# patch versions through Dependabot. + +FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 AS cuda11 +FROM nvidia/cuda:12.1.0-devel-ubuntu22.04 AS cuda12 diff --git a/scripts/get_docker_info.py b/scripts/get_docker_info.py new file mode 100755 index 000000000..ce21d2a84 --- /dev/null +++ b/scripts/get_docker_info.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import argparse +import re + +from_line_re = re.compile(r"FROM\s+(?P\S+)\s+AS\s+(?P\S+)") + + +def find_image_in_dockerfile(dockerfile, target): + with open(dockerfile) as f: + for line in f.readlines(): + if (m := from_line_re.match(line)) and m.group("target") == target: + return m.group("image") + raise ValueError(f"Target {target} not defined in {dockerfile}") + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("dockerfile") + ap.add_argument("target") + ap.add_argument("-t", "--tag-only", action="store_true") + ap.add_argument("-v", "--version-only", action="store_true") + args = ap.parse_args() + result = find_image_in_dockerfile(args.dockerfile, args.target) + if args.tag_only or args.version_only: + result = result.rpartition(":")[-1] + if args.version_only: + result = result.split("-")[0] + print(result) + +if __name__ == '__main__': + main()