1

I am trying to get a very basic job array script working using Slurm job scheduler on a HPC. I am getting the error:

slurmstepd: error: execve(): Rscript: No such file or directory

This is similar to this but I am not using any export commands so this isn't the cause here. Some sources say it could be something to do with creating these scripts in Windows so the line ends will not work for Unix. Could this be the issue? If so how can I check for this?

My shell script:

#!/bin/bash

# Example of running R script with a job array

#SBATCH --nodes=1
#SBATCH --array=1-10                    # how many tasks in the array
#SBATCH --ntasks-per-node=10
#SBATCH -o hello-%j-%a.txt
#SBATCH --mail-user=user@email.address

# Load software
module load R/4.0.0-foss-2020a

# Run R script with a command line argument
srun Rscript hello.R $SLURM_ARRAY_TASK_ID

The script -hello.R is:

#!/usr/bin/env 
# Rscript

# accept command line arguments and save them in a list called args
args = commandArgs(trailingOnly=TRUE)

# print task number
print(paste0('Hello! I am a task number: ', args[1]))
TomCLewis
  • 145
  • 2
  • 10

1 Answers1

0

Thanks to some offline help I have got an answer to my question. Seems I didn't need to use srun in the shell script and needed to include Rscript in the shebang line in hello.R

Shell script is:

#!/bin/bash

# Example of running R script with a job array

#SBATCH --nodes=1
#SBATCH --array=1-10                    # how many tasks in the array
#SBATCH --ntasks-per-node=10
#SBATCH -o hello-%j-%a.txt
#SBATCH --mail-user=tclewis1@sheffield.ac.uk

# Load software
module load R/4.0.0-foss-2020a

# Run R script with a command line argument
Rscript hello.R $SLURM_ARRAY_TASK_ID

And hello.R is now:

#!/usr/bin/env/Rscript

# accept command line arguments and save them in a list called args
args = commandArgs(trailingOnly=TRUE)

# print task number
print(paste0('Hello! I am a task number: ', args[1]))
TomCLewis
  • 145
  • 2
  • 10