# Pennylane-qulacs number of cores

**URL:** <https://discuss.pennylane.ai/t/pennylane-qulacs-number-of-cores/447>\
**Category:** PennyLane Plugins\
**Created:** [July 2, 2020, 4:48am UTC](https://discuss.pennylane.ai/t/pennylane-qulacs-number-of-cores/447 "2020-07-02T04:48:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cnktysz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/cnktysz/32/321_2.png) [@cnktysz](https://discuss.pennylane.ai/u/cnktysz)\
**Post date:** [July 2, 2020, 4:48am UTC](https://discuss.pennylane.ai/t/pennylane-qulacs-number-of-cores/447/1 "2020-07-02T04:48:07Z")

</div>

I’m puzzled with how can I set the number of cores to be used by pennylane-qulacs. When I run it in multicore mode, it consumes all the available cores, I hope there is a way to specify how many cores are allowed. I couldn’t manage to find a solution by looking at the docs. Thanks.

---

<div class="post-metadata">

**Author:** ![theodor](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/theodor/32/178_2.png) [@theodor](https://discuss.pennylane.ai/u/theodor)\
**Post date:** [July 2, 2020, 3:22pm UTC](https://discuss.pennylane.ai/t/pennylane-qulacs-number-of-cores/447/2 "2020-07-02T15:22:30Z")

</div>

Hi @cnktysz. Welcome to the Discussion Forum. 🎉

I believe Qulacs is using OpenMP for parallelization, so it should be possible to change the number of threads used by setting the [environment variable `OMP_NUM_THREADS`](https://www.openmp.org/spec-html/5.0/openmpse50.html) to the specific number of threads that you want to use (e.g. `export OMP_NUM_THREADS=4` for using 4 threads in a Bash shell). Setting `OMP_NUM_THREADS=1` practically turns off multi-threaded use, while deleting the variable all-together sets it back to the default setting.

Unfortunately, as far as I know, there is currently no other, straight-forward way of changing the number of threads/cores that Qulacs uses for its simulations.

---

<div class="post-metadata">

**Author:** ![cnktysz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/cnktysz/32/321_2.png) [@cnktysz](https://discuss.pennylane.ai/u/cnktysz)\
**Post date:** [July 5, 2020, 11:48am UTC](https://discuss.pennylane.ai/t/pennylane-qulacs-number-of-cores/447/3 "2020-07-05T11:48:11Z")

</div>

Hi @theodor, setting the OMP\_NUM\_THREADS did the trick. Now, I am able to choose the amount of threads/cores I want to use. Thank you.

---

<div class="post-metadata">

**Author:** ![theodor](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/theodor/32/178_2.png) [@theodor](https://discuss.pennylane.ai/u/theodor)\
**Post date:** [July 6, 2020, 2:43pm UTC](https://discuss.pennylane.ai/t/pennylane-qulacs-number-of-cores/447/4 "2020-07-06T14:43:20Z")

</div>

That’s great @cnktysz! I’m glad it helped.

Feel free to ask any more questions that might pop up in the future.
