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

Conversation

rickardp
Copy link
Contributor

@rickardp rickardp commented Feb 7, 2024

This PR defines CUDA versions to be built in workflows centrally.

It uses a Dockerfile as a source of truth, as this can be updated automatically by Dependabot.

Currently, the Dockerfile is not used for building the compiler images, but we could do this in the future if we want to speed up buiilds (by caching on ghcr.io and e.g stripping static libs that we don't use, as they constitute about 50% of the image size), but the bottleneck is Windows anyway so this is not critical at the moment

Copy link

github-actions bot commented Feb 7, 2024

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@akx akx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shell script heebie-jeebies within 😁

Comment on lines 1 to 31
#!/bin/sh

version_only=
if [ "$1" = "-v" ]; then
version_only=1
shift 1
fi

dockerfile=$1
shift 1

if [ ! -f $dockerfile ]; then
echo "Dockerfile not found" >> /dev/stderr
exit 1
fi

if [ -z "$1" ]; then
echo "No target specified" >> /dev/stderr
exit 1
fi

tag=$(grep "AS $1\$" $dockerfile | sed -e 's/FROM *//' -e 's/ *AS .*//')
if [ -z "$tag" ]; then
echo "Target $1 not defined" >> /dev/stderr
exit 1
fi
if [ "$version_only" = "1" ]; then
echo $tag | sed -e 's/.*://'
else
echo $tag
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😳 Could we write this in Python, pretty please? 😂

Something like

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", required=True)
    ap.add_argument("target", required=True)
    ap.add_argument("-v", "--version-only", action="store_true")
    args = ap.parse_args()
    image = find_image_in_dockerfile(args.dockerfile, args.target)
    if args.version_only:
        image = image.rpartition(":")[-1]
    print(image)

, I think...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objection from me 😃 I just took this script off my library of useful stuff TBH

@rickardp rickardp mentioned this pull request Feb 21, 2024
17 tasks
@Titus-von-Koeller Titus-von-Koeller mentioned this pull request Apr 8, 2024
3 tasks
@Titus-von-Koeller Titus-von-Koeller force-pushed the main branch 2 times, most recently from 9b72679 to 7800734 Compare July 27, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants