# Does anyone have a progress bar for pmap?

**URL:** <https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 17, 2018, 1:02am UTC](https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729 "2018-06-17T01:02:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [June 17, 2018, 1:02am UTC](https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729/1 "2018-06-17T01:02:01Z")

</div>

I guess it’s been a while since anyone’s asked it, but does somebody have a working progress bar for `pmap` sitting around?

* * *

Related to:

- [Displaying Parallel Progress Bars - #5 by adamslc](https://discourse.julialang.org/t/displaying-parallel-progress-bars/4148/5)
- [Way to add progress bar to map function?](https://discourse.julialang.org/t/way-to-add-progress-bar-to-map-function/6426)
- [A few ProgressMeter.jl Issues](https://github.com/timholy/ProgressMeter.jl/issues)

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [June 17, 2018, 2:07am UTC](https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729/2 "2018-06-17T02:07:36Z")

</div>

Best solution I could find is @slundberg’s package:

[https://github.com/slundberg/PmapProgressMeter.jl](https://github.com/slundberg/PmapProgressMeter.jl)

---

<div class="post-metadata">

**Author:** ![chelseas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chelseas/32/12148_2.png) [@chelseas](https://discourse.julialang.org/u/chelseas)\
**Post date:** [January 4, 2022, 3:19am UTC](https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729/3 "2022-01-04T03:19:57Z")

</div>

Anyone thought of breathing life into this again? Would be great to have.

---

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [January 4, 2022, 3:59am UTC](https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729/4 "2022-01-04T03:59:34Z")

</div>

ProgressMeter.jl has this now. You just need

```julia
@showprogress pmap(...)

```

For even more control, you could use the `RemoteProgressWrapper` I have in `MuseInference.jl` (registered), which wraps any arbitrary `AbstractProgress` and lets you call `next!` etc… on it from any worker. The code is [here](https://github.com/marius311/MuseInference.jl/blob/47348c25efbacb7c7f1ceaee4c707c4d7a990145/src/progress.jl) and an example of using it is [here](https://github.com/marius311/MuseInference.jl/blob/47348c25efbacb7c7f1ceaee4c707c4d7a990145/src/muse.jl#L302-L312). Been meaning to do a PR into ProgressMeter.jl just haven’t had the time.

---

<div class="post-metadata">

**Author:** ![Robert\_Moss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robert_moss/32/48004_2.png) [@Robert\_Moss](https://discourse.julialang.org/u/Robert_Moss)\
**Post date:** [March 3, 2022, 12:20am UTC](https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729/5 "2022-03-03T00:20:43Z")

</div>

Adapted from the ProgressMeter.jl README ([https://github.com/timholy/ProgressMeter.jl#tips-for-parallel-programming](https://github.com/timholy/ProgressMeter.jl#tips-for-parallel-programming)), here’s an example of using a progress bar with `pmap` where each pmapped element has its own batch of jobs (i.e., its own for-loop).

```julia
# n = length of `batches` * number of jobs per batch
progress = Progress(n)
channel = RemoteChannel(()->Channel{Bool}(), 1)

@async while take!(channel)
    next!(progress)
end

pmap(batch->begin
        for i in batch
            # ... some long computation here ...
            put!(channel, true) # trigger progress bar update
        end
    end, batches)

put!(channel, false) # tell printing task to finish

```

This is useful if you want to get progress updates from _each_ completion of your “long computation”, rather than just progress updates over each element you’ve pmapped.
