#+TITLE: Créer des lots applicatifs avec Guix #+AUTHOR: Ludovic Courtès #+DATE: 2025-04-25 * le problème - faire tourner du code sur une machine sans Guix (par ex. supercalculateur) - fournir du code à des gens qui n’ont pas Guix (par ex. Docker) - faire des images Docker + facile et + petit qu’avec un =Dockerfile= :-) * et voilà =guix pack= - ✨ créée un lot applicatif à partir d’un paquet Guix ✨ - une foultitude de formats 👇 - 📦 /tarball/ (le plus simple ! le mieux !) - 🐋 Docker/OCI - 🍋 squashfs (Singularity/Apptainer) - 𑽎 =.deb= (Debian, Ubuntu, etc.) - ƒ =.rpm= (Fedora, CentOS, etc.) - Α AppImage - =guix pack -f FORMAT LOGICIEL …= * principe général - contenu de l’archive - les logiciels demandés et toutes leurs dépendances - un gros =/gnu/store= - souvent utile : créer des liens symboliques - typiquement =/bin= -> =/gnu/store/…-profile/bin= - 👉 =guix pack -S /bin=bin …= - pratique : choisir le format de compression - =gzip= par défaut, mais =zstd= est souvent le meilleur choix - 👉 =guix pack -C zstd …= - *démo* * 🐋 Docker ** aperçu #+BEGIN_SRC sh guix pack hwloc -S /bin=bin -f docker #+END_SRC Et du côté Docker : #+BEGIN_SRC sh docker load -i hwloc-pack.tar.gz # Assuming $IMAGE is the hash returned by 'docker load' above. docker run $IMAGE /bin/lstopo #+END_SRC ** point d’entrée #+begin_src sh guix pack hwloc -S /bin=bin \ --entry-point=bin/lstopo #+end_src ** réduire la duplication en utilisant des couches #+begin_src sh guix pack hwloc -S /bin=bin \ -f docker --max-layers=8 #+end_src * Singularity #+begin_src sh guix pack -f squashfs -S /bin=bin \ hwloc bash-minimal #+end_src * les /tarballs/ Ça marche partout ! ** binaires relogeables - 💡 extraire l’archive n’importe où dans l’arborescence - deux options - =guix pack -R= 👉 requiert les /unprivileged user namespaces/ - =guix pack -RR= 👉 3 possibilités, marche à tous les coups ! 1. user namespaces 2. PRoot (lent, mais efficace) 3. fakechroot (rapide, potentiellement moins « imperméable ») ** utilisation #+begin_src sh guix pack -RR hello -S /bin=bin #+end_src puis : #+begin_src sh tar xf pack.tar.gz ./bin/hello #+end_src ou, en choisant le /moteur d’exécution/ : #+begin_src sh GUIX_EXECUTION_ENGINE=performance ./bin/hello #+end_src * traçabilité - =guix pack --save-provenance …= - enregistre les canaux utilisés dans =/manifest= - cf. [[https://hpc.guix.info/static/doc/caf%C3%A9-guix/tournier-20250128.pdf][Café Guix du 28 janvier 2025 par Simon Tournier]] ! #+begin_src sh guix pack --save-provenance hello tar tvf /gnu/store/...-pack.tar.gz | grep -e -profile$ guix package -p /gnu/store/...-profile --export-channels #+end_src * spécificités HPC 🤲 Romain Garbage ! ** supercalculateurs nationaux (pas Guix !) | machine | *namespaces* | Singularity | Docker | |------------------+--------------+-------------+--------| | Adastra (CINES) | ✔ | ✔* | ❌ | | Jean-Zay (IDRIS) | ✔ | ✔ | ❌ | | Irène (TGCC) | ❌ | ❌ | pcocc | ** exemple MPI + ROCm sur Adastra *** création et copie de l’archive #+begin_src sh $ guix pack -C zstd -R \ -S /libexec=libexec \ -S /bin=bin \ -S /etc=etc \ osu-micro-benchmarks-cuda slurm [...] /gnu/store/[...]-osu-micro-benchmarks-rocm-slurm-tarball-pack.tar.zst $ scp /gnu/store/[...]-osu-micro-benchmarks-rocm-slurm-tarball-pack.tar.zst \ user@adastra:/path/to/$CCFRWORK/guix-pack.tar.zst #+end_src *** extraction de l'archive #+begin_src sh $ cd $CCFRWORK && mkdir -p guix-pack \ && zstd -d guix-pack.tar.zst \ && tar xf guix-pack.tar -C $CCFRWORK/guix-pack #+end_src *** ⚠ désactivation du plugin Lua dans la configuration de SLURM #+begin_src sh $ cp /etc/slurm/slurm.conf ~ $ sed -i ~/slurm.conf -es'/^PlugStack/# PlugStack/g' #+end_src *** positionnement des variables d'environnement #+begin_src sh $ export GUIX_PROFILE=$CCFRWORK/guix-pack $ source $GUIX_PROFILE/etc/profile $ unset LD_LIBRARY_PATH $ export SLURM_CONF=~/slurm.conf #+end_src *** test de communication entre 2 GPUs sur le même nœud en utilisant RCCL #+begin_src sh $ $GUIX_PROFILE/bin/srun -A user --time=00:05:00 --constraint=MI250 \ --nodes=1 --ntasks-per-node=2 --cpus-per-task=1 --gpus-per-node=2 \ --mpi=pmix \ $GUIX_PROFILE/libexec/osu-micro-benchmarks/xccl/pt2pt/osu_xccl_bw \ -d rocm D D [...] #Using RCCL # Send Buffer on DEVICE (D) and Receive Buffer on DEVICE (D) # Size Bandwidth (MB/s) [...] 2097152 14611.61 4194304 14943.06 #+end_src ** exemple MPI + CUDA 💩 sur Jean-Zay *** création et copie de l’archive #+begin_src sh $ guix pack -C zstd -R \ -S /libexec=libexec \ -S /bin=bin \ -S /etc=etc \ osu-micro-benchmarks-cuda slurm $ scp /gnu/store/[...]-osu-micro-benchmarks-cuda-slurm-tarball-pack.tar.zst \ user@jean-zay:/path/to/$WORK/guix-pack.tar.zst #+end_src *** extraction de l'archive #+begin_src sh $ cd $WORK && mkdir -p guix-pack \ && zstd -d guix-pack.tar.zst \ && tar xf guix-pack.tar -C guix-pack $ export GUIX_PROFILE=$WORK/guix-pack $ source $GUIX_PROFILE/etc/profile $ unset LD_LIBRARY_PATH #+end_src *** test de communication entre 2 GPUs sur le même nœud en utilisant NCCL #+begin_src sh $ $GUIX_PROFILE/bin/srun -A project@v100 --time=00:05:00 \ --nodes=1 --ntasks-per-node=2 --cpus-per-task=1 --gres=gpu:2 \ env LD_PRELOAD="/usr/lib64/libcuda.so /usr/lib64/libnvidia-ml.so" \ PSM2_GPUDIRECT=1 PSM2_CUDA=1 \ $GUIX_PROFILE/libexec/osu-micro-benchmarks/xccl/pt2pt/osu_xccl_bw D D [...] #Using NCCL [...] # Send Buffer on DEVICE (D) and Receive Buffer on DEVICE (D) # Size Bandwidth (MB/s) [...] 2097152 35534.99 4194304 39434.92 #+end_src * en résumé - 📦 → 🐋 🍋 𑽎 ƒ ✨ 🤘 * références - [[https://guix.gnu.org/manual/devel/fr/html_node/Invoquer-guix-pack.html][manuel de référence]] - [[https://hpc.guix.info/static/doc/caf%C3%A9-guix/tournier-20250128.pdf][Café Guix de Simon Tournier, 28 janvier 2025]] (traçabilité, etc.) - [[https://hpc.guix.info/events/2024/workshop/video/d%C3%A9ploiement-logiciel-sur-les-supercalculateurs-nationaux-avec-guix-un-retour-d-exp%C3%A9rience/][présentation de Romain Garbage, 7 novembre 2024]] (HPC) - [[https://hpc.guix.info/events/2024/workshop/video/retour-d-exp%C3%A9rience-sur-l-utilisation-de-guix-dans-le-cadre-d-un-programme-de-recherche/][présentation de Benjamin Arrondeau, 7 novembre 2024]] (images Docker en CI/CD)