8
8
9
9
DOT_LMOD = '.lmod'
10
10
11
- hook_txt = """require("strict")
11
+ hook_txt = """require("strict")
12
12
local hook = require("Hook")
13
13
local open = io.open
14
14
36
36
-- eessi_prefix_host_injections is the prefix with site-extensions (i.e. additional modules)
37
37
-- to the official EESSI modules, e.g. /cvmfs/software.eessi.io/host_injections/2023.06
38
38
local eessi_prefix_host_injections = string.gsub(eessi_prefix, 'versions', 'host_injections')
39
-
39
+
40
40
-- Check if the full modulepath starts with the eessi_prefix_*
41
41
return string.find(t.fn, "^" .. eessi_prefix) ~= nil or string.find(t.fn, "^" .. eessi_prefix_host_injections) ~= nil
42
42
end
103
103
if isFile(archSitePackage) then
104
104
dofile(archSitePackage)
105
105
end
106
-
106
+
107
107
end
108
108
109
109
110
110
local function eessi_cuda_enabled_load_hook(t)
111
111
local frameStk = require("FrameStk"):singleton()
112
112
local mt = frameStk:mt()
113
113
local simpleName = string.match(t.modFullName, "(.-)/")
114
- -- If we try to load CUDA itself, check if the full CUDA SDK was installed on the host in host_injections.
114
+ -- If we try to load CUDA itself, check if the full CUDA SDK was installed on the host in host_injections.
115
115
-- This is required for end users to build additional CUDA software. If the full SDK isn't present, refuse
116
116
-- to load the CUDA module and print an informative message on how to set up GPU support for EESSI
117
117
local refer_to_docs = "For more information on how to do this, see https://www.eessi.io/docs/gpu/.\\ n"
207
207
load_site_specific_hooks()
208
208
"""
209
209
210
+
210
211
def error (msg ):
211
212
sys .stderr .write ("ERROR: %s\n " % msg )
212
213
sys .exit (1 )
@@ -221,12 +222,18 @@ def error(msg):
221
222
error ("Prefix directory %s does not exist!" % prefix )
222
223
223
224
sitepackage_path = os .path .join (prefix , DOT_LMOD , 'SitePackage.lua' )
225
+
226
+ # Lmod itself doesn't care about compute capability so remove this duplication from
227
+ # the install path (if it exists)
228
+ accel_subdir = os .getenv ("EESSI_ACCELERATOR_TARGET" )
229
+ if accel_subdir :
230
+ sitepackage_path = sitepackage_path .replace ("/accel/%s" % accel_subdir , '' )
224
231
try :
225
232
os .makedirs (os .path .dirname (sitepackage_path ), exist_ok = True )
226
233
with open (sitepackage_path , 'w' ) as fp :
227
234
fp .write (hook_txt )
228
235
# Make sure that the created Lmod file has "read/write" for the user/group and "read" permissions for others
229
- os .chmod (sitepackage_path , S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH )
236
+ os .chmod (sitepackage_path , S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH )
230
237
231
238
except (IOError , OSError ) as err :
232
239
error ("Failed to create %s: %s" % (sitepackage_path , err ))
0 commit comments