I had previously been using a cluster with SLURM to run parallel computations with ParallelTable. However, it has randomly stopped working and I now receive the error:
LinkOpen::string: String expected at position 1 in
LinkOpen[StringRiffle[{/apps/mathematica/13.2.1/Executables/wolfram, -noinit, -subkernel, -wstp}],
LinkProtocol -> Automatic, LinkHost -> ,
LinkMode -> Launch, LinkOptions -> 256].
Followed by a LinkObject::linkv error, then finally
Timeout for subkernels. Received only 0 of 8 connections.
I am submitting with the following:
#!/bin/bash
#
#SBATCH --job-name=submit
#SBATCH -p Partition # partition
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task 8
#SBATCH -o slurm.%N.%j.out # STDOUT
#SBATCH -e slurm.%N.%j.err # STDERR
wolframscript -file code.wl
and code.wl contains:
CloseKernels[];
LaunchKernels[];
result = Table[i^2, {i, 1, 10}];
Print["Results: ", result];
CloseKernels[];
Quit[];
Oddly enough, the system admin has no trouble when running this code so it seems linked with my login.
Any help would be appreciated.
Edit I:
So, if I use math -script code.wl then the problem disappears.
However, I was using wolframscript because this was the only way I could load in command line arguments. In other words if I try
math -script code.wl 4
then Mathematica returns {} if I include $ScriptCommandLine in the code. I am not sure how I reconcile these two issues.
Edit II:
I've discovered that if I use
MYARG=4 math -script code.wl
then I can read in this value using
envVar = Environment["MYARG"];
Print["MYARG = ", envVar];
While this gets things functionally working again, it feels more like a work around than a solution.
#SBATCH --cpus-per-task 8shouldn't this be#SBATCH --cpus-per-task= 8with an equal to sign? $\endgroup$