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: Shelly J. <js...@um...> - 2020-08-27 01:12:07
|
Thanks for your responses!
I did find a way to get around the error, and also prevent warnings in the
case of "module help hello", which was another related issue. To get
around the help issue, I used an if statement, as:
if (isloaded("cuda") then
setenv('THINGY", cuda_home))
end
To fix the problem on unloading, I added the following:
execute {cmd='unset THINGY', modeA = {'unload'}}
I don't believe there are any remaining issues with that approach (at least
none that I've encountered yet), but definitely Robert's suggestion (*or
"")* is *much* simpler to implement! Thanks so much for your help,
Robert, and thanks also to Maxime, for your suggestion. I hadn't thought
of pushenv, but it seems like one would end up with the same non-string
warning.
Best,
Shelly
Shelly Johnson
Research Applications Specialist
XSEDE Campus Champion
Advanced Research Computing - TS
University of Michigan
On Wed, Aug 26, 2020 at 6:48 PM Robert McLay <mc...@ta...> wrote:
> Yes, but you still need the os.getenv("FOO") or "" bit or you'll get the
> error about having a non-string argument.
>
> Robert.
>
>
> On Wed, Aug 26, 2020 at 5:44 PM Maxime Boissonneault <
> max...@ca...> wrote:
>
>> I would add to that, since I encountered this very issue recently, that
>> "pushenv" can be used in this situation.
>>
>> Best,
>>
>> Maxime
>> Le 20-08-26 à 18:36, Robert McLay a écrit :
>>
>> 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...
>>
>>
>>
>> _______________________________________________
>> Lmod-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/lmod-users
>>
>>
>
> --
> Robert McLay, Ph.D.
> Manager of Software Tools, HPC
> mc...@ta...
>
>
|