@@ -147,6 +147,24 @@ else
147147 mkdir -p ${EESSI_PREFIX} /software/${EESSI_OS_TYPE} /${EESSI_SOFTWARE_SUBDIR_OVERRIDE}
148148fi
149149
150+ # if we run the script for the first time, e.g., to start building for a new
151+ # stack, we need to ensure certain files are present in
152+ # ${EESSI_PREFIX}/software/${EESSI_OS_TYPE}/${EESSI_SOFTWARE_SUBDIR_OVERRIDE}
153+ # - .lmod/lmodrc.lua
154+ # - .lmod/SitePackage.lua
155+ _eessi_software_path=${EESSI_PREFIX} /software/${EESSI_OS_TYPE} /${EESSI_SOFTWARE_SUBDIR_OVERRIDE}
156+ _lmod_cfg_dir=${_eessi_software_path} /.lmod
157+ _lmod_rc_file=${_lmod_cfg_dir} /lmodrc.lua
158+ if [ ! -f ${_lmod_rc_file} ]; then
159+ command -V python3
160+ python3 ${TOPDIR} /create_lmodrc.py ${_eessi_software_path}
161+ fi
162+ _lmod_sitepackage_file=${_lmod_cfg_dir} /SitePackage.lua
163+ if [ ! -f ${_lmod_sitepackage_file} ]; then
164+ command -V python3
165+ python3 ${TOPDIR} /create_lmodsitepackage.py ${_eessi_software_path}
166+ fi
167+
150168# Set all the EESSI environment variables (respecting $EESSI_SOFTWARE_SUBDIR_OVERRIDE)
151169# $EESSI_SILENT - don't print any messages
152170# $EESSI_BASIC_ENV - give a basic set of environment variables
@@ -203,10 +221,21 @@ ${TOPDIR}/install_scripts.sh --prefix ${EESSI_PREFIX}
203221# Hardcode this for now, see if it works
204222# TODO: We should make a nice yaml and loop over all CUDA versions in that yaml to figure out what to install
205223# Allow skipping CUDA SDK install in e.g. CI environments
224+ # The install_cuda... script uses EasyBuild. So, we need to check if we have EB
225+ # or skip this step.
226+ module_avail_out=$TMPDIR /ml.out
227+ module avail 2>&1 | grep EasyBuild & > ${module_avail_out}
228+ if [[ $? -eq 0 ]]; then
229+ echo_green " >> Found an EasyBuild module"
230+ else
231+ echo_yellow " >> No EasyBuild module found: skipping step to install CUDA (see output in ${module_avail_out} )"
232+ export skip_cuda_install=True
233+ fi
234+
206235if [ -z " ${skip_cuda_install} " ] || [ ! " ${skip_cuda_install} " ]; then
207236 ${EESSI_PREFIX} /scripts/gpu_support/nvidia/install_cuda_host_injections.sh -c 12.1.1 --accept-cuda-eula
208237else
209- echo " Skipping installation of CUDA SDK in host_injections, since the --skip-cuda-install flag was passed"
238+ echo " Skipping installation of CUDA SDK in host_injections, since the --skip-cuda-install flag was passed OR no EasyBuild module was found "
210239fi
211240
212241# Install drivers in host_injections
0 commit comments