0

我收到了来自 openBLAS 的大量警告,例如

OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option. OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option. OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option. OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option. OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option. OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option. OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option. OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.

这是我的 src/Makevars 文件的样子

PKG_CPPFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

这是我的头文件:

#define ARMA_NO_DEBUG

#ifdef _OPENMP
#include <omp.h>
#endif

//[[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>

//[[Rcpp::depends(RcppProgress)]]
#include <progress.hpp>

#include <Rcpp.h>
#include <R.h>

openMP 像这样在我的代码中使用

#pragma omp parallel for num_threads(n_threads) schedule(dynamic) private(W, mu)
for (unsigned int j = 0; j < m; j++)

wheren_threads是通过函数参数传递的。一切都很好,n_threads = 1但在n_threads = 2. 完整的代码可以在这里找到,这也取决于其他文件(抱歉,我不能在这里粘贴,因为它有点长)。

我尝试添加USE_OPENMP=1到 src/Makevars,但它不起作用。任何机构都有解决方案?谢谢!

4

1 回答 1

1

在 CPU 模式下运行 Torch 时,我收到了相同的警告。用 OPEN_MP 1 重建 OpenBLAS 为我修复了它。

如果你想用 OPEN_MP 1 重建 OpenBLAS,那么:

转到克隆 OpenBLAS 存储库的文件夹(对我来说是 /home/brt/code/OpenBLAS)

cd /home/brt/code/OpenBLAS/
make clean
make USE_OPENMP=1
sudo make install

如果您还没有这样做,

sudo vi /etc/ld.so.conf.d/openblas.conf

添加行:/opt/OpenBLAS/lib

保存并关闭

sudo ldconfig

这应该使用 OPEN_MP 重建 OpenBLAS 为 1

于 2016-06-29T18:06:23.910 回答