Can we build libtorch without MKL?

I was able to build libtorch with MKL (installed by conda) by python setup.py install. However, there is no guarantee that the production environment is provided with MKL. As a result, I was wondering if we can build libtorch without MKL?
I’ve tried by uninstalling MKL (through conda) and build libtorch. The building process looks normal. However, when linking libcaffe2_gpu.so to my executable, there are several ‘undefined reference’ error messages I’ve never seen and the Google also provide nothing useful.

Apologize for the Chinese characters in the screenshot. ‘未定义的引用’ means ‘undefined reference’

I think if you build Pytorch from source and you don’t provide MKL, then Pytorch will rely on Eigen as one of its submodules. That said, you do not even need a linear algebra library on your system for Pytorch to compile

In the setup.py you will find

#   BLAS
#     BLAS to be used by Caffe2. Can be MKL, Eigen, ATLAS, or OpenBLAS. If set
#     then the build will fail if the requested BLAS is not found, otherwise
#     the BLAS will be chosen based on what is found on your system.

And thanks for translating the characters for us, I appreciate that a lot :slight_smile:

1 Like