Using containers to work with older CMSSW versions on RHEL9
You can use the wrappers offered by the
cmssw-osenv
project that are already installed in
CVMFS.
/cvmfs/cms.cern.ch/common/cmssw-env
. You can add additional directories that are to be mounted into the container using the
-B /work,/scratch
syntax.
Interactively installing a CMSSW release
Start up a container suitable for the CMSSW release you want to install. Ensure that
/work
is mounted into the container
/cvmfs/cms.cern.ch/common/cmssw-env -B /work --cmsos el7
Now, inside of the containerized environment just proceed to install CMSSW as usual
cd /work/feichtinger/CMSSW
source ${VO_CMS_SW_DIR}/cmsset_default.sh
export SCRAM_ARCH=slc7_amd64_gcc700 # override needed for this particular CMSSW version
cmsrel CMSSW_10_6_37
Running slurm jobs in a containerized environment
An example job based on creating a temporary payload file to be executed within the container
#!/bin/bash
#SBATCH --job-name=cmssw-job
#SBATCH --partition=standard
#SBATCH --ntasks=1
#SBATCH --time=08:00:00
echo "# starting Job at $(date) on node ${HOSTNAME}"
echo "###########################"
echo "# INITIAL ENVIRONMENT START"
echo "###########################"
env
echo "##########################"
echo "# INITIAL ENVIRONMENT END"
echo "##########################"
JOBSCRATCH=/scratch/${USER}/${SLURM_JOBID}
mkdir -p $JOBSCRATCH
payload=$(mktemp ${JOBSCRATCH}/apptainer-payload-XXXXXX.sh)
cat > "$payload" << EOF
# Adapt this based on your install directory
cd /work/feichtinger/CMSSW/CMSSW_10_6_37
source ${VO_CMS_SW_DIR}/cmsset_default.sh
#For this particular CMSSW version we need to override the ARCH
export SCRAM_ARCH=slc7_amd64_gcc700
cmsenv
# IMPLEMENT YOUR FUNCTIONALITY HERE!
EOF
chmod u+x "$payload"
# Launch the payload, make sure that /scratch and /work are available
# in the container
/cvmfs/cms.cern.ch/common/cmssw-env --cmsos el7 -B /scratch,/work \
--command-to-run $payload
rm -rf "$JOBSCRATCH"
echo "# ending Job at $(date) "
References
--
DerekFeichtinger - 2025-05-22