The reason could be you use more number of threads(in your case, 30) than the actual number of threads that can be processed parallely by your machine.
Do
nproc

which gives the Core(s) per socket * Thread(s) per core
Pass that value to torch.set_num_threads().
You can also use torch.get_num_threads() to get the number of threads which will be used for parallelizing.
P.S: Not sure how to interpret the output given by torch.get_num_threads().