1
- name : Common setup
1
+ name : Fetch mini CTK
2
+
3
+ description : Fetch (or create) a mini CUDA Toolkit from cache
2
4
3
5
inputs :
4
- client-repo :
5
- required : true
6
- type : string
7
- build-type :
8
- required : true
9
- type : string
10
- target-device :
11
- required : true
12
- type : string
13
6
host-platform :
14
7
required : true
15
8
type : string
16
- build-mode :
17
- required : true
18
- type : string
19
- upload-enabled :
20
- required : true
21
- type : boolean
22
- python-version :
23
- required : true
24
- type : string
25
9
cuda-version :
26
10
required : true
27
11
type : string
28
12
29
13
runs :
30
14
using : composite
31
15
steps :
32
- # WAR: setup-python is not relocatable...
33
- # see https://github.com/actions/setup-python/issues/871
34
- - name : Set up Python ${{ inputs.python-version }}
35
- if : ${{ startsWith(inputs.host-platform, 'linux') }}
36
- id : setup-python
37
- uses : actions/setup-python@v5
38
- with :
39
- python-version : " 3.12"
40
-
41
- - name : Set up MSVC
42
- if : ${{ startsWith(inputs.host-platform, 'win') }}
43
- uses : ilammy/msvc-dev-cmd@v1
44
-
45
- - name : Dump environment
46
- shell : bash --noprofile --norc -xeuo pipefail {0}
47
- run : |
48
- env
49
-
50
16
- name : Set up CTK cache variable
51
17
shell : bash --noprofile --norc -xeuo pipefail {0}
52
18
run : |
53
19
echo "CTK_CACHE_KEY=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}" >> $GITHUB_ENV
54
20
echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}.tar.gz" >> $GITHUB_ENV
55
21
22
+ - name : Install dependencies
23
+ shell : bash --noprofile --norc -xeuo pipefail {0}
24
+ run : |
25
+ dependencies=(zstd curl xz-utils)
26
+ dependent_exes=(zstd curl xz)
27
+
28
+ not_found=0
29
+ for dep in ${dependent_exes[@]}; do
30
+ if ! (command -v curl 2>&1 >/dev/null); then
31
+ not_found=1
32
+ break
33
+ fi
34
+ done
35
+ if [[ $not_found == 0 ]]; then
36
+ echo "All dependencies are found. Do nothing."
37
+ exit 0
38
+ fi
39
+ if ! (command -v sudo 2>&1 >/dev/null); then
40
+ if [[ $EUID == 0 ]]; then
41
+ alias SUDO=""
42
+ else
43
+ echo "The following oprations require root access."
44
+ exit 1
45
+ fi
46
+ else
47
+ alias SUDO="sudo"
48
+ fi
49
+ shopt -s expand_aliases
50
+ SUDO apt update
51
+ SUDO apt install -y ${dependencies[@]}
52
+
56
53
- name : Download CTK cache
57
54
id : ctk-get-cache
58
55
uses : actions/cache/restore@v4
59
56
continue-on-error : true
60
57
with :
61
58
key : ${{ env.CTK_CACHE_KEY }}
62
59
path : ./${{ env.CTK_CACHE_FILENAME }}
60
+ fail-on-cache-miss : false
63
61
64
62
- name : Get CUDA components
65
63
if : ${{ steps.ctk-get-cache.outputs.cache-hit != 'true' }}
@@ -72,15 +70,15 @@ runs:
72
70
CTK_BASE_URL="https://developer.download.nvidia.com/compute/cuda/redist/"
73
71
CTK_JSON_URL="$CTK_BASE_URL/redistrib_${{ inputs.cuda-version }}.json"
74
72
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
75
- if [[ "${{ inputs.host-platform }}" == "linux-x64 " ]]; then
73
+ if [[ "${{ inputs.host-platform }}" == "linux-64 " ]]; then
76
74
CTK_SUBDIR="linux-x86_64"
77
75
elif [[ "${{ inputs.host-platform }}" == "linux-aarch64" ]]; then
78
76
CTK_SUBDIR="linux-sbsa"
79
77
fi
80
78
function extract() {
81
79
tar -xvf $1 -C $CUDA_PATH --strip-components=1
82
80
}
83
- elif [[ "${{ inputs.host-platform }}" == "win-x64 " ]]; then
81
+ elif [[ "${{ inputs.host-platform }}" == "win-64 " ]]; then
84
82
CTK_SUBDIR="windows-x86_64"
85
83
function extract() {
86
84
_TEMP_DIR_=$(mktemp -d)
@@ -112,16 +110,16 @@ runs:
112
110
populate_cuda_path cuda_cudart
113
111
populate_cuda_path cuda_nvrtc
114
112
populate_cuda_path cuda_profiler_api
115
- populate_cuda_path libnvjitlink
113
+ populate_cuda_path cuda_cccl
114
+ if [[ "$(cut -d '.' -f 1 <<< ${{ inputs.cuda-version }})" -ge 12 ]]; then
115
+ populate_cuda_path libnvjitlink
116
+ fi
116
117
ls -l $CUDA_PATH
117
118
118
119
# Prepare the cache
119
120
# Note: try to escape | and > ...
120
121
tar -czvf ${CTK_CACHE_FILENAME} ${CUDA_PATH}
121
122
122
- # Note: the headers will be copied into the cibuildwheel manylinux container,
123
- # so setting the CUDA_PATH env var here is meaningless.
124
-
125
123
- name : Upload CTK cache
126
124
if : ${{ always() &&
127
125
steps.ctk-get-cache.outputs.cache-hit != 'true' }}
@@ -142,44 +140,10 @@ runs:
142
140
exit 1
143
141
fi
144
142
145
- - name : Set environment variables
143
+ - name : Set output environment variables
146
144
shell : bash --noprofile --norc -xeuo pipefail {0}
147
145
run : |
148
- # TODO: just align host-platform names with TARGET_PLATFORM...
149
- if [[ "${{ inputs.host-platform }}" == "linux-x64" ]]; then
150
- TARGET_PLATFORM='linux-64'
151
- elif [[ "${{ inputs.host-platform }}" == "linux-aarch64" ]]; then
152
- TARGET_PLATFORM='linux-aarch64'
153
- elif [[ "${{ inputs.host-platform }}" == "win-x64" ]]; then
154
- TARGET_PLATFORM='win-64'
155
- fi
156
-
157
- PYTHON_VERSION_FORMATTED=$(echo '${{ inputs.python-version }}' | tr -d '.')
158
- if [[ "${{ inputs.host-platform }}" == linux* ]]; then
159
- CIBW_BUILD="cp${PYTHON_VERSION_FORMATTED}-manylinux*"
160
- REPO_DIR=$(pwd)
161
- elif [[ "${{ inputs.host-platform }}" == win* ]]; then
162
- CIBW_BUILD="cp${PYTHON_VERSION_FORMATTED}-win_amd64"
163
- PWD=$(pwd)
164
- REPO_DIR=$(cygpath -w $PWD)
165
- fi
166
-
167
- BUILD_MODE="${{ inputs.build-mode }}"
168
- if [[ ("${BUILD_MODE}" == "") || ("${BUILD_MODE}" == "release") ]]; then
169
- # We upload release versions in the default folder.
170
- PKG_DIR="${TARGET_PLATFORM}"
171
- else
172
- PKG_DIR="${BUILD_MODE}/${TARGET_PLATFORM}"
173
- fi
174
-
175
- echo "PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
176
- echo "REPO_DIR=$REPO_DIR" >> $GITHUB_ENV
177
- echo "PKG_DIR=${PKG_DIR}" >> $GITHUB_ENV
178
- echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ inputs.host-platform }}-${{ inputs.build-type }}-${{ github.sha }}" >> $GITHUB_ENV
179
- echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
180
- echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.cuda-version }}-${{ inputs.host-platform }}-${{ inputs.build-type }}-${{ github.sha }}" >> $GITHUB_ENV
181
- echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
182
- echo "UPLOAD_ENABLED=${{ (inputs.upload-enabled == 'true' && 'ON') || 'OFF' }}" >> $GITHUB_ENV
183
- echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
184
- echo "TARGET_PLATFORM=${TARGET_PLATFORM}" >> $GITHUB_ENV
185
- echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV
146
+ CUDA_PATH=$(realpath "./cuda_toolkit")
147
+ echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV
148
+ echo "${CUDA_PATH}/bin" >> $GITHUB_PATH
149
+ echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${CUDA_PATH}/lib" >> $GITHUB_ENV
0 commit comments