# Flux parallel execution

**URL:** https://discourse.julialang.org/t/flux-parallel-execution/12931
**Category:** Machine Learning
**Tags:** flux
**Created:** [August 6, 2018, 9:27am UTC](https://discourse.julialang.org/t/flux-parallel-execution/12931 "2018-08-06T09:27:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kkmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kkmann/32/1727_2.png) [@kkmann](https://discourse.julialang.org/u/kkmann)
#### Post date: [August 6, 2018, 9:27am UTC](https://discourse.julialang.org/t/flux-parallel-execution/12931/1 "2018-08-06T09:27:11Z")

</div>

Hi,

so, this might be a very dumb question but how do I train model in flux.jl in parallel on my cpu?

---

<div class="post-metadata">

### Author: ![groot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/groot/32/13081_2.png) [@groot](https://discourse.julialang.org/u/groot)
#### Post date: [December 10, 2018, 12:59am UTC](https://discourse.julialang.org/t/flux-parallel-execution/12931/2 "2018-12-10T00:59:14Z")

</div>

Same question. MNIST demo in model zoo runs on a single core only. I am even surprised that Flux doesn’t run on multiple cores by default. Isn’t it mainly matrix multiplication which is paralleled by Julia?

Edit:

It does supported by julia. set JULIA\_NUM\_THREADS env variable will do the trick  
I use following before running julia

```julia
export JULIA_NUM_THREADS=6

```

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [December 10, 2018, 5:33am UTC](https://discourse.julialang.org/t/flux-parallel-execution/12931/3 "2018-12-10T05:33:04Z")

</div>

I have implemented a manual model-parallel computations, where each model is evaluated on a single thread and on the end their gradient is averaged. It is faster in some cases. But I believe that the overall goal should be to have underlying routines multi-threaded.

The implementation is here.

> <https://github.com/pevnak/FluxExtensions.jl/blob/master/src/learn.jl>

---

<div class="post-metadata">

### Author: ![stegua](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@stegua](https://discourse.julialang.org/u/stegua)
#### Post date: [March 29, 2019, 3:48pm UTC](https://discourse.julialang.org/t/flux-parallel-execution/12931/4 "2019-03-29T15:48:33Z")

</div>

In Windows you have to set the enviroment variable using the Control Panel.
