@@ -16,6 +16,7 @@ BASE_IMAGE="${OPENSHELL_SANDBOX_BASE_IMAGE:-ghcr.io/nvidia/openshell-community/s
1616CUDA_BUILD_IMAGE=" ${CUDA_BUILD_IMAGE:- nvcr.io/ nvidia/ cuda: 12.8.1-base-ubuntu22.04} "
1717CUDA_SAMPLES_REPO=" ${CUDA_SAMPLES_REPO:- https:// github.com/ NVIDIA/ cuda-samples} "
1818CUDA_SAMPLES_REF=" ${CUDA_SAMPLES_REF:- v12.8} "
19+ SUPPORTED_IMAGES=(smoke-pass smoke-fail cuda-basic)
1920
2021shell_quote () {
2122 local value=$1
@@ -39,22 +40,13 @@ yaml_quote() {
3940}
4041
4142available_image_dirs () {
42- local dockerfile
4343 local preferred
44- local seen=" "
4544
46- for preferred in smoke-pass smoke-fail cuda-basic ; do
45+ for preferred in " ${SUPPORTED_IMAGES[@]} " ; do
4746 if [[ -f " ${IMAGES_ROOT} /${preferred} /Dockerfile" ]]; then
4847 echo " ${preferred} "
49- seen+=" ${preferred} "
5048 fi
5149 done
52-
53- find " ${IMAGES_ROOT} " -mindepth 2 -maxdepth 2 -name Dockerfile -type f | sort | while IFS= read -r dockerfile; do
54- name=" $( basename " $( dirname " ${dockerfile} " ) " ) "
55- [[ " ${seen} " == * " ${name} " * ]] && continue
56- echo " ${name} "
57- done
5850}
5951
6052contains_image () {
@@ -90,6 +82,19 @@ image_expectation() {
9082 esac
9183}
9284
85+ workload_input_fingerprint () {
86+ local -a names=(" $@ " )
87+
88+ {
89+ printf ' OPENSHELL_SANDBOX_BASE_IMAGE=%s\n' " ${BASE_IMAGE} "
90+ if contains_image cuda-basic " ${names[@]} " ; then
91+ printf ' CUDA_BUILD_IMAGE=%s\n' " ${CUDA_BUILD_IMAGE} "
92+ printf ' CUDA_SAMPLES_REPO=%s\n' " ${CUDA_SAMPLES_REPO} "
93+ printf ' CUDA_SAMPLES_REF=%s\n' " ${CUDA_SAMPLES_REF} "
94+ fi
95+ } | git -C " ${ROOT} " hash-object --stdin | cut -c1-8
96+ }
97+
9398mapfile -t available < <( available_image_dirs)
9499if [[ ${# available[@]} -eq 0 ]]; then
95100 echo " No GPU workload image Dockerfiles found under ${IMAGES_ROOT} " >&2
128133if [[ -n " ${OPENSHELL_GPU_WORKLOAD_IMAGE_TAG:- } " ]]; then
129134 image_tag=" ${OPENSHELL_GPU_WORKLOAD_IMAGE_TAG} "
130135else
131- image_tag=" ${source_short_sha} "
136+ input_fingerprint=" $( workload_input_fingerprint " ${selected[@]} " ) "
137+ image_tag=" ${source_short_sha} -${input_fingerprint} "
132138 if [[ " ${source_dirty} " == " true" ]]; then
133139 image_tag=" ${image_tag} -dirty"
134140 fi
135141fi
142+ input_fingerprint=" $( workload_input_fingerprint " ${selected[@]} " ) "
136143
137144declare -A image_refs=()
138145
@@ -148,12 +155,23 @@ for name in "${selected[@]}"; do
148155 build_args=(
149156 --build-arg " OPENSHELL_SANDBOX_BASE_IMAGE=${BASE_IMAGE} "
150157 )
158+ build_labels=(
159+ --label " com.nvidia.openshell.gpu-workload.source=${name} "
160+ --label " com.nvidia.openshell.gpu-workload.base-image=${BASE_IMAGE} "
161+ --label " com.nvidia.openshell.gpu-workload.input-fingerprint=${input_fingerprint} "
162+ --label " org.opencontainers.image.revision=${source_sha} "
163+ )
151164 if [[ " ${name} " == " cuda-basic" ]]; then
152165 build_args+=(
153166 --build-arg " CUDA_BUILD_IMAGE=${CUDA_BUILD_IMAGE} "
154167 --build-arg " CUDA_SAMPLES_REPO=${CUDA_SAMPLES_REPO} "
155168 --build-arg " CUDA_SAMPLES_REF=${CUDA_SAMPLES_REF} "
156169 )
170+ build_labels+=(
171+ --label " com.nvidia.openshell.gpu-workload.cuda-build-image=${CUDA_BUILD_IMAGE} "
172+ --label " com.nvidia.openshell.gpu-workload.cuda-samples-repo=${CUDA_SAMPLES_REPO} "
173+ --label " com.nvidia.openshell.gpu-workload.cuda-samples-ref=${CUDA_SAMPLES_REF} "
174+ )
157175 fi
158176
159177 echo
@@ -162,8 +180,7 @@ for name in "${selected[@]}"; do
162180 --load \
163181 --provenance=false \
164182 -t " ${image_ref} " \
165- --label " com.nvidia.openshell.gpu-workload.source=${name} " \
166- --label " org.opencontainers.image.revision=${source_sha} " \
183+ " ${build_labels[@]} " \
167184 " ${build_args[@]} " \
168185 " ${context} "
169186
@@ -180,6 +197,11 @@ manifest_path="${BUILD_DIR}/workloads.yaml"
180197 write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_SOURCE_PATH " ${IMAGES_ROOT} "
181198 write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_SOURCE_SHA " ${source_sha} "
182199 write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_SOURCE_DIRTY " ${source_dirty} "
200+ write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_INPUT_FINGERPRINT " ${input_fingerprint} "
201+ write_env_var OPENSHELL_SANDBOX_BASE_IMAGE " ${BASE_IMAGE} "
202+ write_env_var CUDA_BUILD_IMAGE " ${CUDA_BUILD_IMAGE} "
203+ write_env_var CUDA_SAMPLES_REPO " ${CUDA_SAMPLES_REPO} "
204+ write_env_var CUDA_SAMPLES_REF " ${CUDA_SAMPLES_REF} "
183205 write_env_var OPENSHELL_GPU_WORKLOAD_CONTAINER_ENGINE " ${CONTAINER_ENGINE} "
184206 write_env_var OPENSHELL_E2E_WORKLOAD_MANIFEST " ${manifest_path} "
185207 for name in " ${selected[@]} " ; do
@@ -194,11 +216,17 @@ manifest_path="${BUILD_DIR}/workloads.yaml"
194216 echo " path: $( yaml_quote " ${IMAGES_ROOT} " ) "
195217 echo " revision: $( yaml_quote " ${source_sha} " ) "
196218 echo " dirty: ${source_dirty} "
219+ echo " input_fingerprint: $( yaml_quote " ${input_fingerprint} " ) "
197220 echo " container_engine: $( yaml_quote " ${CONTAINER_ENGINE} " ) "
221+ echo " inputs:"
222+ echo " openshell_sandbox_base_image: $( yaml_quote " ${BASE_IMAGE} " ) "
223+ echo " cuda_build_image: $( yaml_quote " ${CUDA_BUILD_IMAGE} " ) "
224+ echo " cuda_samples_repo: $( yaml_quote " ${CUDA_SAMPLES_REPO} " ) "
225+ echo " cuda_samples_ref: $( yaml_quote " ${CUDA_SAMPLES_REF} " ) "
198226 echo " workloads:"
199227 for name in " ${selected[@]} " ; do
200228 echo " - name: $( yaml_quote " ${name} " ) "
201- echo " image: $( yaml_quote " ${image_refs[${name}]} " ) "
229+ echo " image: $( yaml_quote " ${image_refs[${name}]} " ) "
202230 echo " command:"
203231 echo " - $( yaml_quote " /usr/local/bin/openshell-gpu-workload" ) "
204232 echo " expect: $( yaml_quote " $( image_expectation " ${name} " ) " ) "
0 commit comments