@@ -17,7 +17,7 @@ inputs:
17
17
description : " A list of the CTK components to install as a comma-separated list. e.g. 'cuda_nvcc,cuda_nvrtc,cuda_cudart'"
18
18
required : false
19
19
type : string
20
- default : " cuda_nvcc,cuda_cudart,cuda_nvrtc,cuda_profiler_api,cuda_cccl,cuda_sanitizer_api, libnvjitlink"
20
+ default : " cuda_nvcc,cuda_cudart,cuda_nvrtc,cuda_profiler_api,cuda_cccl,libnvjitlink"
21
21
22
22
runs :
23
23
using : composite
@@ -50,38 +50,40 @@ runs:
50
50
if : ${{ steps.ctk-get-cache.outputs.cache-hit != 'true' }}
51
51
shell : bash --noprofile --norc -xeuo pipefail {0}
52
52
run : |
53
- CUDA_PATH="./cuda_toolkit"
54
- mkdir $CUDA_PATH
53
+ # Everything under this folder is packed and stored in the GitHub Cache space,
54
+ # and unpacked after retrieving from the cache.
55
+ CACHE_TMP_DIR="./cache_tmp_dir"
56
+ rm -rf $CACHE_TMP_DIR
57
+ mkdir $CACHE_TMP_DIR
55
58
56
59
# The binary archives (redist) are guaranteed to be updated as part of the release posting.
57
60
CTK_BASE_URL="https://developer.download.nvidia.com/compute/cuda/redist/"
61
+ CTK_JSON_URL="$CTK_BASE_URL/redistrib_${{ inputs.cuda-version }}.json"
58
62
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
59
63
if [[ "${{ inputs.host-platform }}" == "linux-64" ]]; then
60
64
CTK_SUBDIR="linux-x86_64"
61
65
elif [[ "${{ inputs.host-platform }}" == "linux-aarch64" ]]; then
62
66
CTK_SUBDIR="linux-sbsa"
63
67
fi
64
68
function extract() {
65
- tar -xvf $1 -C $CUDA_PATH --strip-components=1
69
+ tar -xvf $1 -C $CACHE_TMP_DIR --strip-components=1
66
70
}
67
71
elif [[ "${{ inputs.host-platform }}" == "win-64" ]]; then
68
72
CTK_SUBDIR="windows-x86_64"
69
73
function extract() {
70
74
_TEMP_DIR_=$(mktemp -d)
71
75
unzip $1 -d $_TEMP_DIR_
72
- cp -r $_TEMP_DIR_/*/* $CUDA_PATH
76
+ cp -r $_TEMP_DIR_/*/* $CACHE_TMP_DIR
73
77
rm -rf $_TEMP_DIR_
74
78
}
75
79
fi
76
-
77
80
function populate_cuda_path() {
78
81
# take the component name as a argument
79
82
function download() {
80
83
curl -kLSs $1 -o $2
81
84
}
82
- local CTK_COMPONENT=$1
83
- local CTK_VERSION=$2
84
- CTK_COMPONENT_REL_PATH="$(curl -s ${CTK_BASE_URL}/redistrib_${CTK_VERSION}.json |
85
+ CTK_COMPONENT=$1
86
+ CTK_COMPONENT_REL_PATH="$(curl -s $CTK_JSON_URL |
85
87
python -c "import sys, json; print(json.load(sys.stdin)['${CTK_COMPONENT}']['${CTK_SUBDIR}']['relative_path'])")"
86
88
CTK_COMPONENT_URL="${CTK_BASE_URL}/${CTK_COMPONENT_REL_PATH}"
87
89
CTK_COMPONENT_COMPONENT_FILENAME="$(basename $CTK_COMPONENT_REL_PATH)"
@@ -98,23 +100,23 @@ runs:
98
100
CTK_CACHE_COMPONENTS="${CTK_CACHE_COMPONENTS//,,/,}"
99
101
# Get headers and shared libraries in place
100
102
for item in $(echo $CTK_CACHE_COMPONENTS | tr ',' ' '); do
101
- ctk_version="${{ inputs.cuda-version }}"
102
- if [[ "$item" == "cuda_sanitizer_api" ]]; then
103
- # Always use latest CTK for cuda_sanitizer_api
104
- # FIXME: Automatically track latest CTK version
105
- CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ inputs.cuda-version }})"
106
- if [[ "$CUDA_MAJOR" == "12" ]]; then
107
- # TODO: Automatically track latest CTK minor version
108
- ctk_version="12.9.0"
109
- fi
110
- fi
111
- populate_cuda_path "$item" "$ctk_version"
103
+ populate_cuda_path "$item"
112
104
done
113
- ls -l $CUDA_PATH
105
+ ls -l $CACHE_TMP_DIR
114
106
115
107
# Prepare the cache
116
108
# Note: try to escape | and > ...
117
- tar -czvf ${CTK_CACHE_FILENAME} ${CUDA_PATH}
109
+ tar -czvf ${CTK_CACHE_FILENAME} ${CACHE_TMP_DIR}
110
+
111
+ # "Move" files from temp dir to CUDA_PATH
112
+ CUDA_PATH="./cuda_toolkit"
113
+ mkdir -p $CUDA_PATH
114
+ # Unfortunately we cannot use "rsync -av $CACHE_TMP_DIR/ $CUDA_PATH" because
115
+ # not all runners have rsync pre-installed (or even installable, such as
116
+ # Git Bash). We do it in the dumb way.
117
+ cp -r $CACHE_TMP_DIR/* $CUDA_PATH
118
+ rm -rf $CACHE_TMP_DIR
119
+ ls -l $CUDA_PATH
118
120
119
121
- name : Upload CTK cache
120
122
if : ${{ always() &&
@@ -129,8 +131,13 @@ runs:
129
131
shell : bash --noprofile --norc -xeuo pipefail {0}
130
132
run : |
131
133
ls -l
134
+ CACHE_TMP_DIR="./cache_tmp_dir"
132
135
CUDA_PATH="./cuda_toolkit"
136
+ mkdir -p $CUDA_PATH
133
137
tar -xzvf $CTK_CACHE_FILENAME
138
+ # Can't use rsync here, see above
139
+ cp -r $CACHE_TMP_DIR/* $CUDA_PATH
140
+ rm -rf $CACHE_TMP_DIR $CTK_CACHE_FILENAME
134
141
ls -l $CUDA_PATH
135
142
if [ ! -d "$CUDA_PATH/include" ]; then
136
143
exit 1
0 commit comments