How do I use Plots with MPIClusterManagers in "only workers" mode?

I find that @mpi_do from MPIClusterManagers.jl is great with Jupiter notebooks. However, I’m not able to plot anything from within @mpi_do:

using MPIClusterManagers
using Distributed
manager = MPIManager(np = 4)
addprocs(manager)

@mpi_do manager begin
    using MPI
    using Plots

    comm = MPI.COMM_WORLD
    rank = MPI.Comm_rank(comm)

    data = 1
    G = MPI.Gather(data, 0, comm)
    if rank == 0
        plot(G)
    end
end

I suspect this is related to this issue, but I’m not sure. Any workaround?

At the moment, your best option for now is to do the plotting on the main process (pid 1). Something like this should work:

G = remotecall_fetch(eval, 2, :G) # pid 2 == MPI rank 0
plot(G)

I’m trying to build some tools that will make this sort of thing easier: https://github.com/simonbyrne/SPMD.jl

Thanks, Simon. And that package is great!

1 Like