question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

settings.num_cpus = 1 does not work

See original GitHub issue

I am distributing some qutip code to several cores. I want to enforce that qutip only uses one core per job with qutip.settings.num_cpus=1, but it is not working, the processes still take all the processors of my machine, so that if I have N cores, the multiprocessing ends up using N*N threads, slowing things down a lot! How can I force qutip to use only 1 core? Currently loading like this:

from qutip import create, destroy, Qobj, expect, tensor, qeye, fidelity, basis, variance, settings
from pathos.multiprocessing import ProcessingPool

settings.num_cpus = 1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Ericgigcommented, Feb 8, 2020

This parallelism does not come from qutip but scipy: coherent use scipy.sparse.linalg.expm which run in parallel for big matrix. This can be fixed with enviroment variable like$ export OPENBLAS_NUM_THREADS=1 in bash or os.environ["OPENBLAS_NUM_THREADS"] = "1" in python, but there are a few possibilities:

OMP_NUM_THREADS: openmp,
OPENBLAS_NUM_THREADS: openblas,
MKL_NUM_THREADS: mkl,
VECLIB_MAXIMUM_THREADS: accelerate,
NUMEXPR_NUM_THREADS: numexpr

See https://stackoverflow.com/questions/30791550/limit-number-of-threads-in-numpy

1reaction
nathanshammahcommented, Feb 6, 2020

I remember that @fminga had a similar necessity while exploiting qutip.parallel on a cluster (the RAM or SWAP were clogging the cluster) and I think he solved it by enforcing the num_cpus in the parfor. I don’t know if this would work for your case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I cant see any other cores but only 1 in msconfig boot advanced
I have amd ryzen 5 3550h with 8 cores. But my task manager is not showing that. I can see how many cores...
Read more >
Setting num_thread = 1 does not work on Windows #4447
Hi there, when setting num_threads = 1, on my linux machine CPU usage dropped from 70% to 10%, however, it didn't change CPU...
Read more >
How To Enable All Cores in Windows - Alphr
Core Settings In Windows 10 · Type 'msconfig' into the Windows Search Box and hit Enter. · Select the Boot tab and then...
Read more >
HOW TO ENABLE ALL CORES IN WINDOWS 10 - YouTube
Problems arise when the Windows OS then never re-enables all the cores. ... try ticking detect HAL in the BOOT Advanced Options in...
Read more >
How To Enable All CPU Cores Windows 10 - YouTube
Copy link. Info. Shopping. Tap to unmute. If playback doesn't begin shortly, try restarting your device. Your browser can 't play this video....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found