singularity

作者: 全村滴希望 | 来源:发表于2019-03-27 21:38 被阅读0次

singularity 安装

安装依赖

在ubuntu上

sudo apt-get update && sudo apt-get install -y \
    build-essential \
    libssl-dev \
    uuid-dev \
    libgpgme11-dev \
    squashfs-tools \
    libseccomp-dev \
    pkg-config

在centos上

sudo yum update -y && \
    sudo yum groupinstall -y 'Development Tools' && \
    sudo yum install -y \
    openssl-devel \
    libuuid-devel \
    libseccomp-devel \
    wget \
    squashfs-tools

安装Go

Singularity 3.0以上版本主要用Go编写,因此需要安装Go来从源代码编译

首先,访问Go下载页面,并选择相应的Go版本(版本选择1.11.1以上)

export VERSION=1.11 OS=linux ARCH=amd64
cd /tmp
wget https://dl.google.com/go/go$VERSION.$OS-$ARCH.tar.gz

将Go安装包解压缩到/usr/local

sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

最后设置Go环境变量

echo 'export GOPATH=${HOME}/go' >> ~/.bashrc
echo 'export PATH=/usr/local/go/bin:${PATH}:${GOPATH}/bin' >> ~/.bashrc
source ~/.bashrc

下载singularity

先创建Go的编译目录

mkdir -p $GOPATH/src/github.com/sylabs
cd $GOPATH/src/github.com/sylabs
git clone https://github.com/sylabs/singularity.git

安装Go依赖项

使用Deo管理依赖关系,用go get安装

go get -u -v github.com/golang/dep/cmd/dep

编译安装

必须以root身份安装

cd $GOPATH/src/github.com/sylabs/singularity
./mconfig
make -C builddir
sudo make -C builddir install

验证安装是否成功

singularity help

Linux container platform optimized for High Performance Computing (HPC) and
Enterprise Performance Computing (EPC)

Usage:
  singularity [global options...]

Description:
  Singularity containers provide an application virtualization layer enabling
  mobility of compute via both application and environment portability. With
  Singularity one is capable of building a root file system that runs on any 
  other Linux system where Singularity is installed.

Options:
  -d, --debug     print debugging information (highest verbosity)
  -h, --help      help for singularity
      --nocolor   print without color output (default False)
  -q, --quiet     suppress normal output
  -s, --silent    only print errors
  -v, --verbose   print additional information

Available Commands:
  apps        List available apps within a container
  build       Build a Singularity image
  cache       Manage the local cache
  capability  Manage Linux capabilities for an image
  exec        Run a command within a container
  help        Help about any command
  inspect     Show metadata for an image
  instance    Manage containers running as services
  key         Manage OpenPGP keys
  oci         Manage OCI containers
  plugin      Manage singularity plugins
  pull        Pull an image from a URI
  push        Upload image to the provided library (default is "https://library.sylabs.io")
  remote      Manage Sylabs Cloud endpoints
  run         Run the user-defined default command within a container
  run-help    Show the help for an image
  search      Search a Library for images
  shell       Run a shell within a container
  sign        Attach a cryptographic signature to an image
  test        Run the user-defined tests within a container
  verify      Verify cryptographic signatures attached to an image
  version     Show the version for Singularity

Examples:
  $ singularity help <command> [<subcommand>]
  $ singularity help build
  $ singularity help instance start


For additional help or support, please visit https://www.sylabs.io/docs/

删除旧版本

sudo rm -rf /usr/local/libexec/singularity
sudo rm -rf /usr/local/etc/singularity
sudo rm -rf /usr/local/include/singularity
sudo rm -rf /usr/local/lib/singularity
sudo rm -rf /usr/local/var/lib/singularity/
sudo rm /usr/local/bin/singularity
sudo rm /usr/local/bin/run-singularity
sudo rm /usr/local/etc/bash_completion.d/singularity 
sudo rm /usr/local/man/man1/singularity.1

singularity 使用

创建镜像/沙盒

可以通过build命令直接创建一个镜像

singularity build centos.img docker://centos:latest

build命令可以直接创建镜像或者singularity默认的sif容器文件,还可以是simg

也可以通过build命令直接创建一个沙盒

singularity build --sandbox centos/ docker://centos:latest

build命令加上 --sandbox可以直接创建沙盒,沙盒可以直观的看到容器内的目录,直观方便

以上实际上是将Container Library或者Docker Hub上的镜像download下来用作容器。

以library:// 开头的URI,表示是从Container Library构建
以docker:// 开头的URI,表示是从Docker Hub构建
以shub:// 开头的URI,表示是从Singularity Hub构建

同样可以用singularity自定义文件(例如Singularity 或者singularity.def)来建立容器

Bootstrap: docker
From: ubuntu:16.04

%post
    apt-get -y update
    apt-get -y install fortune cowsay lolcat

%environment
    export LC_ALL=C
    export PATH=/usr/games:$PATH

%runscript
    fortune | cowsay | lolcat
sudo singularity build lolcow.sif lolcow.def

与容器进行交互

通过shell —writable来对容器进行操作

singularity shell --writable centos/    #此时是对沙盒进行操作

Singularity centos:~/centos> 

安装软件环境

接下来以安装vasp为例

安装intel编译器

下载好tgz包和有效的license文件后,进入容器

tar -zxvf parallel_studio_xe_2017_update5.tgz
cd parallel_studio_xe_2017_update5
./install.sh #卸载操作也是执行这个文件

安装过程有7步,其中第三步骤选择

I want to activate my product using a serial number

cat 查看license里的序列号后输入即可

intel编译器会默认安装在/opt/intel目录下。安装完成后需要添加PATH到环境变量中。 vim ~/.bashrc ,修改单个用户。vim /etc/profile,修改全局。插入如下代码

source /opt/intel/compilers_and_libraries_2017.5.239/linux/bin/compilervars.sh intel64
source /opt/intel/compilers_and_libraries_2017.5.239/linux/bin/iccvars.sh intel64
source /opt/intel/compilers_and_libraries_2017.5.239/linux/bin/ifortvars.sh intel64
source /opt/intel/compilers_and_libraries_2017.5.239/linux/mkl/bin/mklvars.sh intel64
source /opt/intel/impi/2017.4.239/bin64/mpivars.sh

以上操作都是在singularity沙盒目录中执行的操作,处于容器环境中,是可以同时看见容器中的文件和本机系统的文件的。例如此时名为centos的沙盒目录的位置是本机的 /root 目录下,那么容器里的 /root 目录实际路径是 ·/root/centos/root

也就是说,在名为 centos 容器中,Intel编译器默认安装的真实路径实际上是/root/centos/opt/intel 但是由于在容器中是完全隔离的,因此不需要考虑这个真实路径,在配置环境变量的时候依然是 opt/intel

修改环境变量完成后

source ~/.bashrc #或者 source /etc/profile

使用接下来的命令查看环境变量是否添加成功

which icc ifort icpc mpiifort

如果此时退出容器,那么下次进入容器后需要重新 source /etc/profile

否则会报

which: no icc in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
which: no ifort in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
which: no icpc in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
which: no mpiifort in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)

安装VASP

解压VASP压缩包, 进入文件夹复制makefile.include

cd vasp.5.4.4 
cp arch/makefile.include.linux_intel makefile.include

修改makefile.include中的OBJECTS

OBJECTS    = fftmpiw.o fftmpi_map.o fft3dlib.o fftw3d.o /opt/intel/compilers_and_libraries_2017.5.239/linux/mkl/interfaces/fftw3xf/libfftw3xf_intel.a

安装

make all 2>&1 | tee make.log

添加环境变量,vim ~/.bashrc 或者 vim /etc/profile

PATH=/root/vasp.5.4.1/build/std:$PATH
source ~/.bashrc #或者 source /etc/profile

将沙盒打包成镜像或者sif文件

在对容器环境编写好之后,需要将其打包成sif文件或者是镜像的话,同样使用build命令来建立相应的文件

singularity build centos.img centos/

同样可以用 singularity shell --writable centos.img 进入容器

相关文章

  • Singularity入门之乱七八糟

    配置文件路径 singularity.conf: /etc/singularity/singularity.con...

  • Singularity 使用指南

    singularity 官网: https://singularity.lbl.gov/ 进入容器 singul...

  • 2018-07-19 singularity 使用

    singularity is awesome! singularity 类似docker,和docker不同的一点...

  • singularity

    一、singularity 安装 通过以下命令可以安装singularity git clone https://...

  • singularity

    singularity 安装 安装依赖 在ubuntu上 在centos上 安装Go Singularity 3....

  • SINGULARITY

    一群 追日的早鳥 一個 呼嚕的瑪吉 一條 甦醒的海岸 一場 即興的旅行 呼嘯 快轉的車輪 伴隨 春意的藍夜 攜手 ...

  • singularity

  • singularity

    画了泰亨的singularity里自己最喜欢的照片 嗯 花了忙长时间但挺值得

  • Singularity入门之运行容器

    下载已存在镜像 和Docker类似,要运行 Singularity 也需要先获取镜像,Singularity 可以...

  • Singularity升级

    卸载旧版本 以前装的Singularity版本比较低,最近要用新功能,只能升级了。因为以前Singularity安...

网友评论

    本文标题:singularity

    本文链接:https://www.haomeiwen.com/subject/efgtbqtx.html