Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
# izgradnja kontejnera
[korisnik@kompjuter:~] $ apptainer build ubuntu_20.04.sif docker://ubuntu:20.04
...
INFO: Creating SIF file

# sadržaj trenutnog direktorija
[korisnik@kompjuter:~] $ ls -lrt
total 27100
-rwxr-xr-x 1 korisnik korisnik 27746304 svi  23 08:47 ubuntu_20.04.sif

...

Code Block
languagebash
# izgradnja sandbox verzije
[korisnik@kompjuter:~] $ apptainer build --sandbox ubuntu_20.04 docker://ubuntu:20.04
...
INFO:    Creating sandbox directory...
INFO:    Build complete: ubuntu_20.04

# sadržaj trenutnog direktorija
[korisnik@kompjuter:~] $ ls -l
total 27104
drwxr-xr-x 18 korisnik korisnik     4096 svi  23 09:05 ubuntu_20.04
-rwxr-xr-x  1 korisnik korisnik 27746304 svi  23 08:47 ubuntu_20.04.sif

...

Code Block
languagebash
# prebacivanje sandbox verzije u image
[korisnik@kompjuter:~] $ sudo apptainer build ubuntu_20.04.sif ubuntu_20.04/
...
INFO:    Creating SIF file...
INFO:    Build complete: ubuntu_20.04.sif

# sadržaj trenutnog direktorija
[korisnik@kompjuter:~] $ ls -l
total 154496
drwxr-xr-x 18 korisnik korisnik      4096 svi  23 09:51 ubuntu_20.04
-rwxr-xr-x  1 korisnik korisnik 158195712 svi  23 09:58 ubuntu_20.04.sif

...

Code Block
languagebash
# ispis definicijske datoteke
[korisnik@kompjuter:~] $ cat ubuntu_20.04.def 
Bootstrap: docker
From: ubuntu:20.04

%post
  apt update
  apt install python3-pip -y

# izgradnja imagea iz definicijske datoteke
[korisnik@kompjuter:~] $ apptainer build ubuntu_20.04.sif ubuntu_20.04.def 
...
INFO:    Creating SIF file...
INFO:    Build complete: ubuntu_20.04.sif

# sadržaj trenutnog direktorija
[korisnik@kompjuter:~] $ ls -l
total 154504
drwxr-xr-x 18 korisnik korisnik      4096 svi  23 09:51 ubuntu_20.04
-rw-r--r--  1 korisnik korisnik        87 svi  23 10:22 ubuntu_20.04.def
-rwxr-xr-x  1 korisnik korisnik 158195712 svi  23 10:34 ubuntu_20.04.sif

...

Code Block
languagebash
# ispis verzije pythona na računalu
[korisnik@kompjuter:~] $ python3 --version
Python 3.9.2

# ispis verzije pythona u kontejneru
[korisnik@kompjuter:~] $ apptainer exec ubuntu_20.04.sif python3 --version
INFO:    /etc/singularity/ exists; cleanup by system administrator is not complete (see https://apptainer.org/docs/admin/latest/singularity_migration.html)
INFO:    underlay of /etc/localtime required more than 50 (86) bind mounts
Python 3.8.10

...

Code Block
languagebash
# ispis definicijske datoteke
[korisnik@kompjuter:~] $ cat ubuntu_20.04.def
Bootstrap: docker
From: ubuntu:20.04

%post
  apt update
  apt install python3-pip -y

%runscript
  exec python3 $@

# izgradnja imagea iz definicijske datoteke
[korisnik@kompjuter:~] $ apptainer build ubuntu_20.04.sif ubuntu_20.04.def
...
INFO:    Build complete: ubuntu_20.04.sif

[korisnik@kompjuter:~] $ ./ubuntu_20.04.sif --version
Python 3.8.10

...

Code Block
languagebash
# izgradnja sandbox verzije
[korisnik@kompjuter:~] $ apptainer build --sandbox data_stack_sandbox docker://ubuntu:20.04
...
INFO:    Creating sandbox directory...
INFO:    Build complete: data_stack_sandbox

# sadržaj trenutnog direktorija
[korisnik@kompjuter:~] $ ls -l
total 154520
drwxr-xr-x 18 korisnik korisnik      4096 svi  23 16:33 data_stack_sandbox
drwxr-xr-x 18 korisnik korisnik      4096 svi  23 09:51 ubuntu_20.04
-rw-r--r--  1 korisnik korisnik       119 svi  23 15:17 ubuntu_20.04.def
-rwxr-xr-x  1 korisnik korisnik 158208000 svi  23 15:24 ubuntu_20.04.sif

...

Code Block
languagebash
# prebacivanje sandbox verzije u image
[korisnik@kompjuter:~] $ sudo apptainer build data_stack.sif data_stack_sandbox/
...
INFO:    Build complete: data_stack.sif

# veličine verzija sandbox i image
[korisnik@kompjuter:~] $ du -hcs data_stack*
832M	data_stack_sandbox
272M	data_stack.sif
1.1G	total

# dopremanje image verzije na Supek
[korisnik@kompjuter:~] $ scp data_stack.sif mkvakic@login-gpu.hpc.srce.hr:.
data_stack.sif														   100%  272MB 111.0MB/s   00:02m

...

Code Block
languagebash
# login na pristupni poslužitelj gpu
[korisnik@kompjuter:~] $ ssh korisnik@login-gpu.hpc.srce.hr
Last login: Wed May 24 08:16:00 2023 from x.x.x.x

# sadržaj korisničkog direktorija
[korisnik@kompjuter:~] $ ls -l
total 278088
-rwxr-xr-x  1 mkvakic hpc 284729344 May 24 08:02 data_stack.sif

# pokretanje dopremljenog imagea na Supeku
[korisnik@kompjuter:~] $ apptainer exec data_stack.sif python3 --version
Python 3.8.10

...

Code Block
languagebash
linenumberstrue
# ispis definicijske datoteke
[korisnik@kompjuter:~] $ cat data_stack.def
Bootstrap: docker
From: ubuntu:20.04

%post
  apt update
  apt install python3-pip -y
  pip3 install numpy scipy pandas matplotlib ipython

%runscript
  exec python3 $@

# izgradnja imagea
[korisnik@kompjuter:~] $ apptainer build data_stack.sif data_stack.def
...
INFO:    Creating SIF file...
INFO:    Build complete: data_stack.sif

# dopremanje na Supeka
[korisnik@kompjuter:~] $ scp data_stack.sif mkvakic@login-gpu.hpc.srce.hr:.
data_stack.sif      100%  335MB 110.9MB/s   00:03

# login na pristupni poslužitelj gpu
[korisnik@kompjuter:~] $ ssh mkvakic@login-gpu.hpc.srce.hr
Last login: Wed May 24 09:18:44 2023 from x.x.x.x

# direktno izvršavanje imagea na Supeku
[korisnik@x3000c0s27b0n0] $ ./data_stack.sif --version
Python 3.8.10

...

Code Block
languagebash
# izgradnja sandbox verzije
[korisnik@kompjuter:~] $ sudo apptainer build --force --sandbox data_stack_sandbox docker://ubuntu:20.04
...

# otvaranje interaktivne sjednice u sandbox kontejneru
[korisnik@kompjuter:~] $ sudo apptainer shell --writable data_stack_sandbox/

# osvježavanje apt repozitorija
Apptainer> apt update
...

# instalacija curl
Apptainer> apt install curl -y
...

# preuzimanje Miniforge conde
Apptainer> curl -L -O https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
...
100 82.9M  100 82.9M    0     0  30.7M      0  0:00:02  0:00:02 --:--:-- 42.0M

# batch instalacija u /usr/local/miniforge
Apptainer> bash Miniforge3-Linux-x86_64.sh -b -p /usr/local/miniforge
...
installation finished.

...

Code Block
languagebash
# ispis verzije i staze __init__.py datoteke knjižnice matplotlib u kontejneru
[korisnik@kompjuter:~] $ apptainer exec data_stack_sandbox/ /usr/local/miniforge/envs/data_stack/bin/python3 -c 'import matplotlib; print("matplotlib verzija je: ", matplotlib.__version__); print("matplotlib __init__ datoteka je:", matplotlib.__file__)'
...
matplotlib verzija je:  3.7.1
matplotlib __init__ datoteka je: /usr/local/miniforge/envs/data_stack/lib/python3.10/site-packages/matplotlib/__init__.py

...