Hi,
I’m trying to run a script on a cluster for different input parameters. Instead of submitting scripts with hard-coded values, I’m trying to use command-line arguments. My code works fine when the values are hard-coded, but when I use command line arguments the code works for a while and runs out of memory. Any suggestion on what the issue could be?
Hard-coded script:
include("/mcmc_fits/mcmc_bat_julia.jl")
global i=1
while i<=500
global i
nominal = (offset1=99., lambda =1.4066, resolution=5.)
try
energy_range = (low=60. ,high=500., )
posterior, arr = prepare_posterior(nominal,energy_range,5000)
result = bat_sample(posterior,MCMCSampling(mcalg = MetropolisHastings(), nsteps = 10^4, nchains = 8))
file_address = "run_5k_1resolution_"*string(i)*".h5"
bat_write(file_address, result.result)
h5open("test.h5", "cw") do file
write(file, "run_"*string(i), arr)
end
i+=1
catch e
println(e)
end
end
The one that uses ARGS to get command line inputs:
include("/mcmc_fits/mcmc_bat_julia.jl")
function make_data(str_N_events, N_data_sets)
N_events = parse(Int,str_N_events)
i=1
while i<=N_data_sets
nominal = (offset1=99., lambda =1.4066, resolution=5.)
try
energy_range = (low=60. ,high=500., )
event_count = rand(Distributions.Poisson(N_events::Integer))
posterior, arr = prepare_posterior(nominal, energy_range, event_count)
result = bat_sample(posterior,MCMCSampling(mcalg = MetropolisHastings(), nsteps = 10^4, nchains = 8))
file_address = "run_"*string(N_events::Integer)*"_1resolution_"*string(i)*".h5"
bat_write(file_address, result.result)
h5open("test.h5", "cw") do file
write(file, "run_"*string(i), arr)
end
i+=1
catch e
println(e)
end
thr=0.1
rand(Distributions.Uniform(0,1)) < thr && GC.gc();
end
end
make_data(ARGS[1],500)
Submission scripts:
#!/bin/bash
#SBATCH --time=11:59:00
#SBATCH --cpus-per-task=8
#SBATCH --mem-per-cpu=1024MB
export JULIA_NUM_THREADS=$SLURM_CPUS_PER_TASK
module load StdEnv/2020 julia/1.8.5
julia mcmc_set_count_1resolution_constrained.jl 5000