简体   繁体   English

在Ubuntu 16.04 VirtualBox上安装Rmpi

[英]Installing Rmpi on Ubuntu 16.04 VirtualBox

I created a new ubuntu-16.04.2-desktop-amd64 machine on VM VirtualBox and I want to be able to use the R environment with Rmpi. 我在VM VirtualBox上创建了新的ubuntu-16.04.2-desktop-amd64计算机,我希望能够将R环境与Rmpi一起使用。

Both of the below approaches gives a similar error. 以下两种方法都给出了类似的错误。

Updated simplified pre-build binary approach: 更新了简化的预构建二进制方法:

When Ubuntu had installed I opened a terminal and executed the following commands: 安装Ubuntu后,我打开了一个终端并执行以下命令:

~$ sudo apt-get update
~$ sudo apt-get install openmpi-bin
~$ sudo apt-get install r-base
~$ sudo apt-get install r-cran-rmpi
~$ R

This opened the R terminal and I invoking the follow function which resulted in an error: 这打开了R终端,我调用了跟随函数,导致了错误:

> library(Rmpi)
libmpi.so: cannot open shared object file: No such file or directory
Error : .onLoad failed in loadNamespace() for 'Rmpi', details:
call: fun(libname, pkgname)
error: Cannot start MPI_Init(). Exit
Error: package or namespace load failed for ‘Rmpi’

Alternative approaches that I have attempted include using a local OpenMPI installation and using the R function install.packages to install the Rmpi package (see below). 我尝试过的替代方法包括使用本地OpenMPI安装和使用R函数install.packages安装Rmpi软件包(请参见下文)。 These all resulted in the same error. 这些都导致了相同的错误。

I have also tried using MPICH by substituting ~$ sudo apt-get install mpich as the second command in the above procedure (including using the R function for installing the package) which results in an even more onerous runtime error. 我还尝试通过将~$ sudo apt-get install mpich替换为上述过程中的第二个命令来使用MPICH(包括使用R函数安装软件包),这会导致更加繁重的运行时错误。

Does anyone know what I have done wrong or what I can do to resolve this installation error? 有人知道我做错了什么或者我可以解决该安装错误吗?

Or alternatively, have anyone been able to successfully install a VirtualBox machine with Rmpi using any Linux distro or an image with pre-installed components? 或者,是否有人能够使用任何Linux发行版或具有预安装组件的映像成功地使用Rmpi安装VirtualBox计算机?

Original local installation approach: 原始本地安装方法:

I have followed the instructions on this blog to download OpenMPI version 2.1.0, compile and install it. 我已按照此博客上的说明下载OpenMPI 2.1.0版,进行编译和安装。 However when I try to install the package in R with: 但是,当我尝试通过以下方式在R中安装软件包时:

> install.packages("Rmpi", configure.args =
  c("--with-Rmpi-include=/home/jormunr/openmpi/include",
    "--with-Rmpi-libpath=/home/jormunr/openmpi/lib",
    "--with-Rmpi-type=OPENMPI",
    "--with-mpi=/home/jormunr/openmpi/"))

it gives the following error 它给出了以下错误

Error: .onLoad failed in loadNamespace() for 'Rmpi', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/home/jormunr/R/x86_64-pc-linux-gnu-library/3.2/Rmpi/libs/Rmpi.so':
libmpi.so.20: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed

I can see that the 'libmpi.so.20' file is in the /home/jormunr/openmpi/lib that I provided as one of the parameter to the installation. 我可以看到“ libmpi.so.20”文件位于/ home / jormunr / openmpi / lib中,该文件是我作为安装参数之一提供的。

[Disclaimer: I am not a Linux expert and merely have user level skills. [免责声明:我不是Linux专家,仅具有用户级技能。 Any contributions or corrections from an expert will be greatly appreciated.] 专家的任何贡献或纠正,将不胜感激。]

Pre-build Binary Approach 预生成二进制方法

Although trying various ways to install the prebuilt binaries I did not manage to get this option to work. 尽管尝试了各种方法来安装预构建的二进制文件,但我没有设法使该选项起作用。 This involved executing in the terminal the command 'sudo apt-get install r-cran-rmpi' to install the r-cran-rmpi prebuilt packages which also automatically installs the libopenmpi1.10 package that is a listed prerequisite. 这涉及在终端中执行命令“ sudo apt-get install r-cran-rmpi”以安装r-cran-rmpi预先构建的软件包,该软件包还自动安装列出的先决条件libopenmpi1.10软件包。 However, it appears that the file 'libmpi.so' is not included in the libopenmpi1.10 package but expected by the Rmpi library which causes an error in the R environment that it cannot find this file. 但是,似乎文件'libmpi.so'没有包含在libopenmpi1.10包中,而是Rmpi库期望的,这会在R环境中导致找不到该文件的错误。

Local Installation Approach 本地安装方法

The local installation did eventually succeed with a few amendments. 进行了一些修改,最终使本地安装成功。 I created a new ubuntu-16.04.2-desktop-amd64 VirtualBox image with default settings, except for 2048MB of memory and 32GB of hard drive space. 我使用默认设置创建了一个新的ubuntu-16.04.2-desktop-amd64 VirtualBox映像,除了2048MB的内存和32GB的硬盘空间。 When installed I opened a terminal and executed the commands from the Jovinge Lab website with the inclusion of the penultimate command which amends the run-time link editor's path and enables the install.package() function of R to find the 'libmpi.so' file. 安装后,我打开了一个终端并执行了Jovinge Lab网站上的命令,其中包括倒数第二个命令,该命令修改了运行时链接编辑器的路径,并使R的install.package()函数可以找到“ libmpi.so”文件。 (also changed the version to 1.10.6 as this is the latest version release of version 1 – see below for version 2) (还将版本更改为1.10.6,因为这是版本1的最新版本-请参阅下面的版本2)

~$ cd /home/jormunr
~$ wget https://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.2.tar.gz
~$ tar -zxvf openmpi-1.10.6.tar.gz
~$ cd openmpi-1.10.2
~$ ./configure --prefix=/home/jormunr
~$ make
~$ make install
~$ sudo apt-get install r-base
~$ export LD_LIBRARY_PATH=/home/jormunr/lib:$LD_LIBRARY_PATH
~$ R

This opens an R terminal and I invoked the function: 这将打开R终端,并调用了该函数:

> install.packages("Rmpi", configure.args =
+ c("--with-Rmpi-include=/home/jormunr/include/",
+   "--with-Rmpi-libpath=/home/jormunr/lib/",
+   "--with-Rmpi-type=OPENMPI",
+   "--with-mpi=/home/jormunr/"))

This now executed without errors and I could test it with the following R statements: 现在可以正确执行该命令,并且可以使用以下R语句对其进行测试:

> library("Rmpi")
> mpi.spawn.Rslaves()
master (rank 0, comm. 1) of size 2 is running on: Valhalla
slave1 (rank 1, comm. 1) of size 2 is running on: Valhalla
> mpi.close.Rslaves()
[1] 1
> mpi.quit()

When I tried this process with the OpenMPI Version 2.1.0 the installation completed successfully but the above test had issues; 当我使用OpenMPI版本2.1.0尝试此过程时,安装成功完成,但是上述测试存在问题; the mpi.spawn.Rslaves() function completed but mpi.close.Rslaves() did not complete – it never returned and the terminal was left hanging. mpi.spawn.Rslaves()函数已完成,但mpi.close.Rslaves()未完成–从未返回,并且终端被挂起。

I experienced similar challenges. 我遇到了类似的挑战。 I landed on this solution where libopenmpi-dev was the secret. 我找到了libopenmpi-dev是秘密的解决方案。

sudo apt-get install openmpi-common openmpi-bin libopenmpi-dev r-base
sudo apt-get install r-cran-rmpi
sudo su
R
install.packages("doMPI", dependencies=TRUE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM