首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让openBLAS与openMP协同工作?

如何让openBLAS与openMP协同工作?
EN

Stack Overflow用户
提问于 2016-01-04 00:01:56
回答 1查看 7.2K关注 0票数 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文件

代码语言:javascript
复制
PKG_CPPFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

下面是我的头文件:

代码语言:javascript
复制
#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,如下所示

代码语言:javascript
复制
#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的时候得到上面的警告。完整的代码可以在here找到,它也依赖于其他文件(对不起,我不能在这里粘贴,因为它有点长)。

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

EN

回答 1

Stack Overflow用户

发布于 2016-06-30 02:06:24

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

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

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

代码语言:javascript
复制
cd /home/brt/code/OpenBLAS/
make clean
make USE_OPENMP=1
sudo make install

如果您还没有这样做,

代码语言:javascript
复制
sudo vi /etc/ld.so.conf.d/openblas.conf

添加行: /opt/OpenBLAS/lib

保存并关闭

代码语言:javascript
复制
sudo ldconfig

这将重新生成OpenBLAS,并将OPEN_MP设置为1

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34578526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档