Re: [Lmod-users] When using depends_on, setenv via a function is not unset by unload
A Lua based environment module system that reads TCL modulefiles.
Brought to you by:
rtmclay
|
From: Robert M. <mc...@ta...> - 2020-08-26 22:37:48
|
Lmod does what you tell it to do. The depends_on("cuda") unloads the cuda
module if it thinks it should. That is, if there are no other modulefiles
dependent on cuda. So if it unloads the cuda module and it unsets
CUDA_HOME, then of course os.getenv("CUDA_HOME") is going to return a nil,
which is not a string. Lmod requires that setenv(A,B) that both arguments
are strings. A simple way to fix your modulefile is to do:
local cuda_home = os.getenv("CUDA_HOME") or ""
setenv("THINGY", cuda_home)
Best,
Robert.
On Wed, Aug 26, 2020 at 1:38 PM Shelly Johnson <js...@um...> wrote:
> Suppose I have a module, hello, that depends_on('cuda/11.0.2'). I was
> hoping to be able to use something like
>
> #-----------------------------
> local installDir = "/sw/arcts/centos7/hello/1.0"
> local app = "hello"
> depends_on('cuda/11.0.2')
> local cuda_home = os.getenv('CUDA_HOME')
> setenv('THINGY', cuda_home)
> #-----------------------------
>
> That seems to work, so long as the cuda/11.0.2 module is already
> loaded when I load hello/1.0. That is, when cuda/11.0.2 was not
> loaded by depends_on().
>
> If the cuda/11.0.2 module is not loaded when hello/1.0 gets loaded,
> then upon unloading hello, I get
>
> Lmod Warning: Syntax error in file: /home/bennet/Lmod/hello/1.0.lua
> with command: setenv, one or more arguments are not strings.
>
> So, it seems that it might be unloading the module on which hello
> depends before unsetting the variables that hello sets, leading to the
> os.getenv('CUDA_HOME') not getting properly evaluated. Would it not
> be better to unset while the depended upon module was still active?
>
> This seems like it could be a bug.
>
> Thanks!
> Shelly
>
> Shelly Johnson
> Research Applications Specialist
> XSEDE Campus Champion
> Advanced Research Computing - TS
> University of Michigan
> _______________________________________________
> Lmod-users mailing list
> Lmo...@li...
> https://lists.sourceforge.net/lists/listinfo/lmod-users
> >> This message is from an external sender. Learn more about why this <<
> >> matters at https://links.utexas.edu/rtyclf. <<
>
--
Robert McLay, Ph.D.
Manager of Software Tools, HPC
mc...@ta...
|