R 和 nvblas.dynlib(在 mac 上)
R and nvblas.dynlib (on a mac)
我通过 CRAN. I also have openblas installed via homebrew 在 mac 上安装了 R。我可以按如下方式在 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 紧随其后)。
不过,我想尝试更多的力量:
我installed CUDA 6.5 from NVIDIA。这会将一堆文件下载到 /Developer/NVIDIA/
,并将其中一些文件 link 下载到 /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
.
中未包含的 BLAS 函数,这应该将 nvblas.dylib
指向 libopenblas.dylib
到目前为止一切顺利。接下来就是linkR对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) 是什么,都会发生这种情况。谁能帮我解决这个错误?是否还有其他我需要添加到我的路径或 link 以使 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_
到 openblas。
/编辑:
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
我通过 CRAN. I also have openblas installed via homebrew 在 mac 上安装了 R。我可以按如下方式在 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 紧随其后)。
不过,我想尝试更多的力量:
我installed CUDA 6.5 from NVIDIA。这会将一堆文件下载到 /Developer/NVIDIA/
,并将其中一些文件 link 下载到 /usr/local/cuda
。我在 ~/.profile
:
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
.
nvblas.dylib
指向 libopenblas.dylib
到目前为止一切顺利。接下来就是linkR对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) 是什么,都会发生这种情况。谁能帮我解决这个错误?是否还有其他我需要添加到我的路径或 link 以使 libnvblas.dylib
在 mac?
相关错误大概是:
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_
到 openblas。
/编辑:
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