本文介绍了如何使openBLAS与openMP一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从openBLAS得到了很多警告

I got tons of warning from openBLAS like

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.

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文件的样子

Here is what my src/Makevars file looks like

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

openMP is used in my code like this

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

其中n_threads通过函数参数传递. n_threads = 1时一切都很好,但n_threads = 2时得到了以上警告.可以在此处找到完整的代码,该代码取决于其他文件以及(抱歉,我不能粘贴到这里,因为它有点长).

where n_threads is passed via function argument. Everything is fine when n_threads = 1 but got the above warnings when n_threads = 2.A complete code can be found here, which depends on other files as well (sorry I cannot paste here as it is a bit long).

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

I tried adding USE_OPENMP=1 to src/Makevars, but it does not work. Any body has a solution? Thank you!

推荐答案

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

I got the same warnings while running Torch on CPU mode. Rebuilding OpenBLAS with OPEN_MP 1 fixed it for me.

如果要使用OPEN_MP 1重建OpenBLAS,则:

If you want to rebuild OpenBLAS with OPEN_MP 1, then:

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

Go to the folder where you cloned OpenBLAS repository (for me it is /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

add the line: /opt/OpenBLAS/lib

保存并关闭

sudo ldconfig

这应该以OPEN_MP为1重建OpenBLAS

This should rebuild OpenBLAS with OPEN_MP as 1

这篇关于如何使openBLAS与openMP一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-06 19:34