Is it not possible to use all threads with DUALCPU in PYTHON?

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

penpen

New Member
Apr 26, 2023
7
0
1
CPU.png



I want to use all CPU threads. Processing is performed using only one of the two CPUs


import numpy as np
a=np.random.random((25000,5000))
b=np.random.random((5000,25000))
c=np.dot(a,b)

--------------------------

import multiprocessing
multiprocessing.cpu_count()

Out64

---------------------------

psutil.cpu_count(logical=False)

Out32
 

CyklonDX

Active Member
Nov 8, 2022
635
202
43
You can use ThreadPool (again depends on your code)

You will need to use concurrent.futures.ThreadPoolExecutor(max_workers = X) as executor; where you can first query how many threads/cores your system has available and use it as a var to fill max_workers;


or you can try doing threading.Thread class which is potentially less complicated, as you can specify task within each thread; by simply defining thread, starting it, and joining (if you need to join)
 

Sean Ho

seanho.com
Nov 19, 2019
733
333
63
Vancouver, BC
seanho.com
It depends on what function you're using; e.g., most optimization in numpy is really just using LAPACK+BLAS, which are parallelised when using the appropriate libraries.

Is your actual workload primarily generating random numbers? If they need to be cryptographically random, consider openssl instead.