Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating Cray toolchain modulefiles with Lua syntax #3626

Closed
lucamar opened this issue Apr 2, 2021 · 4 comments · Fixed by #3685
Closed

Error creating Cray toolchain modulefiles with Lua syntax #3626

lucamar opened this issue Apr 2, 2021 · 4 comments · Fixed by #3685
Labels
bug report cray Issues and PRs related to integration with Cray PE
Milestone

Comments

@lucamar
Copy link

lucamar commented Apr 2, 2021

I report here as a placeholder for further discussion the issue with the swap function mentioned in #3575.
The error is raised at the sanity check when the Lua syntax is used to create the Cray toolchain modulefiles:

== 2021-02-18 10:41:00,170 build_log.py:169 ERROR EasyBuild crashed with an error (at easybuild/base/exceptions.py:124 in __init__): Module command '/usr/share/lmod/lmod/libexec/lmod python load cpeGNU/21.02' failed with exit code 1; stderr: Lmod has detected the following error: Unable to load module because of error when evaluating modulefile:
     /tmp/eb-l61bgz4f/tmpk9aiog8r/all/Core/cpeGNU/21.02.lua: [string "help([==[..."]:29: attempt to call a nil value (global
'swap')
     Please check the modulefile and especially if there is a the line number specified in the above message 
While processing the following module(s):
    Module fullname  Module Filename
    ---------------  ---------------
    cpeGNU/21.02     /tmp/eb-l61bgz4f/tmpk9aiog8r/all/Core/cpeGNU/21.02.lua

; stdout: _mlstatus = False
 (at easybuild/tools/modules.py:814 in run_module)

The framework scripts involved are easyblocks/generic/craytoolchain.py and tools/module_generator.py. The workaround is to list Cray external modules using module unlod/load commands in modluafooter instead of dependencies, to avoid the use of the function swap in the Lua modulefile created by EasyBuild for the Cray toolchains.
In the example below I make use of the custom easyblock cpeToolchain adapted from craytoolchain.py:

# Compiler toolchain for Cray EX Programming Environment GNU compiler (cpe-gnu)
easyblock = 'cpeToolchain'

name = 'cpeGNU'
version = "21.02"

homepage = 'https://pubs.cray.com'
description = """Toolchain using Cray compiler wrapper with cpe-gnu module (CPE release: %s).\n""" % version

toolchain = SYSTEM

dependencies = [
   ('cpe-gnu', EXTERNAL_MODULE)
]

modluafooter = '''
if not ( isloaded("cray-dsmml/0.1.3") ) then
    load("cray-dsmml/0.1.3")
end
if not ( isloaded("cray-libsci/20.12.1.2") ) then
    load("cray-libsci/20.12.1.2")
end
if not ( isloaded("cray-mpich/8.1.2") ) then
    load("cray-mpich/8.1.2")
end
if not ( isloaded("craype/2.7.5") ) then
    load("craype/2.7.5")
end
if not ( isloaded("craype-x86-rome") ) then
    load("craype-x86-rome")
end
if not ( isloaded("craype-network-ofi") ) then
    load("craype-network-ofi")
end
if not ( isloaded("gcc/10.2.0") ) then
    load("gcc/10.2.0")
end
if not ( isloaded("libfabric/1.11.0.0.233") ) then
    load("libfabric/1.11.0.0.233")
end
if not ( isloaded("perftools-base/21.02.0") ) then
    load("perftools-base/21.02.0")
end
if not ( isloaded("xpmem/2.2.35-7.0.1.0_1.9__gd50fabf.shasta") ) then
    load("xpmem/2.2.35-7.0.1.0_1.9__gd50fabf.shasta")
end
prepend_path("MODULEPATH",root:gsub("software","modules/all/Toolchain"))
'''
moduleclass = 'toolchain'
@boegel boegel added this to the next release (4.3.5?) milestone May 10, 2021
@boegel boegel added the cray Issues and PRs related to integration with Cray PE label May 12, 2021
@boegel
Copy link
Member

boegel commented May 18, 2021

I took a quick look at this, and it's easy to reproduce with a simple test module:

$ find /tmp/$USER/testmods -type f
/tmp/testmods/swapit/1.0.lua
/tmp/testmods/foo/1.2.lua
/tmp/testmods/foo/1.0.lua

$ cat /tmp/testmods/swapit/1.0.lua
swap("foo", "foo/1.2")

This triggers the same error:

$ module list

Currently Loaded Modules:
  1) foo/1.0

$ module load swapit
Lmod has detected the following error:  Unable to load module because of error when evaluating modulefile:
     /tmp/testmods/swapit/1.0.lua: [string "swap("foo", "foo/1.2")..."]:1: attempt to call a nil value (global 'swap')
     Please check the modulefile and especially if there is a the line number specified in the above message
While processing the following module(s):
    Module fullname  Module Filename
    ---------------  ---------------
    swapit/1.0       /tmp/testmods/swapit/1.0.lua

So apparently the swap statement that EasyBuild has been generating since Feb'17 in Lua module files is simply not supported by Lmod at all, and we never noticed?!

@rtmclay Can you confirm that swap is not supported in Lua module files (while module swap in Tcl module files is)?

@rtmclay
Copy link

rtmclay commented May 18, 2021

The module swap command in TCL modulefiles just does an unload() followed by a load().

boegel added a commit to boegel/easybuild-framework that referenced this issue May 18, 2021
boegel added a commit to boegel/easybuild-framework that referenced this issue May 18, 2021
@boegel
Copy link
Member

boegel commented May 18, 2021

OK, so this is fairly easy to fix: we just do an unload + load to emulate a swap operation when using Lua module files.

Fixed in #3685

@lucamar
Copy link
Author

lucamar commented May 19, 2021

Thanks a lot @boegel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report cray Issues and PRs related to integration with Cray PE
Projects
None yet
3 participants