Hi,
I am attempting to run my code on a HPC cluster. I want to limit the number of threads used to the number of cpus I demand. I find, however, that during the backward step thread usage shoots up.
As example: I demand 1 CPU, but during the backward step, 4 threads are used (and afterwards they remain used).
I have set the following environment variables at the start of the code:

import os
os.environ[“OMP_NUM_THREADS”] = “1”
os.environ[“OPENBLAS_NUM_THREADS”] = “1”
os.environ[“MKL_NUM_THREADS”] = “1”
os.environ[“VECLIB_MAXIMUM_THREADS”] = “1”
os.environ[“NUMEXPR_NUM_THREADS”] = “1”

and also set

import torch
torch.set_num_threads(1)

But thread usage during the backward step remains at 4.
Another thing is that the command in the linux terminal (with PID meaning process id)

ps -o nlwp {PID}

and the method

torch.get_num_threads()

return different results: the former command tells me my process is using 4 threads, the latter says it only sees 1 thread. I am inclined to believe the former.
Help would be greatly appreciated.