gpt4 book ai didi

R 和 nvblas.dynlib(在 Mac 上)

转载 作者:行者123 更新时间:2023-12-04 12:02:46 27 4
gpt4 key购买 nike

我通过 CRAN 在我的 Mac 上安装了 R .我也通过 homebrew 安装了 openblas .我可以按如下方式在 BLAS 实现之间切换:

引用 blas(我认为是 netlib):

ln -sf /Library/Frameworks/R.framework/Resources/lib/libRblas.0.dylib /Library/Frameworks/R.framework/Resources/lib/libRblas.dylib

vecLib(Apple 的 BLAS):
 ln -sf /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Versions/Current/libBLAS.dylib /Library/Frameworks/R.framework/Resources/lib/libRblas.dylib

openblas(通过自制软件提供):
brew link openblas --force
ln -sf /usr/local/lib/libopenblas.dylib /Library/Frameworks/R.framework/Resources/lib/libRblas.dylib

在 3 个选项中,openblas 似乎是最快的选项(尽管 vecLib 紧随其后)。

但是,我想尝试更多的力量:

More Power

installed CUDA 6.5 from NVIDIA .这会将一堆文件下载到 /Developer/NVIDIA/并将其中一些链接到 /usr/local/cuda .我在 ~/.profile 中设置了我的 cuda 环境变量:
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib:$LD_LIBRARY_PATH"
export CUDA_ROOT="/usr/local/cuda/bin"
export CUDA_HOME="/usr/local/cuda"
export NVBLAS_CONFIG_FILE="/Users/me/nvblas.conf"

然后我用以下条目制作了一个“/Users/me/nvblas.conf”:
NVBLAS_CPU_BLAS_LIB /usr/local/lib/libopenblas.dylib
NVBLAS_GPU_LIST ALL0
NVBLAS_TILE_DIM 2048
NVBLAS_AUTOPIN_MEM_ENABLED

理论上,这个应该指向 nvblas.dylib返回 libopenblas.dylib对于不包含在 nvblas.dylib 中的 BLAS 函数.

到现在为止还挺好。下一步是将 R 链接到 nvblas.dylib :
ln -sf /usr/local/cuda/lib/libnvblas.dylib /Library/Frameworks/R.framework/Resources/lib/libRblas.dylib

但是,当我启动 R 时,似乎 libRlapack.dylib找不到它要查找的所有 BLAS 函数:
me:~ me$ R
[NVBLAS] Using devices :0
[NVBLAS] Config parsed

R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/stats/libs/stats.so, 6): Symbol not found: _dasum_
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/lib/libRlapack.dylib
Expected in: /Library/Frameworks/R.framework/Versions/3.1/Resources/lib/libRblas.dylib
in /Library/Frameworks/R.framework/Versions/3.1/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found

openblas 本身运行良好,并提供 R 正在寻找的所有功能,所以我认为错误是 libnvblas.dylib没有正确回退到 libopenblas.dylib .

无论我指向什么 CPU BLAS,都会发生这种情况 libnvblas.dylib在(netlib、vecLib、openblas)。谁能帮我解决这个错误?还有什么我需要添加到我的路径或链接中才能获得 libnvblas.dylib在 Mac 上正确使用 R 吗?

相关错误可能是:
Symbol not found: _dasum_
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/lib/libRlapack.dylib
Expected in: /Library/Frameworks/R.framework/Versions/3.1/Resources/lib/libRblas.dylib

在我看来,nvblas 没有转发 _dasum_打开blas。

/编辑:
otool -L /Library/Frameworks/R.framework/Resources/lib/libRblas.dylib

产量:
/Library/Frameworks/R.framework/Resources/lib/libRblas.dylib:
@rpath/libnvblas.6.5.dylib (compatibility version 0.0.0, current version 6.5.14)
@rpath/libcublas.6.5.dylib (compatibility version 0.0.0, current version 6.5.14)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.21.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

最佳答案

我和你有同样的问题。在 OSX 下覆盖库而不是替换 R.framework 中的库为我解决了这个问题:

$ DYLD_FORCE_FLAT_NAMESPACE=y DYLD_INSERT_LIBRARIES=/Developer/NVIDIA/CUDA-7.0/lib/libnvblas.7.0.dylib R

关于R 和 nvblas.dynlib(在 Mac 上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28179093/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com