Torch – 错误 getrf : Lapack library not found in compile time

  • Post author:
  • Post category:其他


在学习torch的时候遇到这个错误,更确切的是在使用torch模块中的

inverse函数

的时候出现的报错。

百度了下,在HermanHGF的

这篇博客

中提到是由于未安装OpenBLAS所致,给出了如下的解决方案:

git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make NO_AFFINITY=1 USE_OPENMP=1
sudo make install

然后添加路径,进行torch模块的安装。

CMAKE_LIBRARY_PATH=/opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
luarocks install torch


原文的解决方案到此为止,然而在尝试过后依然不行,于是搜到了以下的解决方案:

  • 根据提示安装lapack库
sudo apt-get install liblapack-dev
  • 按照之前的步骤重新安装OpenBLAS,torch模块即可。

另, 在安装OpenBLAS的时候,可能还会出现以下报错提示,

OpenBLAS: Detecting fortran compiler failed. Cannot compile LAPACK. Only compile BLAS.

需要安装gfortran编译器进行编译。

sudo apt-get install gfortran

安装后重复以上步骤即可


至此,完美解决inverse报错。

参考资料:


  1. 安装Torch参考官方文档遇到的问题