Skip to content

Commit

Permalink
Merge pull request #399 from trz42/nessi-2023.06-deps-PyTorch-bundle-…
Browse files Browse the repository at this point in the history
…CPU-only

{2023.06,2023a} dependencies for PyTorch-bundle v2.1.2
  • Loading branch information
poksumdo authored Jun 9, 2024
2 parents 093601c + fc7707e commit 0c2664d
Show file tree
Hide file tree
Showing 12 changed files with 412 additions and 14 deletions.
16 changes: 11 additions & 5 deletions EESSI-install-software.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ display_help() {
echo " --skip-cuda-install - disable installing a full CUDA SDK in the host_injections prefix (e.g. in CI)"
}

# Function to check if a command exists
function command_exists() {
command -v "$1" >/dev/null 2>&1
}

function copy_build_log() {
# copy specified build log to specified directory, with some context added
build_log=${1}
Expand Down Expand Up @@ -159,8 +154,13 @@ fi
# are:
# - .lmod/lmodrc.lua
# - .lmod/SitePackage.lua
#
# We run scripts to create them if they don't exist or if the scripts have been
# changed in the PR.
#
# (TODO do we need to change the path if we have sub-directories for
# accelerators? And would we need different scripts for creating lua files under
# different directories?)

# Set base directory for software and for Lmod config files
_eessi_software_path=${EESSI_PREFIX}/software/${EESSI_OS_TYPE}/${EESSI_SOFTWARE_SUBDIR_OVERRIDE}
Expand Down Expand Up @@ -256,6 +256,12 @@ if command_exists "nvidia-smi"; then
${EESSI_PREFIX}/scripts/gpu_support/nvidia/link_nvidia_host_libraries.sh
fi

# Install extra software that is needed (e.g., for providing a custom ctypes
# library when needed)
cd ${TOPDIR}/scripts/extra
./install_extra_packages.sh --temp-dir /tmp/temp --easystack eessi-2023.06-extra-packages.yml
cd ${TOPDIR}

# use PR patch file to determine in which easystack files stuff was added
changed_easystacks=$(cat ${pr_diff} | grep '^+++' | cut -f2 -d' ' | sed 's@^[a-z]/@@g' | grep '^easystacks/.*yml$' | egrep -v 'known-issues|missing')
if [ -z "${changed_easystacks}" ]; then
Expand Down
16 changes: 10 additions & 6 deletions bot/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,20 @@ mkdir -p ${TARBALL_TMP_BUILD_STEP_DIR}
BUILD_STEP_ARGS+=("--save" "${TARBALL_TMP_BUILD_STEP_DIR}")
BUILD_STEP_ARGS+=("--storage" "${STORAGE}")
# add options required to handle NVIDIA support
BUILD_STEP_ARGS+=("--nvidia" "all")
if command_exists "nvidia-smi"; then
echo "Command 'nvidia-smi' found, using available GPU"
BUILD_STEP_ARGS+=("--nvidia" "all")
else
echo "No 'nvidia-smi' found, no available GPU but allowing overriding this check"
BUILD_STEP_ARGS+=("--nvidia" "install")
fi
# Retain location for host injections so we don't reinstall CUDA
# (Always need to run the driver installation as available driver may change)

if [[ ! -z ${SHARED_FS_PATH} ]]; then
BUILD_STEP_ARGS+=("--host-injections" "${SHARED_FS_PATH}/host-injections")
fi

# Don't run the Lmod GPU driver check when doing builds (may not have a GPU, and it's not relevant for vanilla builds anyway)
echo "EESSI_OVERRIDE_GPU_CHECK='${EESSI_OVERRIDE_GPU_CHECK}'"
export EESSI_OVERRIDE_GPU_CHECK=1
echo "EESSI_OVERRIDE_GPU_CHECK='${EESSI_OVERRIDE_GPU_CHECK}'"

# create tmp file for output of build step
build_outerr=$(mktemp build.outerr.XXXX)

Expand Down
20 changes: 20 additions & 0 deletions easystacks/pilot.nessi.no/2023.06/eessi-2023.06-eb-4.9.1-2023a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,23 @@ easyconfigs:
- PyTorch-2.1.2-foss-2023a-CUDA-12.1.1.eb:
options:
cuda-compute-capabilities: 6.0,6.1,7.0,7.5,8.0,8.6,8.9,9.0
# PyTorch-bundle-CUDA's dependencies without CUDA
- librosa-0.10.1-foss-2023a.eb
- NLTK-3.8.1-foss-2023a.eb
- parameterized-0.9.0-GCCcore-12.3.0.eb
- Scalene-1.5.26-GCCcore-12.3.0.eb
- scikit-image-0.22.0-foss-2023a.eb
- SentencePiece-0.2.0-GCC-12.3.0.eb:
# see https://github.com/easybuilders/easybuild-easyconfigs/pull/19987
options:
from-pr: 19987
- libmad-0.15.1b-GCCcore-12.3.0.eb:
# see https://github.com/easybuilders/easybuild-easyconfigs/pull/19987
options:
from-pr: 19987
- SoX-14.4.2-GCCcore-12.3.0.eb:
# see https://github.com/easybuilders/easybuild-easyconfigs/pull/19987
options:
from-pr: 19987
- tensorboard-2.15.1-gfbf-2023a.eb
- tqdm-4.66.1-GCCcore-12.3.0.eb
86 changes: 86 additions & 0 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import easybuild.tools.environment as env
from easybuild.easyblocks.generic.configuremake import obtain_config_guess
from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS
from easybuild.easyblocks.python import EXTS_FILTER_PYTHON_PACKAGES
from easybuild.tools.build_log import EasyBuildError, print_msg
from easybuild.tools.config import build_option, update_build_option
from easybuild.tools.filetools import apply_regex_substitutions, copy_file, remove_file, symlink, which
Expand Down Expand Up @@ -311,6 +312,31 @@ def parse_hook_qt5_check_qtwebengine_disable(ec, eprefix):
raise EasyBuildError("Qt5-specific hook triggered for non-Qt5 easyconfig?!")



def parse_hook_sentencepiece_disable_tcmalloc_aarch64(ec, eprefix):
"""
Disable using TC_Malloc on 'aarch64/generic'
"""
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')
if ec.name == 'SentencePiece' and ec.version in ['0.2.0']:
if cpu_target == CPU_TARGET_AARCH64_GENERIC:
print_msg("parse_hook for SentencePiece: OLD '%s'", ec['components'])
new_components = []
for item in ec['components']:
if item[2]['easyblock'] == 'CMakeMake':
new_item = item[2]
new_item['configopts'] = '-DSPM_ENABLE_TCMALLOC=OFF'
new_components.append((item[0], item[1], new_item))
else:
new_components.append(item)
ec['components'] = new_components
print_msg("parse_hook for SentencePiece: NEW '%s'", ec['components'])
else:
print_msg("parse_hook for SentencePiece on %s -> leaving configopts unchanged", cpu_target)
else:
raise EasyBuildError("SentencePiece-specific hook triggered for non-SentencePiece easyconfig?!")


def parse_hook_ucx_eprefix(ec, eprefix):
"""Make UCX aware of compatibility layer via additional configuration options."""
if ec.name == 'UCX':
Expand Down Expand Up @@ -349,6 +375,30 @@ def parse_hook_lammps_remove_deps_for_CI_aarch64(ec, *args, **kwargs):
raise EasyBuildError("LAMMPS-specific hook triggered for non-LAMMPS easyconfig?!")


def parse_hook_librosa_custom_ctypes(ec, *args, **kwargs):
"""
Add exts_filter to soundfile extension in exts_list
"""
if ec.name == 'librosa' and ec.version in ('0.10.1',):
ec_dict = ec.asdict()
eessi_software_path = get_eessi_envvar('EESSI_SOFTWARE_PATH')
custom_ctypes_path = os.path.join(eessi_software_path, "software", "custom_ctypes", "1.2")
ebpythonprefixes = "EBPYTHONPREFIXES=%s" % custom_ctypes_path
exts_list_new = []
for item in ec_dict['exts_list']:
if item[0] == 'soundfile':
ext_dict = item[2]
ext_dict['exts_filter'] = (ebpythonprefixes + ' ' + EXTS_FILTER_PYTHON_PACKAGES[0],
EXTS_FILTER_PYTHON_PACKAGES[1])
exts_list_new.append((item[0], item[1], ext_dict))
else:
exts_list_new.append(item)
ec['exts_list'] = exts_list_new
print_msg("New exts_list: '%s'", ec['exts_list'])
else:
raise EasyBuildError("librosa/0.10.1-specific hook triggered for non-librosa/0.10.1 easyconfig?!")


def pre_prepare_hook_highway_handle_test_compilation_issues(self, *args, **kwargs):
"""
Solve issues with compiling or running the tests on both
Expand Down Expand Up @@ -852,17 +902,49 @@ def inject_gpu_property(ec):
return ec



def pre_module_hook(self, *args, **kwargs):
"""Main pre-module-check hook: trigger custom functions based on software name."""
if self.name in PRE_MODULE_HOOKS:
PRE_MODULE_HOOKS[self.name](self, *args, **kwargs)


def pre_module_hook_librosa_augment_modluafooter(self, *args, **kwargs):
"""
Add EBPYTHONPREFIXES to modluafooter
"""
if self.name == 'librosa' and self.version == '0.10.1':
eessi_software_path = get_eessi_envvar('EESSI_SOFTWARE_PATH')
custom_ctypes_path = os.path.join(eessi_software_path, "software", "custom_ctypes", "1.2")
key = 'modluafooter'
values = ['prepend_path("EBPYTHONPREFIXES","%s")' % (custom_ctypes_path)]
print_msg("Adding '%s' to modluafooter", values[0])
if not key in self.cfg:
self.cfg[key] = '\n'.join(values)
else:
new_value = self.cfg[key]
for value in values:
if not value in new_value:
new_value = '\n'.join([new_value, value])
self.cfg[key] = new_value
print_msg("Full modluafooter is '%s'", self.cfg[key])
else:
raise EasyBuildError("librosa/0.10.1-specific hook triggered for non-librosa/0.10.1 easyconfig?!")


PARSE_HOOKS = {
'casacore': parse_hook_casacore_disable_vectorize,
'CGAL': parse_hook_cgal_toolchainopts_precise,
'fontconfig': parse_hook_fontconfig_add_fonts,
'GPAW': parse_hook_gpaw_harcoded_path,
'ImageMagick': parse_hook_imagemagick_add_dependency,
'LAMMPS': parse_hook_lammps_remove_deps_for_CI_aarch64,
'librosa': parse_hook_librosa_custom_ctypes,
'OpenBLAS': parse_hook_openblas_relax_lapack_tests_num_errors,
'Pillow-SIMD' : parse_hook_Pillow_SIMD_harcoded_paths,
'pybind11': parse_hook_pybind11_replace_catch2,
'Qt5': parse_hook_qt5_check_qtwebengine_disable,
'SentencePiece': parse_hook_sentencepiece_disable_tcmalloc_aarch64,
'UCX': parse_hook_ucx_eprefix,
}

Expand Down Expand Up @@ -909,3 +991,7 @@ def inject_gpu_property(ec):
'cuDNN': post_sanitycheck_cudnn,
'cuTENSOR': post_sanitycheck_cutensor,
}

PRE_MODULE_HOOKS = {
'librosa': pre_module_hook_librosa_augment_modluafooter,
}
5 changes: 5 additions & 0 deletions eessi_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@ if [[ ${SETUP_NVIDIA} -eq 1 ]]; then
mkdir -p ${EESSI_USR_LOCAL_CUDA}
BIND_PATHS="${BIND_PATHS},${EESSI_VAR_LOG}:/var/log,${EESSI_USR_LOCAL_CUDA}:/usr/local/cuda"
[[ ${VERBOSE} -eq 1 ]] && echo "BIND_PATHS=${BIND_PATHS}"
if [[ "${NVIDIA_MODE}" == "install" ]] ; then
# No GPU so we need to "trick" Lmod to allow us to load CUDA modules even without a CUDA driver
# (this variable means EESSI_OVERRIDE_GPU_CHECK=1 will be set inside the container)
export SINGULARITYENV_EESSI_OVERRIDE_GPU_CHECK=1
fi
fi
fi

Expand Down
1 change: 1 addition & 0 deletions install_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ nvidia_files=(
eessi-2023.06-cuda-and-libraries.yml
install_cuda_and_libraries.sh
link_nvidia_host_libraries.sh
copy_nvidia_host_libraries.sh
)
copy_files_by_list ${TOPDIR}/scripts/gpu_support/nvidia ${INSTALL_PREFIX}/scripts/gpu_support/nvidia "${nvidia_files[@]}"

Expand Down
6 changes: 3 additions & 3 deletions run_in_compat_layer_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ fi
if [ ! -z ${EESSI_VERSION_OVERRIDE} ]; then
INPUT="export EESSI_VERSION_OVERRIDE=${EESSI_VERSION_OVERRIDE}; ${INPUT}"
fi
if [ ! -z ${http_proxy} ]; then
INPUT="export http_proxy=${http_proxy}; ${INPUT}"
fi
if [ ! -z ${EESSI_OVERRIDE_GPU_CHECK} ]; then
INPUT="export EESSI_OVERRIDE_GPU_CHECK=${EESSI_OVERRIDE_GPU_CHECK}; ${INPUT}"
fi
if [ ! -z ${http_proxy} ]; then
INPUT="export http_proxy=${http_proxy}; ${INPUT}"
fi
if [ ! -z ${https_proxy} ]; then
INPUT="export https_proxy=${https_proxy}; ${INPUT}"
fi
Expand Down
29 changes: 29 additions & 0 deletions scripts/extra/custom_ctypes-1.2.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
##
# This is a contribution from the NESSI project
# Homepage: https://documentation.sigma2.no
#
# Authors:: Thomas Roeblitz <[email protected]>
# License:: GPL-2.0-only
#
##

easyblock = 'Tarball'

name = 'custom_ctypes'
version = '1.2'

homepage = 'https://github.com/ComputeCanada/custom_ctypes'
description = """custum_ctypes is a small Python package to fix the discovery of libraries with Python's ctypes module. It changes the behavior of find_library to return absolute paths to shared objects rather than just the names."""

toolchain = SYSTEM

source_urls = ['https://github.com/ComputeCanada/custom_ctypes/archive/refs/tags']
sources = ['%(version)s.tar.gz']
checksums = ['3b30ce633c6a329169f2b10ff24b8eaaeef3fa208a66cdacdb53c22f02a88d9b']

sanity_check_paths = {
'files': ['README.md'],
'dirs': ['lib'],
}

moduleclass = 'lib'
2 changes: 2 additions & 0 deletions scripts/extra/eessi-2023.06-extra-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
easyconfigs:
- custom_ctypes-1.2.eb
95 changes: 95 additions & 0 deletions scripts/extra/install_extra_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env bash

# This script can be used to install extra packages under ${EESSI_SOFTWARE_PATH}

# some logging
echo ">>> Running ${BASH_SOURCE}"

# Initialise our bash functions
TOPDIR=$(dirname $(realpath ${BASH_SOURCE}))
source "${TOPDIR}"/../utils.sh

# Function to display help message
show_help() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --help Display this help message"
echo " -e, --easystack EASYSTACKFILE Easystack file which specifies easyconfigs to be installed."
echo " -t, --temp-dir /path/to/tmpdir Specify a location to use for temporary"
echo " storage during the installation"
}

# Initialize variables
TEMP_DIR=
EASYSTACK_FILE=

# Parse command-line options
while [[ $# -gt 0 ]]; do
case "$1" in
--help)
show_help
exit 0
;;
-e|--easystack)
if [ -n "$2" ]; then
EASYSTACK_FILE="$2"
shift 2
else
echo "Error: Argument required for $1"
show_help
exit 1
fi
;;
-t|--temp-dir)
if [ -n "$2" ]; then
TEMP_DIR="$2"
shift 2
else
echo "Error: Argument required for $1"
show_help
exit 1
fi
;;
*)
show_help
fatal_error "Error: Unknown option: $1"
;;
esac
done

if [[ -z ${EASYSTACK_FILE} ]]; then
show_help
fatal_error "Error: need to specify easystack file"
fi

# Make sure NESSI is initialised
check_eessi_initialised

# As an installation location just use $EESSI_SOFTWARE_PATH
export NESSI_CVMFS_INSTALL=${EESSI_SOFTWARE_PATH}

# we need a directory we can use for temporary storage
if [[ -z "${TEMP_DIR}" ]]; then
tmpdir=$(mktemp -d)
else
mkdir -p ${TEMP_DIR}
tmpdir=$(mktemp -d --tmpdir=${TEMP_DIR} extra.XXX)
if [[ ! -d "$tmpdir" ]] ; then
fatal_error "Could not create directory ${tmpdir}"
fi
fi
echo "Created temporary directory '${tmpdir}'"
export WORKING_DIR=${tmpdir}

# load EasyBuild
ml EasyBuild

# load NESSI-extend/2023.06-easybuild
ml NESSI-extend/2023.06-easybuild

eb --show-config

eb --easystack ${EASYSTACK_FILE} --robot

# clean up tmpdir
rm -rf "${tmpdir}"
Loading

0 comments on commit 0c2664d

Please sign in to comment.