【问题标题】:slurm sbatch standard IO redirectionslurm sbatch 标准 IO 重定向
【发布时间】:2017-08-17 03:27:04
【问题描述】:

我需要运行一个需要从标准 io 读取的并行程序。如何在 slurm sbatch 中将文件传递给它?我尝试了 -input 命令但没有用。这是我的批处理脚本

    #!/bin/sh

    #SBATCH -p main
    #SBATCH --nodes=1
    #SBATCH --ntasks=1
    #SBATCH --time 0-23:59:59
    #SBATCH --reservation=VR0188
    #SBATCH --input /vlsci/VR****/phillis/input.txt


    # Run info and srun job launch

    echo 'start work--------------------'

    srun helloworld

这是我的测试代码:

    #include <stdio.h>
    #include <omp.h>

     main(int argc, char *argv[]) {

     int nthreads, tid;

     #pragma omp parallel private(tid)
       {
       /* Obtain and print thread id */
       tid = omp_get_thread_num();
       printf("Hello World from thread = %d\n", tid);

       }  /* All threads join master thread and terminate */

       int a;
       scanf("%d", &a);
       printf("file input read as %d\n",a);
     }

这个程序可以成功提交运行,但是scanf结果总是:

     file input read as 0

【问题讨论】:

  • 你试过srun helloworld &lt; input.txt还是cat input.txt | srun helloworld

标签: c parallel-processing openmp slurm


【解决方案1】:

sbatch 中的--input 选项会将文件传输到提交脚本的标准输入,而不是您的程序的标准输入。你有三个行动方案:

  1. --input 参数移至srun 调用:srun --input /vlsci/VR****/phillis/input.txt helloworld

  2. 将提交脚本的标准输入传递给srun,然后再传递给helloworldcat | srun helloworld

  3. 忽略--input 参数并明确使用重定向:srun helloworld &lt; /vlsci/VR****/phillis/input.txt

【讨论】:

  • 我尝试了所有这些但得到相同的错误结果:“slurmstepd: error: execve(): helloworld: Permission denied”
  • 没关系,它有效;只需要将 scanf 放在并行块之外;非常感谢!
猜你喜欢
  • 2016-05-18
  • 2017-10-01
  • 1970-01-01
  • 2019-04-03
  • 2019-07-07
  • 2021-01-19
  • 1970-01-01
  • 1970-01-01
  • 2014-08-21
相关资源
最近更新 更多