Julia Distributed,出现冗余迭代

Julia Distributed, redundant iterations appearing

我运行

mpiexec -n $nprocs julia --project myfile.jl 

在集群上,其中 myfile.jl 具有以下形式

using Distributed; using Dates; using JLD2;  using LaTeXStrings
@everywhere begin
using SharedArrays; using QuantumOptics; using LinearAlgebra; using Plots; using Statistics; using DifferentialEquations; using StaticArrays
#Defining some other functions and SharedArrays to be used later e.g.
MySharedArray=SharedArray{SVector{Nt,Float64}}(Np,Np)
end
@sync @distributed for pp in 1:Np^2
  for jj in 1:Nj 
  #do some stuff with local variables
  for tt in 1:Nt
  #do some stuff with local variables
  end
  end
  MySharedArray[pp]=... #using linear indexing
  println("$pp finished")
end

timestr=Dates.format(Dates.now(), "yyyy-mm-dd-HH:MM:SS")
filename="MyName"*timestr

@save filename*".jld2"

#later on, some other small stuff like making and saving a figure. (This does give an error "no method matching heatmap_edges(::Surface{Array{Float64,2}}, ::Symbol)" but I think that this is a technical thing about Plots so not very related to the bigger issue here)

但是,在查看输出时,有几个问题让我断定出了问题

编辑:我还可以添加两件事

$nprocs在pbs脚本中通过

获取
#PBS -l select=1:ncpus=32:mpiprocs=32
nprocs= `cat $PBS_NODEFILE|wc -l`

正如 adamslc 在 Julia 话语中所指出的,在集群上使用 Julia 的正确方法是

  • 使用作业脚本中的一个核心启动会话,在 Julia 脚本本身中使用 addprocs() 添加更多
  • 使用更专业的 Julia 包

https://discourse.julialang.org/t/julia-distributed-redundant-iterations-appearing/57682/3