julia并行问题

使用julia -p 10 .\test.jl 能运行代码得到结果,
但是改成julia -p 6 .\test48.jl 后会报错:
Running 8 processes
Unhandled Task ERROR: On worker 8:
UndefVarError: #cut_n not defined

using ProgressMeter
using Distributed
@everywhere using SharedArrays, LinearAlgebra

@everywhere function annihilation(n_max::Int64
    )::Tuple{Matrix{Float64}, Matrix{Float64}}
    a = diagm(1 => sqrt.(1:n_max-1))
    c = a'
    return a, c*a
end

@everywhere function ham(z::Int64, mu::Float64, t::Float64, 
    phi::Float64, n_max::Int64, u::Float64)::Matrix{Float64}
    a, n= annihilation(n_max)
    h0 = u/2 .* n * (n - diagm(ones(n_max))) - mu .* n
    h1 = -z .* t .* phi .* a
    h = h0 + h1 + h1'
    return h
end

@everywhere function cut_n(z::Int64, mu::Float64, t::Float64, psi::Float64)::Int64
    e_old = 1.0
    n_max = 0
    for i in 5:50
        h = ham(z, mu, t, psi, i, 1.0)
        eig, psi_t = eigen(h)
        if abs(eig[1] - e_old) < 1e-6
            break
        end
        e_old = eig[1]
        n_max = i
    end
    return n_max
end

function Iteration(z::Int64, mu, t
    )::Matrix{Float64}

    addprocs(8 - nprocs())
    println("Running ",nprocs()," processes")
    n_max = SharedArray(zeros(length(t), length(mu)))
    @sync @distributed for j in 1:length(t)
    # for j in 1:length(t)
        mut = mu[j]
        for k in 1:length(mu)
            tt = t[k]
            n_max[j, k] = cut_n(z, mut, tt, 0.1)
        end
    end
    return n_max
end

z = 1
step = 10
t = range(0, stop=0.2, length=step)
mu = range(0, stop=3, length=step)
x = Iteration(z, mu, t)
println(x)

后面的进程是通过addprocs(8 - nprocs())加上去的,没有被函数定义时的@everywhere涵盖到