Skip to content
Snippets Groups Projects
Commit 6ccaf3a5 authored by Eric Müller's avatar Eric Müller :mountain_bicyclist:
Browse files

feat(f27): Add new container type and apps

Depends-On: 21379
Change-Id: Ia1e7993e854917fa9b2941b9068d46cf67f11ad7
parent df8fb33f
No related branches found
No related tags found
No related merge requests found
...@@ -52,7 +52,7 @@ parser = argparse.ArgumentParser( ...@@ -52,7 +52,7 @@ parser = argparse.ArgumentParser(
# mandatory # mandatory
parser.add_argument( parser.add_argument(
"style", type=str, choices=["visionary", "asic"], "style", type=str, choices=["visionary", "asic", "f27"],
help="Style of container to build.") help="Style of container to build.")
parser.add_argument( parser.add_argument(
"spack_dir", type=pathlib.Path, "spack_dir", type=pathlib.Path,
......
...@@ -16,6 +16,7 @@ DATE=$(date --iso) ...@@ -16,6 +16,7 @@ DATE=$(date --iso)
declare -A CONTAINER_PREFIX_LUT declare -A CONTAINER_PREFIX_LUT
CONTAINER_PREFIX_LUT[visionary]="" CONTAINER_PREFIX_LUT[visionary]=""
CONTAINER_PREFIX_LUT[asic]="asic" CONTAINER_PREFIX_LUT[asic]="asic"
CONTAINER_PREFIX_LUT[f27]="f27"
CONTAINER_PREFIX=${CONTAINER_PREFIX_LUT[$CONTAINER_STYLE]} CONTAINER_PREFIX=${CONTAINER_PREFIX_LUT[$CONTAINER_STYLE]}
......
docker_base_image: "debian:bullseye"
dependency_python: "3.8.2"
spack_gcc:
# Whether to build the specified gcc via spack or assume existance.
build: true
# Version to use as compiler for spack build.
version: "11.2.0"
#!/bin/bash
ROOT_DIR="$(dirname "$(dirname "$(dirname "$(dirname "$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")")")")")"
source "${ROOT_DIR}/lib/yashchiki/commons.sh"
# create container description file
# * based on Debian buster (minimal) + a few extra packages (e.g. git, python, ...)
# * bind mount spack's fetch-cache and ccache into the container -> speed up stuff
# * bind mount spack's buildcache into the container -> speed up stuff
# * copy spack installation script into container
# * create "spack" user in the container and run spack installation script as spack user
# (-> installs to /opt/spack, and creates views)
# * provide "apps" which set environment variables to appropriate views
cat <<EOF >"${YASHCHIKI_RECIPE_PATH}"
Bootstrap: docker
From: ${DOCKER_BASE_IMAGE}
%setup
# bind-mount spack-folder as moving involves copying the complete download cache
mkdir \${SINGULARITY_ROOTFS}/opt/spack
mount --no-mtab --bind "${YASHCHIKI_SPACK_PATH}" "\${SINGULARITY_ROOTFS}/opt/spack"
# bind-mount ccache
mkdir \${SINGULARITY_ROOTFS}/opt/ccache
mount --no-mtab --bind "${YASHCHIKI_CACHES_ROOT}/spack_ccache" "\${SINGULARITY_ROOTFS}/opt/ccache"
# bind-mount build_cache
mkdir -p "\${SINGULARITY_ROOTFS}${BUILD_CACHE_INSIDE}"
# create buildcache directory if it does not exist
[ ! -d "${BUILD_CACHE_OUTSIDE}" ] && mkdir -p "${BUILD_CACHE_OUTSIDE}"
# mount the full build cache folder into container because some files might be symlinked to other buildcaches
mount --no-mtab --bind "${BASE_BUILD_CACHE_OUTSIDE}" "\${SINGULARITY_ROOTFS}${BASE_BUILD_CACHE_INSIDE}"
# bind-mount preserved packages in case the build fails
mkdir -p "\${SINGULARITY_ROOTFS}${PRESERVED_PACKAGES_INSIDE}"
mount --no-mtab --bind "${PRESERVED_PACKAGES_OUTSIDE}" "\${SINGULARITY_ROOTFS}${PRESERVED_PACKAGES_INSIDE}"
# bind-mount tmp-folder
mkdir -p "\${SINGULARITY_ROOTFS}/tmp/spack"
mount --no-mtab --bind "${JOB_TMP_SPACK}" "\${SINGULARITY_ROOTFS}/tmp/spack"
# bind-mount spack config tmp-folder
mkdir -p "\${SINGULARITY_ROOTFS}/tmp/spack_config"
mount --no-mtab --bind "${YASHCHIKI_SPACK_CONFIG}" "\${SINGULARITY_ROOTFS}/tmp/spack_config"
# copy install scripts
mkdir "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}"
rsync -av --chmod 0755 "${ROOT_DIR}"/share/yashchiki/styles/${CONTAINER_STYLE}/*.sh "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}"
rsync -av --chmod 0755 "${ROOT_DIR}"/lib/yashchiki/*.sh "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}"
rsync -av "${ROOT_DIR}"/lib/yashchiki/*.awk "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}"
rsync -av "${ROOT_DIR}"/share/yashchiki/patches "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}"
mkdir -p "\${SINGULARITY_ROOTFS}/${META_DIR_INSIDE}"
rsync -av "${META_DIR_OUTSIDE}/" "\${SINGULARITY_ROOTFS}/${META_DIR_INSIDE}"
# init scripts for user convenience
mkdir -p "\${SINGULARITY_ROOTFS}/opt/init"
rsync -av "${ROOT_DIR}"/share/yashchiki/misc-files/init/*.sh "\${SINGULARITY_ROOTFS}/opt/init"
%files
# NOTE: Due to a bug in singularity 2.6 all paths in this section _cannot_
# be surrounded in quotes.. ergo there should be no spaces in filenames! If
# there are, I pray for your poor soul that escaping them works..
# --obreitwi, 17-02-19 # 23:45:51
# provide spack command to login shells
${ROOT_DIR}/share/yashchiki/misc-files/setup-spack.sh /etc/profile.d/setup-spack.sh
${ROOT_DIR}/share/yashchiki/misc-files/locale.gen /etc/locale.gen
${ROOT_DIR}/share/yashchiki/misc-files/locale.alias /etc/locale.alias
${ROOT_DIR}/share/yashchiki/misc-files/sudoers /etc/sudoers
# ECM (2024-04-30) need nvidia stuff for py-cupy
/usr/lib/nvidia
/usr/lib/x86_64-linux-gnu/nvidia
/usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1
/etc/alternatives/nvidia--libnvidia-ml.so.1-x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libnvidia-ptxjitcompiler.so.1
/etc/alternatives/nvidia--libnvidia-ptxjitcompiler.so.1-x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libcuda.so
/etc/alternatives/nvidia--libcuda.so-x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libcuda.so.1
/etc/alternatives/nvidia--libcuda.so.1-x86_64-linux-gnu
%post
ls /usr/lib/x86_64-linux-gnu/libcuda*
# create a fingerprint by which we can identify the container from within
cat /proc/sys/kernel/random/uuid > /opt/fingerprint
# prerequisites
"${SPACK_INSTALL_SCRIPTS}/install_prerequisites.sh" || exit 1
# cannot specify permissions in files-section
chmod 440 /etc/sudoers
chown root:root /etc/sudoers
# install locales
locale-gen
# propagate environment variables to container recipe
export DEPENDENCY_PYTHON="${DEPENDENCY_PYTHON}"
export YASHCHIKI_BUILD_SPACK_GCC="${YASHCHIKI_BUILD_SPACK_GCC}"
export YASHCHIKI_SPACK_GCC="${YASHCHIKI_SPACK_GCC}"
export YASHCHIKI_SPACK_GCC_VERSION="${YASHCHIKI_SPACK_GCC_VERSION}"
export YASHCHIKI_JOBS="${YASHCHIKI_JOBS}"
export YASHCHIKI_SPACK_CONFIG="/tmp/spack_config"
export YASHCHIKI_CACHES_ROOT="${YASHCHIKI_CACHES_ROOT}"
export YASHCHIKI_BUILD_CACHE_NAME="${YASHCHIKI_BUILD_CACHE_NAME}"
export YASHCHIKI_BUILD_CACHE_ON_FAILURE_NAME="${YASHCHIKI_BUILD_CACHE_ON_FAILURE_NAME}"
export YASHCHIKI_SPACK_VERBOSE="${YASHCHIKI_SPACK_VERBOSE}"
export CONTAINER_STYLE="${CONTAINER_STYLE}"
# Improve efficiency by installing system packages in the background (even
# though we set the number of worker to \${YASHCHIKI_JOBS}, often times - e.g. when
# concretizing - only one process will be active.)
# NOTE: For this to work all spack-related dependencies need to be
# specified under "Inlucde:" above. install_system_dependencies.sh should
# only install packages that are needed once the container finished
# building!
# We kill the main process in case of errors in order to have no silent
# fails!
PID_MAIN="\$\$"
( "${SPACK_INSTALL_SCRIPTS}/install_system_dependencies.sh" \
|| kill \${PID_MAIN} ) &
"${SPACK_INSTALL_SCRIPTS}/complete_spack_install_routine_called_in_post_as_root.sh"
# system dependencies might not have installed by now
# currently, singularity needs some dependendencies from apt as well, so
# wait till we are finished with system dependencies
wait
"${SPACK_INSTALL_SCRIPTS}/install_singularity_as_root.sh" || \
(
sudo -Eu spack "${SPACK_INSTALL_SCRIPTS}/preserve_built_spack_packages.sh" &&
exit 1 # propagate the error
)
# apply some system-level patching (TODO: remove this as soon as gccxml dependency is gone)
"${SPACK_INSTALL_SCRIPTS}/manual_system_level_patching_routine_called_in_post_as_root.sh"
EOF
# create appenvs for all views...
# append apps for each spackview...
generate_appenv() {
local name_app="$1"
local name_view="$2"
cat <<EOF
%appenv ${name_app}
# there can only be one app loaded at any time
export VIEW_ENV=${name_view}
SVF=/opt/spack_views/\${VIEW_ENV}
export PATH=\${SVF}/bin\${PATH:+:}\${PATH}
export PYTHONHOME=\${SVF}
export SPACK_PYTHON_BINARY=\${SVF}/bin/python
export MANPATH=\${SVF}/man:\${SVF}/share/man\${MANPATH:+:}\${MANPATH}
export LIBRARY_PATH=\${SVF}/lib:\${SVF}/lib64\${LIBRARY_PATH:+:}\${LIBRARY_PATH}
export LD_LIBRARY_PATH=\${SVF}/lib:\${SVF}/lib64\${LD_LIBRARY_PATH:+:}\${LD_LIBRARY_PATH}
export TCLLIBPATH=\${SVF}/lib\${TCLLIBPATH:+:}\${TCLLIBPATH}
export CPATH=\${SVF}/include\${CPATH:+:}\${CPATH}
export C_INCLUDE_PATH=\${SVF}/include\${C_INCLUDE_PATH:+:}\${C_INCLUDE_PATH}
export CPLUS_INCLUDE_PATH=\${SVF}/include\${CPLUS_INCLUDE_PATH:+:}\${CPLUS_INCLUDE_PATH}
export QUIET_CPATH=\${CPATH}
export QUIET_C_INCLUDE_PATH=\${C_INCLUDE_PATH}
export QUIET_CPLUS_INCLUDE_PATH=\${CPLUS_INCLUDE_PATH}
export PKG_CONFIG_PATH=\${SVF}/lib/pkgconfig:\${SVF}/lib64/pkgconfig:\${SVF}/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig\${PKG_CONFIG_PATH:+:}\${PKG_CONFIG_PATH}
export CMAKE_PREFIX_PATH=\${SVF}\${CMAKE_PREFIX_PATH:+:}\${CMAKE_PREFIX_PATH}
EOF
}
for view in "${spack_views[@]}"; do
# generate app
(
generate_appenv "${view}" "${view}"
) >> "${YASHCHIKI_RECIPE_PATH}"
done
../visionary/install_prerequisites.sh
\ No newline at end of file
../visionary/install_system_dependencies.sh
\ No newline at end of file
../visionary/manual_system_level_patching_routine_called_in_post_as_root.sh
\ No newline at end of file
# All spack packages that should be fetched/installed in the container
spack_packages=(
"f27-ido ^${DEPENDENCY_PYTHON} %${YASHCHIKI_SPACK_GCC}"
"f27-niklas ^${DEPENDENCY_PYTHON} %${YASHCHIKI_SPACK_GCC}"
)
spack_views=(\
ido
niklas
)
spack_views_no_default_gcc=(
)
spack_views_gccxml=(
)
spack_gid="nogroup"
spack_create_user_cmd() {
adduser spack --uid 888 --no-create-home --home /opt/spack --disabled-password --system --shell /bin/bash
}
# all views get the default gcc except those in spack_views_no_default_gcc
# (defined above)
spack_add_to_view_with_dependencies["${YASHCHIKI_SPACK_GCC}"]="no"
spack_add_to_view["${YASHCHIKI_SPACK_GCC}"]="$(
for viewname in "${spack_views[@]+"${spack_views[@]}"}"; do
# check if the current view matches any view that does not get the
# default gcc
# Note: Currently this allow partial matches
if printf "%s\n" "${spack_views_no_default_gcc[@]+"${spack_views_no_default_gcc[@]}"}" \
| grep -qF "${viewname}"; then
continue
fi
echo ${viewname}
done | tr '\n' ' '
)"
## Add gccxml to those views that still depend on it
spack_add_to_view_gccxml="$(
for viewname in "${spack_views[@]+"${spack_views[@]}"}"; do
# check if the current view matches any view that gets gccxml
# Note: Currently this allow partial matches
if printf "%s\n" "${spack_views_gccxml[@]+"${spack_views_gccxml[@]}"}" \
| grep -qF "${viewname}"; then
echo ${viewname}
fi
done | tr '\n' ' '
)"
if [[ "$spack_add_to_view_gccxml" != "" ]]; then
spack_add_to_view_with_dependencies["gccxml"]="no"
spack_add_to_view["gccxml"]="$spack_add_to_view_gccxml"
fi
cat <<EOF
${MY_SPACK_CMD} ${SPACK_ARGS_VIEW[@]+"${SPACK_ARGS_VIEW[@]}"} view -d yes symlink -i ${MY_SPACK_VIEW_PREFIX}/ido $(get_latest_hash f27-ido "^${DEPENDENCY_PYTHON}")
${MY_SPACK_CMD} ${SPACK_ARGS_VIEW[@]+"${SPACK_ARGS_VIEW[@]}"} view -d yes symlink -i ${MY_SPACK_VIEW_PREFIX}/niklas $(get_latest_hash f27-niklas "^${DEPENDENCY_PYTHON}")
EOF
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment