生信log48|如何在MacOS中安裝和運(yùn)行Singularity鏡像

啊,因?yàn)榫W(wǎng)絡(luò)問(wèn)題無(wú)法在服務(wù)器中直接用Singularity拉取鏡像了,因此在本地電腦中拉取。由于系統(tǒng)是MacOS, Singularity官方并沒(méi)有提供Mac系統(tǒng)的安裝包而是給出了另外一種使用SingularityCE的方法,在嘗試過(guò)程中遇到困難,在此記錄一下。

0. 平臺(tái)版本和思路

  • 平臺(tái)和軟件
    • MacOS
    • SingularityCE, ver. 4.1

這是官方文檔上面記載的,在此截取MacOS使用SingularityCE的部分

  • 思路
    • 在Mac中安裝Linux虛擬機(jī)(lima,brew install lima
    • 在Linux虛擬機(jī)中安裝和運(yùn)行SingularityCE

1. 配置文件準(zhǔn)備和軟件下載

虛擬機(jī)配置(官方)

  • 注意點(diǎn):掛載目錄(mount)一定要加入writable否則拉取鏡像后無(wú)法保存在本地(沒(méi)有系統(tǒng)寫入權(quán)限導(dǎo)致的)
  • ??下面是官方提供(掛載目錄沒(méi)有寫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

導(dǎo)致的報(bào)錯(cuò)

  • 無(wú)法保存文件(缺乏讀寫權(quán)限導(dǎo)致
讀寫錯(cuò)誤
  • 解決方案:在配置文件的mounts節(jié)點(diǎn)打開(kāi)寫入權(quán)限
解決方案

2. 運(yùn)行SingularityCE

  1. 啟動(dòng)虛擬機(jī)實(shí)例

根據(jù)配置文件啟動(dòng)(不需要加./代表當(dāng)前目錄否則啟動(dòng)失?。?/p>

limactl start singularity-ce.yml
  • 進(jìn)入虛擬機(jī)中進(jìn)行操作
#啟動(dòng)一個(gè)叫singularity-ce的虛擬機(jī)實(shí)例
limactl shell singularity-ce

  • 不進(jìn)入虛擬機(jī)中操作
#在虛擬機(jī)外直接拉取鏡像
limactl shell singularity-ce singularity pull cibersortx_fractions.sif docker://cibersortx/fractions:latest

關(guān)閉虛擬機(jī)

  • 如果想根據(jù)新配置啟動(dòng)鏡像,需要先把實(shí)例停止、刪除后才能生效
#step 1 stop instance
limactl stop singularity-ce

#step 2 delete instance
limactl delete singularity-ce

參考

官方文檔

原文地址

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容