Centos安装Singularity记录
2023-05-16 本文已影响0人
生物信息与育种
环境依赖
sudo yum update -y && \
yum groupinstall -y 'Development Tools' && \
yum install -y \
openssl-devel \
libuuid-devel \
libseccomp-devel \
wget \
squashfs-tools\
cryptsetup
golang安装
sudo export VERSION=1.16.5 OS=linux ARCH=amd64 && \
wget https://studygolang.com/dl/golang/go$VERSION.$OS-$ARCH.tar.gz && \
tar -C /usr/local -xzvf go$VERSION.$OS-$ARCH.tar.gz && \
rm go$VERSION.$OS-$ARCH.tar.gz
echo 'export GOPATH=${HOME}/go' >> ~/.bashrc && \
echo 'export PATH=/usr/local/go/bin:${PATH}:${GOPATH}/bin' >> ~/.bashrc && \
source ~/.bashrc
Singularity安装
export VERSION=3.8.0 && export REL=rc.2 && # adjust this as necessary \
wget https://github.com/hpcng/singularity/releases/download/v${VERSION}-${REL}/singularity-${VERSION}-${REL}.tar.gz && \
tar -xzf singularity-${VERSION}-${REL}.tar.gz && \
cd singularity
sudo ./mconfig && \
make -C ./builddir && \
make -C ./builddir install
直接在默认路径上编译会报错,显示Go没有找到,可是明明能运行go:
Configuring for project `singularity' with languages: C, Golang
=> running pre-basechecks project specific checks ...
=> running base system checks ...
checking: host C compiler... cc
checking: host C++ compiler... c++
checking: host Go compiler (at least version 1.13)... not found!
mconfig: could not complete configuration
删除整个singularity目录,重新解压安装(普通用户即可):
export VERSION=3.8.0
tar -xzf singularity-ce-${VERSION}.tar.gz
cd singularity-ce-${VERSION}
./mconfig --prefix=/opt/singularity/${VERSION}
cd builddir/
make && make install
echo "export PATH=/opt/singularity/${VERSION}/bin:\$PATH" >> ~/.bashrc
常用命令
singularity -h
singularity build #构建镜像
singularity run #容器内启动执行脚本
singularity exec #镜像内执行命令
singularity shell #执行一个 shell 脚本
Ref:
https://www.jianshu.com/p/b081c9622dda
https://www.jianshu.com/p/b46ee066806b
后续
以上表面上是安装成功了,但实际上运行singularity容器时,出现setuid
的错误,说明有些容器普通用户安装的singularity不行,最好用root安装。问题来了,root安装默认路径编译显示如上的go错误。
ERROR : No setuid installation found, for unprivileged installation use: ./mconfig --without-suid
重装了几次仍然不行,网上说明了go和singularity版本需要对应。
最后看了个回答:使用go version 1.13.15对应singularity version 3.6.3是可以的。
sudo rm -r /usr/local/go
export VERSION=1.13.15 OS=linux ARCH=amd64 # change this as you need
wget -O /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz https://dl.google.com/go/go${VERSION}.${OS}-${ARCH}.tar.gz && \
sudo tar -C /usr/local -xzf /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz
echo 'export GOPATH=${HOME}/go' >> ~/.bashrc && \
echo 'export PATH=/usr/local/go/bin:${PATH}:${GOPATH}/bin' >> ~/.bashrc && \
source ~/.bashrc
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh |
sh -s -- -b $(go env GOPATH)/bin v1.21.0
github上已经不能直接找到v3.6.3,可在此下载:https://github.com/apptainer/singularity/releases/tag/v3.6.3
如下:
wget https://github.com/apptainer/singularity/releases/download/v3.6.3/singularity-3.6.3.tar.gz
tar -xzf singularity-3.6.3.tar.gz
cd singularity
./mconfig && make -C ./builddir && sudo make -C ./builddir install
singularity
这时,再运行容器,显示正常了。
Ref:
https://github.com/apptainer/singularity/issues/5099
https://blog.csdn.net/weixin_62940906/article/details/128586498