Set_num_threads not working in python3

Hello everyone.
I recently updated to python3 and I am seeing that I cannot set the number of omp proccess anymore in pytorch.

This is the check I did:
python2.7

import torch
print(torch.__version__)
>1.0.0.dev20181003

print(torch.get_num_threads())
> 20

torch.set_num_threads(8)

print(torch.get_num_threads())
> 8

Here everything works as expected. When I run exactly the same with python3.7 I get:

import torch
print(torch.__version__)
>1.0.0

print(torch.get_num_threads())
> 1

torch.set_num_threads(8)

print(torch.get_num_threads())
> 1

Any clue why is this happening?

Using envirionment variable OMP_NUM_THREADS doesn’t work any better.

Thank you very much in advance.

1 Like

Hi,

If the number of threads is 1, that means that no multithreading can be used. Most certainly because OMP was not detected at compilation time. This means that you cannot change the number of threads as only 1 will be used anyway.

1 Like

I have the same problem, using the official pip wheel of PyTorch 1.0 for Python 3.6 + CUDA 10.