Skip to content

Commit

Permalink
adjust creation of SitePackage.lua to NESSI
Browse files Browse the repository at this point in the history
  • Loading branch information
truib committed May 8, 2024
1 parent 46ef372 commit b5f3c95
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions create_lmodsitepackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
end
local function from_eessi_prefix(t)
-- eessi_prefix is the prefix with official EESSI modules
-- e.g. /cvmfs/software.eessi.io/versions/2023.06
-- eessi_prefix is the prefix with official NESSI modules
-- e.g. /cvmfs/pilot.nessi.no/versions/2023.06
local eessi_prefix = os.getenv("EESSI_PREFIX")
-- If EESSI_PREFIX wasn't defined, we cannot check if this module was from the EESSI environment
-- If EESSI_PREFIX wasn't defined, we cannot check if this module was from the NESSI environment
-- In that case, we assume it isn't, otherwise EESSI_PREFIX would (probably) have been set
if eessi_prefix == nil then
return False
else
-- NOTE: exact paths for site so may need to be updated later.
-- See https://github.com/EESSI/software-layer/pull/371
-- See https://github.com/NorESSI/software-layer/pull/358
-- eessi_prefix_host_injections is the prefix with site-extensions (i.e. additional modules)
-- to the official EESSI modules, e.g. /cvmfs/software.eessi.io/host_injections/2023.06
-- to the official NESSI modules, e.g. /cvmfs/pilot.nessi.no/host_injections/2023.06
local eessi_prefix_host_injections = string.gsub(eessi_prefix, 'versions', 'host_injections')
-- Check if the full modulepath starts with the eessi_prefix_*
Expand All @@ -42,9 +42,9 @@
end
local function load_site_specific_hooks()
-- This function will be run after the EESSI hooks are registered
-- This function will be run after the NESSI hooks are registered
-- It will load a local SitePackage.lua that is architecture independent (if it exists) from e.g.
-- /cvmfs/software.eessi.io/host_injections/2023.06/.lmod/SitePackage.lua
-- /cvmfs/pilot.nessi.no/host_injections/2023.06/.lmod/SitePackage.lua
-- That can define a new hook
--
-- function site_specific_load_hook(t)
Expand All @@ -58,15 +58,15 @@
-- site_specific_load_hook(t)
-- end
--
-- Over overwrite the EESSI hook entirely:
-- Or overwrite the NESSI hook entirely:
--
-- hook.register("load", final_load_hook)
--
-- Note that the appending procedure can be simplified once we have an lmod >= 8.7.36
-- See https://github.com/TACC/Lmod/pull/696#issuecomment-1998765722
--
-- Subsequently, this function will look for an architecture-specific SitePackage.lua, e.g. from
-- /cvmfs/software.eessi.io/host_injections/2023.06/software/linux/x86_64/amd/zen2/.lmod/SitePackage.lua
-- /cvmfs/pilot.nessi.no/host_injections/2023.06/software/linux/x86_64/amd/zen2/.lmod/SitePackage.lua
-- This can then register an additional hook, e.g.
--
-- function arch_specific_load_hook(t)
Expand Down Expand Up @@ -112,7 +112,7 @@
local simpleName = string.match(t.modFullName, "(.-)/")
-- If we try to load CUDA itself, check if the full CUDA SDK was installed on the host in host_injections.
-- This is required for end users to build additional CUDA software. If the full SDK isn't present, refuse
-- to load the CUDA module and print an informative message on how to set up GPU support for EESSI
-- to load the CUDA module and print an informative message on how to set up GPU support for NESSI
local refer_to_docs = "For more information on how to do this, see https://www.eessi.io/docs/gpu/.\\n"
if simpleName == 'CUDA' then
-- get the full host_injections path
Expand All @@ -121,26 +121,26 @@
local cudaEasyBuildDir = hostInjections .. "/software/" .. t.modFullName .. "/easybuild"
local cudaDirExists = isDir(cudaEasyBuildDir)
if not cudaDirExists then
local advice = "but while the module file exists, the actual software is not entirely shipped with EESSI "
advice = advice .. "due to licencing. You will need to install a full copy of the CUDA SDK where EESSI "
local advice = "but while the module file exists, the actual software is not entirely shipped with NESSI "
advice = advice .. "due to licencing. You will need to install a full copy of the CUDA SDK where NESSI "
advice = advice .. "can find it.\\n"
advice = advice .. refer_to_docs
LmodError("\\nYou requested to load ", simpleName, " ", advice)
end
end
-- when loading CUDA enabled modules check if the necessary driver libraries are accessible to the EESSI linker,
-- when loading CUDA enabled modules check if the necessary driver libraries are accessible to the NESSI linker,
-- otherwise, refuse to load the requested module and print error message
local haveGpu = mt:haveProperty(simpleName,"arch","gpu")
if haveGpu then
local arch = os.getenv("EESSI_CPU_FAMILY") or ""
local cudaVersionFile = "/cvmfs/software.eessi.io/host_injections/nvidia/" .. arch .. "/latest/cuda_version.txt"
local cudaDriverFile = "/cvmfs/software.eessi.io/host_injections/nvidia/" .. arch .. "/latest/libcuda.so"
local cudaVersionFile = "/cvmfs/pilot.nessi.no/host_injections/nvidia/" .. arch .. "/latest/cuda_version.txt"
local cudaDriverFile = "/cvmfs/pilot.nessi.no/host_injections/nvidia/" .. arch .. "/latest/libcuda.so"
local cudaDriverExists = isFile(cudaDriverFile)
local singularityCudaExists = isFile("/.singularity.d/libs/libcuda.so")
if not (cudaDriverExists or singularityCudaExists) then
local advice = "which relies on the CUDA runtime environment and driver libraries. "
advice = advice .. "In order to be able to use the module, you will need "
advice = advice .. "to make sure EESSI can find the GPU driver libraries on your host system.\\n"
advice = advice .. "to make sure NESSI can find the GPU driver libraries on your host system.\\n"
advice = advice .. refer_to_docs
LmodError("\\nYou requested to load ", simpleName, " ", advice)
else
Expand All @@ -162,7 +162,7 @@
if driver_libs_need_update == true then
local advice = "but the module you want to load requires CUDA " .. cudaVersion_req .. ". "
advice = advice .. "Please update your CUDA driver libraries and then "
advice = advice .. "let EESSI know about the update.\\n"
advice = advice .. "let NESSI know about the update.\\n"
advice = advice .. refer_to_docs
LmodError("\\nYour driver CUDA version is ", cudaVersion, " ", advice)
end
Expand All @@ -174,7 +174,7 @@
-- Combine both functions into a single one, as we can only register one function as load hook in lmod
-- Also: make it non-local, so it can be imported and extended by other lmodrc files if needed
function eessi_load_hook(t)
-- Only apply CUDA hooks if the loaded module is in the EESSI prefix
-- Only apply CUDA hooks if the loaded module is in the NESSI prefix
-- This avoids getting an Lmod Error when trying to load a CUDA module from a local software stack
if from_eessi_prefix(t) then
eessi_cuda_enabled_load_hook(t)
Expand All @@ -183,7 +183,7 @@
hook.register("load", eessi_load_hook)
-- Note that this needs to happen at the end, so that any EESSI specific hooks can be overwritten by the site
-- Note that this needs to happen at the end, so that any NESSI specific hooks can be overwritten by the site
load_site_specific_hooks()
"""

Expand Down

0 comments on commit b5f3c95

Please sign in to comment.