Skip to content

Commit 9dff222

Browse files
authored
Merge pull request #798 from trz42/2023.06-software.eessi.io-cuDNN-8.9.2.26-part-2
adjust SitePackage.lua for multiple CUDA/cu* modules
2 parents 464dcba + f87857a commit 9dff222

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

create_lmodsitepackage.py

+22-16
Original file line numberDiff line numberDiff line change
@@ -110,36 +110,42 @@
110110
end
111111
112112
113-
local function eessi_cuda_enabled_load_hook(t)
113+
local function eessi_cuda_and_libraries_enabled_load_hook(t)
114114
local frameStk = require("FrameStk"):singleton()
115115
local mt = frameStk:mt()
116116
local simpleName = string.match(t.modFullName, "(.-)/")
117-
-- If we try to load CUDA itself, check if the full CUDA SDK was installed on the host in host_injections.
118-
-- This is required for end users to build additional CUDA software. If the full SDK isn't present, refuse
119-
-- to load the CUDA module and print an informative message on how to set up GPU support for EESSI
117+
local packagesList = { ["CUDA"] = true, ["cuDNN"] = true }
118+
-- If we try to load any of the modules in packagesList, we check if the
119+
-- full package was installed on the host in host_injections.
120+
-- This is required for end users to build additional software that depends
121+
-- on the package. If the full SDK isn't present, refuse
122+
-- to load the module and print an informative message on how to set up GPU support for EESSI
120123
local refer_to_docs = "For more information on how to do this, see https://www.eessi.io/docs/site_specific_config/gpu/.\\n"
121-
if simpleName == 'CUDA' then
124+
if packagesList[simpleName] then
125+
-- simpleName is a module in packagesList
122126
-- get the full host_injections path
123127
local hostInjections = string.gsub(os.getenv('EESSI_SOFTWARE_PATH') or "", 'versions', 'host_injections')
124-
-- build final path where the CUDA software should be installed
125-
local cudaEasyBuildDir = hostInjections .. "/software/" .. t.modFullName .. "/easybuild"
126-
local cudaDirExists = isDir(cudaEasyBuildDir)
127-
if not cudaDirExists then
128+
129+
-- build final path where the software should be installed
130+
local packageEasyBuildDir = hostInjections .. "/software/" .. t.modFullName .. "/easybuild"
131+
local packageDirExists = isDir(packageEasyBuildDir)
132+
if not packageDirExists then
128133
local advice = "but while the module file exists, the actual software is not entirely shipped with EESSI "
129-
advice = advice .. "due to licencing. You will need to install a full copy of the CUDA SDK where EESSI "
134+
advice = advice .. "due to licencing. You will need to install a full copy of the " .. simpleName .. " package where EESSI "
130135
advice = advice .. "can find it.\\n"
131136
advice = advice .. refer_to_docs
132137
LmodError("\\nYou requested to load ", simpleName, " ", advice)
133138
end
134139
end
135-
-- when loading CUDA enabled modules check if the necessary driver libraries are accessible to the EESSI linker,
140+
-- when loading CUDA (and cu*) enabled modules check if the necessary driver libraries are accessible to the EESSI linker,
136141
-- otherwise, refuse to load the requested module and print error message
137142
local checkGpu = mt:haveProperty(simpleName,"arch","gpu")
138143
local overrideGpuCheck = os.getenv("EESSI_OVERRIDE_GPU_CHECK")
139144
if checkGpu and (overrideGpuCheck == nil) then
140145
local arch = os.getenv("EESSI_CPU_FAMILY") or ""
141-
local cudaVersionFile = "/cvmfs/software.eessi.io/host_injections/nvidia/" .. arch .. "/latest/cuda_version.txt"
142-
local cudaDriverFile = "/cvmfs/software.eessi.io/host_injections/nvidia/" .. arch .. "/latest/libcuda.so"
146+
local cvmfs_repo = os.getenv("EESSI_CVMFS_REPO") or ""
147+
local cudaVersionFile = cvmfs_repo .. "/host_injections/nvidia/" .. arch .. "/latest/cuda_version.txt"
148+
local cudaDriverFile = cvmfs_repo .. "/host_injections/nvidia/" .. arch .. "/latest/libcuda.so"
143149
local cudaDriverExists = isFile(cudaDriverFile)
144150
local singularityCudaExists = isFile("/.singularity.d/libs/libcuda.so")
145151
if not (cudaDriverExists or singularityCudaExists) then
@@ -197,10 +203,10 @@
197203
-- Also: make it non-local, so it can be imported and extended by other lmodrc files if needed
198204
function eessi_load_hook(t)
199205
eessi_espresso_deprecated_message(t)
200-
-- Only apply CUDA hooks if the loaded module is in the EESSI prefix
201-
-- This avoids getting an Lmod Error when trying to load a CUDA module from a local software stack
206+
-- Only apply CUDA and cu*-library hooks if the loaded module is in the EESSI prefix
207+
-- This avoids getting an Lmod Error when trying to load a CUDA or cu* module from a local software stack
202208
if from_eessi_prefix(t) then
203-
eessi_cuda_enabled_load_hook(t)
209+
eessi_cuda_and_libraries_enabled_load_hook(t)
204210
end
205211
end
206212

0 commit comments

Comments
 (0)