singularity container

Menu


GPU があるかどうかを確認する

確認するだけなら、

    $ singularity shell -nv --shell /bin/zsh  /mnt/ie-virsh/singularity/os_complete/os_complete.sif
    Singularity> nvidia-smi 
    Fri Sep 24 11:15:37 2021       
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 450.142.00   Driver Version: 450.142.00   CUDA Version: 11.0     |
    |-------------------------------+----------------------+----------------------+
    | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    |                               |                      |               MIG M. |
    |===============================+======================+======================|
    |   0  Tesla V100S-PCI...  Off  | 00000000:3B:00.0 Off |                    0 |
    | N/A   37C    P0    36W / 250W |      0MiB / 32510MiB |      0%      Default |
    |                               |                      |                  N/A |
    +-------------------------------+----------------------+----------------------+
                                                                                   
    +-----------------------------------------------------------------------------+
    | Processes:                                                                  |
    |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
    |        ID   ID                                                   Usage      |
    |=============================================================================|
    |  No running processes found                                                 |
    +-----------------------------------------------------------------------------+


daru 上で slum を使う

pytorch のイメージを pull

    singularity pull --docker-login docker://localhost:5000/pytorch:latest

または
    singularity pull --docker-login docker://pytorch/pytorch:latest

localhost:5000 は学科のコンテナレジストリ

MNIST の exsample をホームディレクトリに clone

    git clone https://github.com/pytorch/examples.git

以下の batch を作って

    #!/bin/bash
    #SBATCH --job-name mnist 
    #SBATCH --output logs/%x-%j.log
    #SBATCH --error logs/%x-%j.err
    #SBATCH --nodes 1
    #SBATCH --gpus tesla:1
    date
    singularity exec --nv pytorch_latest.sif python examples/mnist/main.py
    date

Slurm で Job を投下
      sbatch mnist.sbatch

GPUが混んでる時には gpu をはずそう

    #!/bin/bash
    #SBATCH --job-name mnist 
    #SBATCH --output logs/%x-%j.log
    #SBATCH --error logs/%x-%j.err
    #SBATCH --nodes 1
    date
    singularity exec pytorch_latest.sif python examples/mnist/main.py
    date

以下はオプションにします。


singularity image の作り方

ここを参考に サーバ上にいろいろおいてある。それが使えるならそれで良い。

    % ls /mnt/ie-virsh/singularity 
    README.md  alpine-latex/  cbc_gcc/        cbc_llvm/   erlang/        flexgen/  os_complete/  reading/     stable_diffusion/  teachers/   xv6/
    agda/      camelot.sif*   cbc_gcc_cross/  cbcgcc_vs/  fedora-debug/  hugo/     rails/        rust-debug/  students/          templates/  xv6-podman/

作業ディレクトリを作成して、そこで

    singularity pull --docker-login ubuntu:20.04

とする。

学科のrepositoryに何があるかはamaneで

    ls /ie-ryukyu/podman/registry/registry/docker/registry/v2/repositories

とするとわかります。


apt-install は このままではできない

vim も入ってない。apt-install vim は失敗する。root じゃないから。

test.def という以下のファイルを作る

    BootStrap: docker
    From: ubuntu:20.04
    %post
        apt-get update
        apt-get -y upgrade
        apt-get -y install build-essential vim

以下を実行する

    % singularity build --fakeroot test.sif test.def

すると
    % singularity shell test.sif  
    Singularity> vim

で vim が動作する


rust を入れてみる

   Singularity>  apt search rust

rustc だというのがわかるので、

   Singularity>  apt-get install rustc

でもやっぱりだめ。

    % singularity shell --fakeroot test.sif  

でもだめ。

    %  singularity shell --fakeroot  --writable  test.sif

これで、なかから、
   Singularity>  apt-get update
   Singularity>  apt-get install rustc

で rust が入る。
   Singularity>  mkdir rust; cd rust ; cargo new hello_world --bin

でも、これでは抜けたあと、全部消えてしまう。なのでやっぱり、build しないと繰り返し使えない。

    BootStrap: docker
    From: ubuntu:20.04
    %post
        apt-get update
        apt-get -y upgrade
        apt-get -y install build-essential vim
        apt-get -y install rustc

で build しなおす。

でも、これやる必要なくて、既に誰かが作ったものを使えば良い。

  % singularity build --sandbox --fakeroot test/ test.def
  % singularity shell --fakeroot --writable test

と sanbox でやっても良い。これだと install 履歴は command に残らない。あと、かなり遅い。

   daru:/mnt/nvme0/singuralrity/students/e2175xx

などを作ってやると少し早いかも。


オプション macOS 上の lima

macOS のlimaを使うと、singularity container を動かせる


singularity の速度

singularity 内のfileは singularity のAUFS上に作られている。それがどこかを lsof commnad で調べよ。

singularity 環境下で FileWrite.jar を用いてファイルの書き込み時間を測定する。以下の二種類の測定を行う。

    singularity 内の file system に対して測定を行う
    -v ~/tmp/os:/mnt/os などで singularity からsingularityの外のdirectoryを共有して測定を行う

Shinji KONO / Fri Oct 27 14:06:29 2023