我遇到了Rmpi的问题,我尝试加载它,我收到此错误消息:
> library('Rmpi') Error in dyn.load(file,DLLpath = DLLpath,...) : unable to load shared library '/usr/lib64/R/library/Rmpi/libs/Rmpi.so': libmpi.so.0: cannot open shared object file: No such file or directory In addition: Warning message: .Last.lib Failed in detach() for 'Rmpi',details: call: dyn.unload(file.path(libpath,"libs",paste("Rmpi",.Platform$dynlib.ext,error: dynamic/shared library '/usr/lib64/R/library/Rmpi/libs/Rmpi.so' was not loaded Error in library("Rmpi") : .First.lib Failed for 'Rmpi'
它似乎不是权限问题.我检查了libmpi.so.0的权限:
[meehan@cnl10 /]$ll /usr/lib64/lam/lib/ total 7.4M -rw-r--r-- 1 root root 207 May 25 2008 lam.module -rw-r--r-- 1 root root 885K May 25 2008 liblam.a -rw-r--r-- 1 root root 361K May 25 2008 liblamf77mpi.a lrwxrwxrwx 1 root root 21 Apr 12 2010 liblamf77mpi.so -> liblamf77mpi.so.0.0.0 lrwxrwxrwx 1 root root 21 Apr 12 2010 liblamf77mpi.so.0 -> liblamf77mpi.so.0.0.0 -rwxr-xr-x 1 root root 73K May 25 2008 liblamf77mpi.so.0.0.0 -rw-r--r-- 1 root root 2.2M May 25 2008 liblammpi++.a -rw-r--r-- 1 root root 509K May 25 2008 liblammpio.a lrwxrwxrwx 1 root root 20 Apr 12 2010 liblammpi++.so -> liblammpi++.so.0.0.0 lrwxrwxrwx 1 root root 20 Apr 12 2010 liblammpi++.so.0 -> liblammpi++.so.0.0.0 -rwxr-xr-x 1 root root 167K May 25 2008 liblammpi++.so.0.0.0 lrwxrwxrwx 1 root root 15 Apr 12 2010 liblam.so -> liblam.so.0.0.0 lrwxrwxrwx 1 root root 15 Apr 12 2010 liblam.so.0 -> liblam.so.0.0.0 -rwxr-xr-x 1 root root 332K May 25 2008 liblam.so.0.0.0 -rw-r--r-- 1 root root 2.2M May 25 2008 libmpi.a lrwxrwxrwx 1 root root 15 Apr 12 2010 libmpi.so -> libmpi.so.0.0.0 lrwxrwxrwx 1 root root 15 Apr 12 2010 libmpi.so.0 -> libmpi.so.0.0.0 -rwxr-xr-x 1 root root 655K May 25 2008 libmpi.so.0.0.0
和Rmpi.so:
[meehan@cnl10 /]$ll /usr/lib64/R/library/Rmpi/libs/ total 108K -rwxr-xr-x 1 root root 104K Jan 20 2011 Rmpi.so
无论如何,我正在运行R作为sudo.
相关系统信息:
-Linux发行版:CentOS 5.5
-R版本:2.11.1(2010-05-31)
-Rmpi版本:0.5-8
-MPI实现是openmpi
[meehan@cnl10 /]$ echo $LD_LIBRARY_PATH /opt/lib:/opt/open-mpi/tcp-`gnu41/lib:/opt/intel/mkl/10.2/lib/em64t:/opt/intel/fce/11.1/lib:/opt/intel/cce/11.1/lib:`
非常感激任何的帮助!
解决方法
这里的问题是OpenMPI默认情况下不会使用系统链接器注册其library目录.这就是为什么一些安装指南建议您将其目录放在LD_LIBRARY_PATH变量中,以便可以在运行时找到这些库.但是,每次加载新shell时都必须“将目录添加到LD_LIBRARY_PATH”,这就是为什么这些指南建议将它放在〜/ .bashrc等中,以便在每次登录时恢复设置.
但是,〜/ .bashrc文件(或〜/ .profile或任何此类文件)是特定于用户的设置.假设有人在安装openmpi和Rmpi等时以root用户身份登录,这似乎意味着添加到这些特定于用户的文件只会在以root身份运行时设置库路径,而不是像通常的运行时用户那样.
通常,修复是告诉链接器可以找到这些文件的位置.在我自己的系统上,运行CentOS 7,OpenMPI 1.10.0(使用Scientific Linux RPMs),R 3.2.3和Rmpi 0.6-5,这是当我设置库路径失败时会发生的情况:
[dchurch@workstation ~]$R -q -e "library('Rmpi')" > library('Rmpi') Error : .onLoad Failed in loadNamespace() for 'Rmpi',details: call: dyn.load(file,...) error: unable to load shared object '/usr/lib64/R/library/Rmpi/libs/Rmpi.so': libmpi.so.12: cannot open shared object file: No such file or directory Error: package or namespace load Failed for ‘Rmpi’ Execution halted
[dchurch@workstation ~]$LD_LIBRARY_PATH=/usr/lib64/openmpi/lib R -q -e "library('Rmpi')" > library('Rmpi') > >
但是,要使此更改成为永久更改,最好的方法是使用系统链接器本身注册openmpi库目录,方法是在/etc/ld.so.conf.d中创建一个新文件并运行ldconfig,如下所示:
[dchurch@workstation ~]$sudo sh -c 'echo /usr/lib64/openmpi/lib > /etc/ld.so.conf.d/openmpi.conf; ldconfig' [dchurch@workstation ~]$R -q -e "library('Rmpi')" > library('Rmpi') > >
完成后,无论环境变量如何,都应该能够为任何用户加载Rmpi.