@@ -11,6 +11,10 @@ inputs:
1111 required : true
1212 cuda-version :
1313 required : true
14+ cuda-channel :
15+ description : " CUDA package channel: stable redistributables or prerelease packages"
16+ required : false
17+ default : " stable"
1418 cuda-components :
1519 description : " A list of the CTK components to install as a comma-separated list. e.g. 'cuda_nvcc,cuda_nvrtc,cuda_cudart'"
1620 required : false
@@ -30,17 +34,34 @@ runs:
3034 # Use the runtime workspace mount so this also works inside container jobs.
3135 CTK_REDIST_TOOL="${GITHUB_WORKSPACE}/ci/tools/fetch_ctk_redistrib.py"
3236 CTK_CACHE_COMPONENTS=${{ inputs.cuda-components }}
33- CTK_JSON_URL="https://developer.download.nvidia.com/compute/cuda/redist/redistrib_${{ inputs.cuda-version }}.json"
34- CTK_CACHE_COMPONENTS="$(python "$CTK_REDIST_TOOL" filter-components \
35- --host-platform "${{ inputs.host-platform }}" \
36- --cuda-version "${{ inputs.cuda-version }}" \
37- --components "$CTK_CACHE_COMPONENTS" \
38- --metadata-url "$CTK_JSON_URL")"
37+ CTK_PREVIEW_PACKAGES=
38+ if [[ "${{ inputs.cuda-channel }}" == "stable" ]]; then
39+ CTK_JSON_URL="https://developer.download.nvidia.com/compute/cuda/redist/redistrib_${{ inputs.cuda-version }}.json"
40+ CTK_CACHE_COMPONENTS="$(python "$CTK_REDIST_TOOL" filter-components \
41+ --host-platform "${{ inputs.host-platform }}" \
42+ --cuda-version "${{ inputs.cuda-version }}" \
43+ --components "$CTK_CACHE_COMPONENTS" \
44+ --metadata-url "$CTK_JSON_URL")"
45+ elif [[ "${{ inputs.cuda-channel }}" == "prerelease" ]]; then
46+ CTK_PREVIEW_PACKAGES="$(python "$CTK_REDIST_TOOL" preview-packages \
47+ --host-platform "${{ inputs.host-platform }}" \
48+ --cuda-version "${{ inputs.cuda-version }}" \
49+ --components "$CTK_CACHE_COMPONENTS")"
50+ CTK_CACHE_COMPONENTS="$CTK_PREVIEW_PACKAGES"
51+ else
52+ echo "Unsupported CUDA package channel: ${{ inputs.cuda-channel }}" >&2
53+ exit 1
54+ fi
3955
4056 HASH=$(echo -n "${CTK_CACHE_COMPONENTS}" | sha256sum | awk '{print $1}')
41- echo "CTK_CACHE_KEY=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH" >> $GITHUB_ENV
57+ CHANNEL_CACHE_SEGMENT=
58+ if [[ "${{ inputs.cuda-channel }}" != "stable" ]]; then
59+ CHANNEL_CACHE_SEGMENT="-${{ inputs.cuda-channel }}"
60+ fi
61+ echo "CTK_CACHE_KEY=mini-ctk${CHANNEL_CACHE_SEGMENT}-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH" >> $GITHUB_ENV
4262 echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH.tar.gz" >> $GITHUB_ENV
4363 echo "CTK_CACHE_COMPONENTS=${CTK_CACHE_COMPONENTS}" >> $GITHUB_ENV
64+ echo "CTK_PREVIEW_PACKAGES=${CTK_PREVIEW_PACKAGES}" >> $GITHUB_ENV
4465
4566 - name : Install dependencies
4667 uses : ./.github/actions/install_unix_deps
@@ -68,48 +89,92 @@ runs:
6889 rm -rf $CACHE_TMP_DIR
6990 mkdir $CACHE_TMP_DIR
7091
71- # The binary archives (redist) are guaranteed to be updated as part of the release posting.
72- # Use the runtime workspace mount so this also works inside container jobs.
73- CTK_REDIST_TOOL="${GITHUB_WORKSPACE}/ci/tools/fetch_ctk_redistrib.py"
74- CTK_BASE_URL="https://developer.download.nvidia.com/compute/cuda/redist/"
75- CTK_JSON_URL="$CTK_BASE_URL/redistrib_${{ inputs.cuda-version }}.json"
76- CTK_JSON_FILE="$CACHE_TMP_DIR/redistrib.json"
77- curl -LSs "$CTK_JSON_URL" -o "$CTK_JSON_FILE"
78- if [[ "${{ inputs.host-platform }}" == linux* ]]; then
79- function extract() {
80- tar -xvf $1 -C $CACHE_TMP_DIR --strip-components=1
81- }
82- elif [[ "${{ inputs.host-platform }}" == "win-64" ]]; then
83- function extract() {
84- _TEMP_DIR_=$(mktemp -d)
85- unzip $1 -d $_TEMP_DIR_
86- cp -r $_TEMP_DIR_/*/* $CACHE_TMP_DIR
87- rm -rf $_TEMP_DIR_
88- # see commit NVIDIA/cuda-python@69410f1d9228e775845ef6c8b4a9c7f37ffc68a5
89- chmod 644 $CACHE_TMP_DIR/LICENSE
92+ if [[ "${{ inputs.cuda-channel }}" == "prerelease" ]]; then
93+ if [[ "${{ inputs.host-platform }}" != linux* ]]; then
94+ echo "CUDA prerelease package extraction currently supports Linux only" >&2
95+ exit 1
96+ fi
97+
98+ source /etc/os-release
99+ DISTRO_CODENAME="${VERSION_CODENAME:-}"
100+ case "$DISTRO_CODENAME" in
101+ bookworm|jammy|noble|resolute|trixie) ;;
102+ *)
103+ echo "Unsupported distribution for CUDA prerelease packages: ${DISTRO_CODENAME:-unknown}" >&2
104+ exit 1
105+ ;;
106+ esac
107+
108+ KEYRING_DEB="$CACHE_TMP_DIR/nvidia-preview-keyring.deb"
109+ curl -fLSs "https://packages.nvidia.com/${DISTRO_CODENAME}/nvidia-preview-keyring.deb" -o "$KEYRING_DEB"
110+ sudo dpkg -i "$KEYRING_DEB"
111+ sudo apt-get update
112+
113+ DEB_DIR="$CACHE_TMP_DIR/debs"
114+ DEB_ROOT="$CACHE_TMP_DIR/deb-root"
115+ mkdir -p "$DEB_DIR/partial" "$DEB_ROOT"
116+ DEB_DIR="$(realpath "$DEB_DIR")"
117+ IFS=, read -ra PREVIEW_PACKAGES <<< "$CTK_PREVIEW_PACKAGES"
118+ sudo apt-get install --yes --download-only --no-install-recommends \
119+ -o "Dir::Cache::archives=$DEB_DIR" \
120+ "${PREVIEW_PACKAGES[@]}"
121+ for package in "$DEB_DIR"/*.deb; do
122+ dpkg-deb -x "$package" "$DEB_ROOT"
123+ done
124+
125+ CUDA_SHORT_VERSION="${{ inputs.cuda-version }}"
126+ CUDA_SHORT_VERSION="${CUDA_SHORT_VERSION%.*}"
127+ CUDA_PACKAGE_ROOT="$DEB_ROOT/usr/local/cuda-${CUDA_SHORT_VERSION}"
128+ if [[ ! -d "$CUDA_PACKAGE_ROOT/include" ]]; then
129+ echo "CUDA prerelease packages did not provide $CUDA_PACKAGE_ROOT/include" >&2
130+ exit 1
131+ fi
132+ cp -a "$CUDA_PACKAGE_ROOT/." "$CACHE_TMP_DIR/"
133+ rm -rf "$DEB_DIR" "$DEB_ROOT" "$KEYRING_DEB"
134+ else
135+ # The binary archives (redist) are guaranteed to be updated as part of the release posting.
136+ # Use the runtime workspace mount so this also works inside container jobs.
137+ CTK_REDIST_TOOL="${GITHUB_WORKSPACE}/ci/tools/fetch_ctk_redistrib.py"
138+ CTK_BASE_URL="https://developer.download.nvidia.com/compute/cuda/redist/"
139+ CTK_JSON_URL="$CTK_BASE_URL/redistrib_${{ inputs.cuda-version }}.json"
140+ CTK_JSON_FILE="$CACHE_TMP_DIR/redistrib.json"
141+ curl -fLSs "$CTK_JSON_URL" -o "$CTK_JSON_FILE"
142+ if [[ "${{ inputs.host-platform }}" == linux* ]]; then
143+ function extract() {
144+ tar -xvf $1 -C $CACHE_TMP_DIR --strip-components=1
145+ }
146+ elif [[ "${{ inputs.host-platform }}" == "win-64" ]]; then
147+ function extract() {
148+ _TEMP_DIR_=$(mktemp -d)
149+ unzip $1 -d $_TEMP_DIR_
150+ cp -r $_TEMP_DIR_/*/* $CACHE_TMP_DIR
151+ rm -rf $_TEMP_DIR_
152+ # see commit NVIDIA/cuda-python@69410f1d9228e775845ef6c8b4a9c7f37ffc68a5
153+ chmod 644 $CACHE_TMP_DIR/LICENSE
154+ }
155+ fi
156+ function populate_cuda_path() {
157+ # take the component name as a argument
158+ function download() {
159+ curl -fLSs $1 -o $2
160+ }
161+ CTK_COMPONENT=$1
162+ CTK_COMPONENT_REL_PATH="$(python "$CTK_REDIST_TOOL" component-relative-path \
163+ --host-platform "${{ inputs.host-platform }}" \
164+ --component "$CTK_COMPONENT" \
165+ --metadata-path "$CTK_JSON_FILE")"
166+ CTK_COMPONENT_URL="${CTK_BASE_URL}/${CTK_COMPONENT_REL_PATH}"
167+ CTK_COMPONENT_COMPONENT_FILENAME="$(basename $CTK_COMPONENT_REL_PATH)"
168+ download $CTK_COMPONENT_URL $CTK_COMPONENT_COMPONENT_FILENAME
169+ extract $CTK_COMPONENT_COMPONENT_FILENAME
170+ rm $CTK_COMPONENT_COMPONENT_FILENAME
90171 }
172+
173+ # Get headers and shared libraries in place
174+ for item in $(echo $CTK_CACHE_COMPONENTS | tr ',' ' '); do
175+ populate_cuda_path "$item"
176+ done
91177 fi
92- function populate_cuda_path() {
93- # take the component name as a argument
94- function download() {
95- curl -LSs $1 -o $2
96- }
97- CTK_COMPONENT=$1
98- CTK_COMPONENT_REL_PATH="$(python "$CTK_REDIST_TOOL" component-relative-path \
99- --host-platform "${{ inputs.host-platform }}" \
100- --component "$CTK_COMPONENT" \
101- --metadata-path "$CTK_JSON_FILE")"
102- CTK_COMPONENT_URL="${CTK_BASE_URL}/${CTK_COMPONENT_REL_PATH}"
103- CTK_COMPONENT_COMPONENT_FILENAME="$(basename $CTK_COMPONENT_REL_PATH)"
104- download $CTK_COMPONENT_URL $CTK_COMPONENT_COMPONENT_FILENAME
105- extract $CTK_COMPONENT_COMPONENT_FILENAME
106- rm $CTK_COMPONENT_COMPONENT_FILENAME
107- }
108-
109- # Get headers and shared libraries in place
110- for item in $(echo $CTK_CACHE_COMPONENTS | tr ',' ' '); do
111- populate_cuda_path "$item"
112- done
113178 # TODO: check Windows
114179 if [[ "${{ inputs.host-platform }}" == linux* && -d "${CACHE_TMP_DIR}/lib" ]]; then
115180 mv $CACHE_TMP_DIR/lib $CACHE_TMP_DIR/lib64
0 commit comments