Skip to content

Commit 00150b8

Browse files
authored
ci: Bump runner (#801)
* ci: Bump runner Signed-off-by: oliver könig <[email protected]> * check for ngc wheels Signed-off-by: oliver könig <[email protected]> * fix Signed-off-by: oliver könig <[email protected]> * fixes Signed-off-by: oliver könig <[email protected]> * fix Signed-off-by: oliver könig <[email protected]> --------- Signed-off-by: oliver könig <[email protected]>
1 parent 269bd98 commit 00150b8

File tree

2 files changed

+84
-8
lines changed

2 files changed

+84
-8
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# Configuration
4+
BASE_IMAGE="nvcr.io/nvidia/pytorch"
5+
TAG_SUFFIX="-py3"
6+
MONTHS_TO_CHECK=7 # Check current month and previous 6 months (total 7)
7+
8+
# Initialize an array to store existing tags
9+
EXISTING_TAGS=()
10+
11+
echo "Checking for existence of the last ${MONTHS_TO_CHECK} NGC PyTorch images: ${BASE_IMAGE}:YY.MM${TAG_SUFFIX}"
12+
echo "---------------------------------------------------------------------"
13+
14+
# Loop through the last N months
15+
for i in $(seq 0 $((MONTHS_TO_CHECK - 1))); do
16+
# Calculate Year and Month for the tag
17+
CURRENT_YEAR=$(date +%Y)
18+
CURRENT_MONTH=$(date +%m)
19+
20+
# Calculate target month and year
21+
TARGET_DATE=$(date -d "$CURRENT_YEAR-$CURRENT_MONTH-01 -$i months" +%y.%m)
22+
23+
# Construct the full image tag and the tag-only string
24+
IMAGE_TAG="${TARGET_DATE}${TAG_SUFFIX}"
25+
FULL_IMAGE="${BASE_IMAGE}:${IMAGE_TAG}"
26+
27+
echo "Checking: ${FULL_IMAGE}"
28+
29+
# Use 'docker manifest inspect' to check for image existence without pulling.
30+
if docker manifest inspect "${FULL_IMAGE}" > /dev/null 2>&1; then
31+
echo "✅ EXISTS: Found."
32+
# Add the tag-only string to the array
33+
EXISTING_TAGS+=("nvcr.io/nvidia/pytorch:${IMAGE_TAG}")
34+
else
35+
echo "❌ MISSING: Not found."
36+
fi
37+
done
38+
39+
echo "---------------------------------------------------------------------"
40+
41+
## JSON Output Generation
42+
# This uses the collected array to build a JSON string.
43+
44+
# 1. Convert the shell array to a newline-separated string.
45+
TAGS_NL_SEP=$(printf "%s\n" "${EXISTING_TAGS[@]}")
46+
47+
# 2. Use jq to read the newline-separated list and format it into a JSON array.
48+
# . | split("\n") | .[:-1] reads the input, splits it by newline, and removes the trailing empty element.
49+
if command -v jq &> /dev/null; then
50+
JSON_STRING=$(echo -e "${TAGS_NL_SEP}" | jq -R -s 'split("\n") | .[:-1]')
51+
52+
echo "Generated JSON String of Existing Tags:"
53+
echo "${JSON_STRING}"
54+
55+
# Optional: Save the JSON string to a variable for further use
56+
# echo "JSON_STRING is now available in the shell if you source this script."
57+
else
58+
echo "WARNING: 'jq' is not installed. Cannot format output as JSON."
59+
echo "Found Tags: ${EXISTING_TAGS[*]}"
60+
fi
61+
62+
echo "---"
63+
echo "Check complete."
64+
65+
echo "${JSON_STRING}" > ngc_images.json

.github/workflows/publish.yaml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
matrix:
4343
# Using ubuntu-20.04 instead of 22.04 for more compatibility (glibc). Ideally we'd use the
4444
# manylinux docker image, but I haven't figured out how to install CUDA on manylinux.
45-
os: [ubuntu-20.04]
45+
os: [ubuntu-22.04]
4646
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
4747
torch-version: ["2.1.2", "2.2.2", "2.3.1", "2.4.0", "2.5.1", "2.6.0.dev20241001"]
4848
cuda-version: ["11.8.0", "12.3.2"]
@@ -76,20 +76,31 @@ jobs:
7676
release-version: ${{ needs.setup_release.outputs.release-version }}
7777
upload-to-release: true
7878

79+
check_for_ngc_images:
80+
runs-on: ubuntu-latest
81+
outputs:
82+
images: ${{ steps.check_for_ngc_images.outputs.IMAGES }}
83+
steps:
84+
- name: Checkout repository
85+
uses: actions/checkout@v4
86+
87+
- name: Check for NGC PyTorch images
88+
id: check_for_ngc_images
89+
run: |
90+
bash ./.github/scripts/check_for_ngc_images.sh
91+
echo "IMAGES=$(cat ngc_images.json| jq -cr)" | tee -a $GITHUB_OUTPUT
92+
7993
build_ngc_wheels:
8094
name: Build Wheel for NGC PyTorch
81-
needs: setup_release
95+
needs: [setup_release, check_for_ngc_images]
8296
strategy:
8397
fail-fast: false
8498
matrix:
85-
os: [ubuntu-20.04]
86-
container-image:
87-
- nvcr.io/nvidia/pytorch:25.05-py3
88-
- nvcr.io/nvidia/pytorch:25.06-py3
89-
- nvcr.io/nvidia/pytorch:25.08-py3
99+
os: [ubuntu-22.04]
100+
container-image: ${{ fromJson(needs.check_for_ngc_images.outputs.images) }}
90101
uses: ./.github/workflows/_build_in_container.yml
91102
with:
92-
runs-on: ${{ matrix.runs-on }}
103+
runs-on: ${{ matrix.os }}
93104
container-image: ${{ matrix.container-image }}
94105
release-version: ${{ needs.setup_release.outputs.release-version }}
95106
upload-to-release: true

0 commit comments

Comments
 (0)