Wonder about details in PyTorch. If using CPU, How to know which math library is using?

I’m a Python engineer and asked to build a server to run PyTorch model as fast as possible. I am
new to PyTorch and I am not familiar with the algorithms. I’m wandering how PyTorch do calculating on CPU and how to make it as fast as possible.

so I have some questions.

  1. Does PyTorch relay on NumPy to perform math operations? Or it has it’s own math library?
  2. I heard that use MKL can speed up, but how can I know whether PyTorch is using MKL or not?
  3. There are many low-level tensor libraries for PyTorch, like TH, THC…, Are they relay on NumPy? Are they Use MKL for speed?
  4. If I want to see how many benefit I can gain from MKL, how to disable MKL or enable MKL?


  1. No. We don’t rely on numpy to do math operations. Instead, both Pytorch and numpy use blas/lapack library calls.
  2. Try use torch.svd. It is only available when mkl is installed.
  3. The linalg operations use blas interface provided by mkl, e.g. svd.
  4. The difference can be a lot on linalg operations, e.g. addmm that is used by linear layer. I think the way to enable/disable is to install/uninstall unfortunately.