Problems with Apptainer#
By default the Apptainer binds certain volumes and imports all the environment variables from the host system.
A list of what is binded: https://apptainer.org/docs/user/main/bind_paths_and_mounts.html#system-defined-bind-paths
The
/usr/local/etc/apptainer/apptainer.confallows the administrator to modify the default behavoiour.You can use
--no-mountflag to manually disable the volume mounting and--bindto only bind specific volumes as follows:
apptainer shell --no-mount hostfs,tmp,sys,dev,proc,sys,devpts,home,slave --bind "$(pwd)":/data modulus.img
This automatic binding is complete madness. Recently, I modified the $HOME/.bashrc inside the Apptainer image and It broke my Host system’s Python installation. So, It is better to stop all the automatic volume binding.
One can disable all the automatic volume binds using
--containflag. The specific documentation.One can also disable the environment variables import using
--cleanenvor-e. The specific documenation.
If we don’t disable the environment propagation, the image will always point to the Host computer’s HOME directory. See the following output wher I compared an Apptainer image with a Docker image.
(base) hell@Dell-Precision-T7910:~/Desktop/PhD/PhD work/PINNs/12. August 2022/5.
Week 5 (3 days)/Deepxde apptainer image/deepxde/apptainer$ docker run -it nvcr.io/nvidia/pytorch:22.05-py3
NVIDIA Release 22.05 (build 37432893)
PyTorch Version 1.12.0a0+8a1a93a
root@528346ef88a7:/workspace# $HOME
bash: /root: Is a directory
Running the Modulus Apptainer image#
[s.1915438@sl2 modulus_apptainer]$ apptainer shell --contain --cleanenv modulus.img
Nvidia Modulus 22.07 Apptainer image
Apptainer> python
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pysdf.sdf
>>> import torch
>>> import modulus
>>>
Using the GPU#
One can use the GPU inside the Apptainer image using --nv flag.
So the command will look like this:
apptainer shell --nv --contain --cleanenv --bind "$(pwd)":/data,/tmp:/tmp modulus.img
Here we can replace shell with shell or exec. A similar documentation.
Downloading Modulus examples#
If we don’t download Modulus example repository with Git LFS we will get this error. So first install Git LFS from this page. After running the install.sh file, run git lfs install in the terminal. Then pull the Modulus exanple using git clone
Testing the Modulus Apptainer image#
Checking GPU#
Simple LDC problem#
Tessellation library based problem with NVIDIA OPTIX for accelerated SDF computation#
Apptainer supports guest pull from NVIDIA NGC#
Now Apptainer allows guest pull. I wasn’t able to accomplish this.