3

When running scipy optimize minimum using the L-BFGS-B method, I found that on certain computers, it uses all 8 cpu cores (see photo 1), on others it uses 4 out of 8 cores (see photo 2) and on others it only uses 1 core. I have not used any libraries/code to make it parallel -- it seems to be doing that by default.

Is there a way that I can specify how many cores it should use easily? I couldn't find anything online that suggested scipy optimize uses parallelisation by default.

fmin = scipy.optimize.minimize(fun=mf.nncostfunction3, x0=theta_initial_ravel, args=(input_layer_size, hidden_layer_size1, num_labels, x_train, y_train, lambda_reg), method=minimisation_method, jac=True, options={'maxiter': iteration_number, 'disp': use_minimisation_display})

answer = fmin.x

On my desktop, it uses all 8 out of 8 cores

On my latpop, it uses all 4 out of 8 cores

Scott Yiu
  • 31
  • 1
  • 3
  • 4
    That's with a very high probability only dependent on BLAS. Some older ubuntu's bringt single-core or max 2-core BLAS out of the box. The newer ones are able to use more. So the analysis would be something like: check which BLAS is used (e.g. OpenBLAS, MKL, ...), then ask for the settings in regards to cores. **Edit:** also check if something like Hyper-threading is activated. I'm not sure how the different BLAS-libs decide on the cores to use then.Possible: your laptop has 4 real cores with HT -> only 4 cores are used (which sounds quite common) – sascha Nov 23 '16 at 16:59
  • 2
    Thanks for the comment! I would upvote if I could (not enough reputation). I will check this out. – Scott Yiu Nov 23 '16 at 17:10
  • (upvoted) This is the correct answer, so this should be made to an answer which we can upvote and the OP can accept :-). – ev-br Nov 23 '16 at 23:41
  • I see 4 of 4 cores being used by scipy.optimize.minimize (with `method="SLSQP"`) on my laptop. Running `apt list --installed | grep blas` prints `libblas-common/xenial,now 3.6.0-2ubuntu2 amd64 [installed,automatic] libblas-dev/xenial,now 3.6.0-2ubuntu2 amd64 [installed,automatic] libblas3/xenial,now 3.6.0-2ubuntu2 amd64 [installed,automatic] ` – Adrian Nov 18 '17 at 23:55
  • how do you "ask for the settings in regards to cores"? – KeatsKelleher Apr 08 '21 at 23:03

0 Answers0