@@ -261,13 +261,6 @@ declare -a BUILD_STEP_ARGS=()
261261BUILD_STEP_ARGS+=(" --save" " ${TARBALL_TMP_BUILD_STEP_DIR} " )
262262BUILD_STEP_ARGS+=(" --storage" " ${STORAGE} " )
263263
264- # add options required to handle NVIDIA support
265- if nvidia_gpu_available; then
266- BUILD_STEP_ARGS+=(" --nvidia" " all" )
267- else
268- BUILD_STEP_ARGS+=(" --nvidia" " install" )
269- fi
270-
271264# Retain location for host injections so we don't reinstall CUDA
272265# (Always need to run the driver installation as available driver may change)
273266if [[ ! -z ${SHARED_FS_PATH} ]]; then
@@ -294,19 +287,39 @@ else
294287 # prepend accel/ to all array elements
295288 EESSI_ACCELERATOR_TARGET_OVERRIDES=(" ${ACCEL_OVERRIDES_ARRAY[@]/#/ accel/ } " )
296289fi
290+ RESUME_DIR=" "
291+
297292for ACCEL_OVERRIDE in " ${EESSI_ACCELERATOR_TARGET_OVERRIDES[@]} " ; do
293+ # copy the common build step arguments to a a
294+ BUILD_STEP_ARGS_ACCEL=(" ${BUILD_STEP_ARGS[@]} " )
295+ if [[ " ${ACCEL_OVERRIDE} " == " accel/nvidia/" * ]]; then
296+ nvidia_cc=${ACCEL_OVERRIDE##*/ cc}
297+ # add options required to handle NVIDIA support
298+ # only make the GPU available in the container if the host has a GPU and it has the correct compute capability
299+ if nvidia_gpu_available && nvidia_gpu_has_compute_capability " ${nvidia_cc} " ; then
300+ echo " bot/build.sh: GPU with the requested compute capability is available, using '--nvidia all'"
301+ BUILD_STEP_ARGS_ACCEL+=(" --nvidia" " all" )
302+ else
303+ echo " bot/build.sh: no GPU with the requested compute capability is available, using '--nvidia install'"
304+ BUILD_STEP_ARGS_ACCEL+=(" --nvidia" " install" )
305+ fi
306+ fi
307+ # resume from the previous accelerator's build directory
308+ # as we want to combine all accelerator builds into a single tarball in the end
309+ if [[ ! -z " ${RESUME_DIR} " ]]; then
310+ BUILD_STEP_ARGS_ACCEL+=(" --resume" " ${RESUME_DIR} " )
311+ fi
312+
298313 export EESSI_ACCELERATOR_TARGET_OVERRIDE=" ${ACCEL_OVERRIDE} "
299314 echo " bot/build.sh: EESSI_ACCELERATOR_TARGET_OVERRIDE='${ACCEL_OVERRIDE} '"
300315 echo " Executing command to build software:"
301- echo " $software_layer_dir /eessi_container.sh ${COMMON_ARGS[@]} ${BUILD_STEP_ARGS [@]} "
316+ echo " $software_layer_dir /eessi_container.sh ${COMMON_ARGS[@]} ${BUILD_STEP_ARGS_ACCEL [@]} "
302317 echo " -- $software_layer_dir /install_software_layer.sh \" ${INSTALL_SCRIPT_ARGS[@]} \" \" $@ \" 2>&1 | tee -a ${build_outerr} "
303- $software_layer_dir /eessi_container.sh " ${COMMON_ARGS[@]} " " ${BUILD_STEP_ARGS [@]} " \
318+ $software_layer_dir /eessi_container.sh " ${COMMON_ARGS[@]} " " ${BUILD_STEP_ARGS_ACCEL [@]} " \
304319 -- $software_layer_dir /install_software_layer.sh " ${INSTALL_SCRIPT_ARGS[@]} " " $@ " 2>&1 | tee -a ${build_outerr}
305320
306321 # determine temporary directory to resume from for the next accelerator,
307- # as we want to combine all accelerator builds into a single tarball in the end
308- BUILD_TMPDIR=$( grep ' as tmp directory ' ${build_outerr} | cut -d ' ' -f 2)
309- BUILD_STEP_ARGS+=(" --resume" " ${BUILD_TMPDIR} " )
322+ RESUME_DIR=$( grep ' as tmp directory ' ${build_outerr} | cut -d ' ' -f 2)
310323done
311324
312325# prepare directory to store tarball of tmp for tarball step
0 commit comments