Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define CUDA versions for workflows centrally #1052

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
17 changes: 13 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"]'
Expand All @@ -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 \
Expand All @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions docker/cuda.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions scripts/get_docker_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python

import argparse
import re

from_line_re = re.compile(r"FROM\s+(?P<image>\S+)\s+AS\s+(?P<target>\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()