【发布时间】:2017-10-12 20:38:34
【问题描述】:
我有一个 python 提交脚本,我使用sbatch 使用slurm 运行:
sbatch batch.py
当我这样做时,事情不能正常工作,因为我假设batch.py 进程没有继承正确的环境变量。因此,不是从完成sbatch 命令的地方运行batch.py,而是从其他地方运行(/ 我相信)。我已经设法通过用 bash 脚本包装 python 脚本来解决这个问题:
#!/usr/bin/env bash
cd path/to/scripts
python script.py
这种临时的破解方式似乎有效,但它似乎完全避免了这个问题,而不是解决它。有人知道如何以更好的方式解决此问题吗?
例如,我知道在 docker 中存在 -w 或 -WORKDIR,以便 docker 容器知道它应该在哪里。我想知道 slurm 是否存在类似的东西。
【问题讨论】:
-
也许:
--workdir=<directory> Set the working directory of the batch script to directory before it is executed. The path can be specified as full path or relative path to the directory where the command is executed. -
你看过 sbatch --get-user-env 吗?这可能是你需要的。否则,如果仅在当前终端中添加环境变量,您可能需要使用 sbatch --export 显式传递您需要的变量。
-
不确定给
--get-user-env看是什么意思,你的意思是看标志还是环境变量?