【问题标题】:How does one use python as a submission script using the PBS scheduler?如何使用 PBS 调度程序将 python 用作提交脚本?
【发布时间】:2020-09-14 19:58:37
【问题描述】:

我过去使用 python 作为我的提交脚本,而不是 bash 等。在 slurm conder 中,我通常在顶部指示编译器的路径。我在qsub 中尝试过,但没有成功。知道如何使它工作吗?

代码:

#/homes/miranda9/.conda/envs/myenv/lib/python3.7
#PBS -V
#PBS -M me@gmail.com
#PBS -m abe

import sys

for p in sys.path:
    print(p)

然后我做了:

qsub test_qsub.py

错误信息:

$ cat test_qsub.py.e381299 
/homes/miranda9/.profile: line 2: /opt/intel/compilers_and_libraries_2017/linux/mpi/intel64/bin/mpivars.sh: No such file or directory
/homes/miranda9/.profile: line 3: /opt/intel/compilers_and_libraries_2017/linux/bin/compilervars.sh: No such file or directory
import: unable to open X server `' @ error/import.c/ImportImageCommand/369.
/var/spool/pbs/mom_priv/jobs/381299.iam-pbs.SC: line 9: syntax error near unexpected token `print'
/var/spool/pbs/mom_priv/jobs/381299.iam-pbs.SC: line 9: `    print(p)'


在我添加 ! 并在顶部创建 '#!/homes/miranda9/.conda/envs/automl-meta-learning/lib/python3.7' 后,我收到了一个新错误:

$ cat test_qsub.py.e381301 
/homes/miranda9/.profile: line 2: /opt/intel/compilers_and_libraries_2017/linux/mpi/intel64/bin/mpivars.sh: No such file or directory
/homes/miranda9/.profile: line 3: /opt/intel/compilers_and_libraries_2017/linux/bin/compilervars.sh: No such file or directory
-bash: /var/spool/pbs/mom_priv/jobs/381301.iam-pbs.SC: /homes/miranda9/.conda/envs/automl-meta-learning/lib/python3.7: bad interpreter: Permission denied

交叉发布:

【问题讨论】:

    标签: pbs


    【解决方案1】:

    首先不要忘记顶部的!

    诀窍是找出 python 的二进制文件在哪里(例如在您的 conda 环境中)并在顶部告诉 PBS 以获取您的提交脚本。我尝试使用sys.path,但这会导致指向 PBS 无法使用的文件夹的路径。我必须找出sys.executable 才能找到它。然后我就把它放在最上面。

    找到它的演示会话:

    $ python
    Python 3.7.7 (default, Mar 26 2020, 15:48:22) 
    [GCC 7.3.0] :: Anaconda, Inc. on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.executable
    '/homes/miranda9/.conda/envs/myenv/bin/python'
    

    然后用感叹号正确放置:

    #!/homes/miranda9/.conda/envs/YOURENV/bin/python
    #PBS -V
    #PBS -M youremail@gmail.com
    #PBS -m abe
    #PBS -lselect=1:ncpus=112
    
    import sys
    import os
    
    for p in sys.path:
        print(p)
    
    print(os.environ)
    

    现在可以使用了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      • 2012-08-24
      • 1970-01-01
      相关资源
      最近更新 更多