2021年1月6日星期三

How to properly call a perl script from within an SBATCH script for SLURM submissions? Perl script is executed but no output is obtained

I received a perl script that apparently is called from an SBATCH script to be submitted as a job to a computer cluster managed by SLURM. The script is old and I am yet to become more familiar with perl. Additionally, the perl script is being used as wrapper to call an executable with mpiexec_mpt. But whenever I do sbatch sbatch_submission, the perl script is executed by the computer node but I don't obtain any output or execution of the system() method - or I do but I don't know where it is. I know perl is executed by SBATCH because I got an error that it couldn't find a module so I manually pointed perl to the library path using the -l flag as shown below. But after that I don't get any output. The SBATCH script and the perl script are below:

SBATCH SCRIPT

  1 #!/bin/bash    2 #SBATCH --job-name=job_submission    3 #SBATCH --output=output_perl.run    4 #SBATCH --error=error_perl.run    5 #SBATCH -n 2 # request 2 cores    6 #SBATCH --constraint=intel    7    8 # Load Needed Modules:    9 module load mpt   10   11 # Set-up environment for perl:   12    13    14   15 # Running perl script:   16 echo "Calling simple hello_world.c with perl (sbatch)"   17   18 perl input_perl.pl 1> perl_in.stdout 2> perl_in.stderr # edit after                                                              # suggestions   19 echo "Done with perl script (sbatch)"   20  

PERL INPUT

  1 #!/usr/bin/perl -w    2 use strict;    3 use warnings;    4 use diagnostics;    5 use List::MoreUtils qw(indexes); ## edit after suggestions    6 system("echo this is your hostname:");    7 system("hostname");    8 system("mpiexec_mpt -np 2 hello_world");    9 print "Done executing hello world! from within perl script!\n"  

OUTPUT FROM STDERR

  1 Can't locate List/MoreUtils.pm in @INC (@INC contains: /usr/lib64/perl5/vendor_perl/List /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /    usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at input_perl.pl line 5.      

Aside from the output above the output files: perl.output and output_perl.run are empty.

I suspect I am missing something regarding the applicability of the system() method in perl, as well as how to tell perl where to send it's output when working with slurm. I have also tried generating a .txt file with the perl script, but when I run it with SBATCH the .txt file is not generated. I have no issues running the perl_input.pl without using the SBATCH script as wrapper: e.g: perl perl_input.pl.

Additional info, the hello_world executable has been written in .c and I have tested it independently and it runs. It is a simple MPI program that lists ranks and size. I don't think that's the issue though.

Independently and running locally the perl and .c scripts run, it's when I use SBATCH that the issues arise.

I would appreciate it if you could give me any useful info or point me in the right direction, to figure this out! Thanks!

EDITS I followed the suggestions given and now I output the stderr from the perl execution but the module List::MoreUtils is not found. Even though when I run the perl script from the terminal, the script runs without issues and List::MoreUtils is loaded. I added PERL5LIB to my .bashrc:

export PERL5LIB=/usr/lib64/perl5/vendor_perl/List  

Also I did:

perl -e'print "$_\n" for @INC'  

And my output is:

/usr/lib64/perl5/vendor_perl/List  /usr/local/lib64/perl5  /usr/local/share/perl5  /usr/lib64/perl5/vendor_perl  /usr/share/perl5/vendor_perl  /usr/lib64/perl5  /usr/share/perl5  

For PERL5LIB

PERL5LIB=/foo perl -e'print "$_\n" for @INC'  

Output:

/foo  /usr/local/lib64/perl5  /usr/local/share/perl5  /usr/lib64/perl5/vendor_perl  /usr/share/perl5/vendor_perl  /usr/lib64/perl5  /usr/share/perl5  
https://stackoverflow.com/questions/65602693/how-to-properly-call-a-perl-script-from-within-an-sbatch-script-for-slurm-submis January 07, 2021 at 04:03AM

没有评论:

发表评论