# pvbatch on Windows uses many CPU cores by default?

**URL:** https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111
**Category:** ParaView Support
**Tags:** mpi, python
**Created:** [February 5, 2025, 2:33pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111 "2025-02-05T14:33:24Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![s1291](https://discourse.paraview.org/user_avatar/discourse.paraview.org/s1291/32/15950_2.png) [@s1291](https://discourse.paraview.org/u/s1291)
#### Post date: [February 5, 2025, 2:33pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/1 "2025-02-05T14:33:24Z")

</div>

Hi,  
I have ParaView 5.13.2 (I downloaded `ParaView-5.13.2-MPI-Windows-Python3.10-msvc2017-AMD64.msi` from the official website) installed on Windows 11.

When I try to use pvbatch to render an orbit around a box (.py state file attached here:  
[orbiting\_around\_a\_box.py](https://discourse.paraview.org/uploads/short-url/eU5ZSpQUyMyj9QZ4kBWcqVxFOxJ.py) (7.4 KB)):

```sh
pvbatch orbiting_around_a_box.py

```

I see that pvbatch is using almost all CPU core as shown below:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/5/529efb96056176997cbb0a9f9d42abaab43200eb.png)

### Question:

How do I tell pvbatch to use only some specific number of processes?

I have tried with the two versions of mpiexec (see below the output of `where.exe` command) with different `-np X` where `X` is an integer between [2, 10], but on the tasks manager as shown in the screenshot above, the CPU usage always looks the same.

```auto
# for mpiexec command I tried: mpiexec, the first absolute path of mpiexec, and the second absolute path as well
# X is an integer
mpiexec -np X pvbatch orbiting_around_a_box.py

```

## Other relevant information:

```auto
❯ where.exe pvbatch
C:\Program Files\ParaView 5.13.2\bin\pvbatch.exe

 where.exe mpiexec
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\intel64\bin\mpiexec.exe
C:\Program Files\Microsoft MPI\Bin\mpiexec.exe

```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 5, 2025, 3:14pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/2 "2025-02-05T15:14:46Z")

</div>

> [@s1291](#):
>
> I have tried with the two versions of mpiexe

Its not about MPI, its about multithreading.

You should be able to control it by positioning the correct env var: `VTK_SMP_MAX_THREADS`.  
More info here: [https://www.kitware.com/vtk-shared-memory-parallelism-tools-2021-updates/](https://www.kitware.com/vtk-shared-memory-parallelism-tools-2021-updates/)

---

<div class="post-metadata">

### Author: ![s1291](https://discourse.paraview.org/user_avatar/discourse.paraview.org/s1291/32/15950_2.png) [@s1291](https://discourse.paraview.org/u/s1291)
#### Post date: [February 5, 2025, 3:17pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/3 "2025-02-05T15:17:33Z")

</div>

Could you please elaborate? I don’t understand your reply.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 5, 2025, 3:21pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/4 "2025-02-05T15:21:18Z")

</div>

You say that pvbatch is using all your CPU cores even when you run it without mpi, it means that its not mpi using all your core, but its the native multithreading support of VTK that is using all your cores.

The number of cores used by the native multithreading support can be controlled using the environment variable, `VTK_SMP_MAX_THREADS`.

---

<div class="post-metadata">

### Author: ![s1291](https://discourse.paraview.org/user_avatar/discourse.paraview.org/s1291/32/15950_2.png) [@s1291](https://discourse.paraview.org/u/s1291)
#### Post date: [February 5, 2025, 3:25pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/5 "2025-02-05T15:25:03Z")

</div>

Thanks for the clarification. But this is still confusing because the documentation ([7. Remote and parallel visualization — ParaView Documentation 5.12.0 documentation](https://docs.paraview.org/en/latest/ReferenceManual/parallelDataVisualization.html#using-pvbatch)) clearly states that to run pvbatch in parallel you can use mpi.

So I think my question still holds: I don’t want to use multithreading or whatever, just want to use MPI with many processes to run pvbatch as linked in the documentation.

Thanks

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 5, 2025, 3:29pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/6 "2025-02-05T15:29:28Z")

</div>

> [@s1291](#):
>
> clearly states that to run pvbatch in parallel you can use mpi.

Of course you can, but that is not your question.

> I don’t want to use multithreading or whatever, just want to use MPI with many processes to run pvbatch as linked in the documentation.

Sure, use it as the documentation states, with `mpirun` or `mpiexec`.

But it will still uses all your cores because of multithreading.

---

<div class="post-metadata">

### Author: ![s1291](https://discourse.paraview.org/user_avatar/discourse.paraview.org/s1291/32/15950_2.png) [@s1291](https://discourse.paraview.org/u/s1291)
#### Post date: [February 5, 2025, 3:34pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/7 "2025-02-05T15:34:23Z")

</div>

Sorry, But this is so confusing. What is this SMP thing? Why do I need it? What has this to do with ParaView? Why it is not documented? … many questions.

I do believe that this deserve some explanation, or some context (I tried to read the blog post you linked, but it is too technical and not clear).

Thank you

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 5, 2025, 3:38pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/8 "2025-02-05T15:38:35Z")

</div>

> [@s1291](#):
>
> What is this SMP thing?

symmetric multiprocessing, aka multithreading

> Why do I need it? What has this to do with ParaView?

Its a feature of VTK, which is the engine of ParaView

> Why it is not documented?

[https://www.paraview.org/ParaView/index.php/Multi\_Core\_Processing#Threading\_Methods](https://www.paraview.org/ParaView/index.php/Multi_Core_Processing#Threading_Methods)

[https://www.kitware.com/paraview-hpc-scalability-guide/](https://www.kitware.com/paraview-hpc-scalability-guide/)

But I agree, this doc should be ported to the ParaView guide and updated.

---

<div class="post-metadata">

### Author: ![s1291](https://discourse.paraview.org/user_avatar/discourse.paraview.org/s1291/32/15950_2.png) [@s1291](https://discourse.paraview.org/u/s1291)
#### Post date: [February 5, 2025, 3:45pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/9 "2025-02-05T15:45:11Z")

</div>

@Kenneth_Moreland: I do really appreciate your input here.  
Thank you very much.

---

<div class="post-metadata">

### Author: ![s1291](https://discourse.paraview.org/user_avatar/discourse.paraview.org/s1291/32/15950_2.png) [@s1291](https://discourse.paraview.org/u/s1291)
#### Post date: [February 5, 2025, 3:55pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/11 "2025-02-05T15:55:01Z")

</div>

I created an environment variable on Windows:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/2/2e671293315c2e5e51b27d9a177631f842cb5c3c.png)

I restarted Windows, and opened a new terminal (Powershell) and confirmed this env variable is correctly set:

```auto
❯ $env:VTK_SMP_MAX_THREADS
1

```

**The problem still persist**. When I run pvbatch it uses all the CPUs as shown in the first screenshot from my first post

 ![](https://discourse.paraview.org/uploads/default/original/2X/5/529efb96056176997cbb0a9f9d42abaab43200eb.png)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 5, 2025, 4:11pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/12 "2025-02-05T16:11:46Z")

</div>

This is unexpected, I would have expected this to work.

Edit: This is caused by TBB that ignore this env var. You should be able to set `VTK_SMP_BACKEND_IN_USE` to `Sequential` instead.

---

<div class="post-metadata">

### Author: ![s1291](https://discourse.paraview.org/user_avatar/discourse.paraview.org/s1291/32/15950_2.png) [@s1291](https://discourse.paraview.org/u/s1291)
#### Post date: [February 5, 2025, 4:33pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/13 "2025-02-05T16:33:21Z")

</div>

I added another environment variable as shown below:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/6/6f40be882ee1ddd6bdafe3b51e1bed1e164ab641.png)

I restarted Windows, but that has no effect. 🤔

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 5, 2025, 4:34pm UTC](https://discourse.paraview.org/t/pvbatch-on-windows-uses-many-cpu-cores-by-default/16111/14 "2025-02-05T16:34:15Z")

</div>

Then I’m afraid I have no idea and more investigation is needed.
