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

**URL:** https://discourse.julialang.org/t/how-do-i-use-plots-with-mpiclustermanagers-in-only-workers-mode/64286
**Category:** Julia at Scale
**Created:** [July 8, 2021, 5:17pm UTC](https://discourse.julialang.org/t/how-do-i-use-plots-with-mpiclustermanagers-in-only-workers-mode/64286 "2021-07-08T17:17:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![giancarloantonucci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giancarloantonucci/32/202551_2.png) [@giancarloantonucci](https://discourse.julialang.org/u/giancarloantonucci)
#### Post date: [July 8, 2021, 5:17pm UTC](https://discourse.julialang.org/t/how-do-i-use-plots-with-mpiclustermanagers-in-only-workers-mode/64286/1 "2021-07-08T17:17:50Z")

</div>

I find that `@mpi_do` from [MPIClusterManagers.jl](https://github.com/JuliaParallel/MPIClusterManagers.jl) is great with Jupiter notebooks. However, I’m not able to plot anything from within `@mpi_do`:

```julia
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](https://github.com/JuliaParallel/MPIClusterManagers.jl/issues/20), but I’m not sure. Any workaround?

---

<div class="post-metadata">

### Author: ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)
#### Post date: [July 19, 2021, 10:04pm UTC](https://discourse.julialang.org/t/how-do-i-use-plots-with-mpiclustermanagers-in-only-workers-mode/64286/2 "2021-07-19T22:04:00Z")

</div>

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

```julia
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](https://github.com/simonbyrne/SPMD.jl)

---

<div class="post-metadata">

### Author: ![giancarloantonucci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giancarloantonucci/32/202551_2.png) [@giancarloantonucci](https://discourse.julialang.org/u/giancarloantonucci)
#### Post date: [July 19, 2021, 10:30pm UTC](https://discourse.julialang.org/t/how-do-i-use-plots-with-mpiclustermanagers-in-only-workers-mode/64286/3 "2021-07-19T22:30:12Z")

</div>

Thanks, Simon. And that package is great!
