美文网首页
生信log48|如何在MacOS中安装和运行Singularit

生信log48|如何在MacOS中安装和运行Singularit

作者: 小周的万用胶囊 | 来源:发表于2024-06-14 09:50 被阅读0次

啊,因为网络问题无法在服务器中直接用Singularity拉取镜像了,因此在本地电脑中拉取。由于系统是MacOS, Singularity官方并没有提供Mac系统的安装包而是给出了另外一种使用SingularityCE的方法,在尝试过程中遇到困难,在此记录一下。

0. 平台版本和思路

  • 平台和软件
    • MacOS
    • SingularityCE, ver. 4.1

这是官方文档上面记载的,在此截取MacOS使用SingularityCE的部分

  • 思路
    • 在Mac中安装Linux虚拟机(lima,brew install lima
    • 在Linux虚拟机中安装和运行SingularityCE

1. 配置文件准备和软件下载

虚拟机配置(官方)

  • 注意点:挂载目录(mount)一定要加入writable否则拉取镜像后无法保存在本地(没有系统写入权限导致的)
  • 👇下面是官方提供(挂载目录没有写writable)
# SingularityCE on Alma Linux 9
# 
# Usage:
#
#   $ limactl start ./singularity-ce.yml
#   $ limactl shell singularity-ce singularity run library://alpine

images:
- location: "https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2"
  arch: "x86_64"
- location: "https://repo.almalinux.org/almalinux/9/cloud/aarch64/images/AlmaLinux-9-GenericCloud-latest.aarch64.qcow2"
  arch: "aarch64"

mounts:
- location: "~"
- location: "/tmp/lima"

containerd:
  system: false
  user: false

provision:
- mode: system
  script: |
    #!/bin/bash
    set -eux -o pipefail
    dnf -y install --enablerepo=epel singularity-ce squashfs-tools-ng

probes:
- script: |
    #!/bin/bash
    set -eux -o pipefail
    if ! timeout 30s bash -c "until command -v singularity >/dev/null 2>&1; do sleep 3; done"; then
      echo >&2 "singularity is not installed yet"
      exit 1
    fi
  hint: See "/var/log/cloud-init-output.log" in the guest

message: |
  To run `singularity` inside your lima VM:
    $ limactl shell {{.Name}} singularity run library://alpine

导致的报错

  • 无法保存文件(缺乏读写权限导致
读写错误
  • 解决方案:在配置文件的mounts节点打开写入权限
解决方案

2. 运行SingularityCE

  1. 启动虚拟机实例

根据配置文件启动(不需要加./代表当前目录否则启动失败)

limactl start singularity-ce.yml
  • 进入虚拟机中进行操作
#启动一个叫singularity-ce的虚拟机实例
limactl shell singularity-ce

  • 不进入虚拟机中操作
#在虚拟机外直接拉取镜像
limactl shell singularity-ce singularity pull cibersortx_fractions.sif docker://cibersortx/fractions:latest

关闭虚拟机

  • 如果想根据新配置启动镜像,需要先把实例停止、删除后才能生效
#step 1 stop instance
limactl stop singularity-ce

#step 2 delete instance
limactl delete singularity-ce

参考

官方文档

原文地址

相关文章

网友评论

      本文标题:生信log48|如何在MacOS中安装和运行Singularit

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