Apptainer: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 19: Line 19:
* renamed all environment variables having <code>SINGULARITY</code> in their names to have <code>APPTAINER</code> in them,
* renamed all environment variables having <code>SINGULARITY</code> in their names to have <code>APPTAINER</code> in them,


Should you need to port scripts, etc. to Apptainer, know Apptainer version 1 is backwards compatible with Singularity --so such porting can be done incrementally.
Should you need to port scripts, etc. to Apptainer, know Apptainer version 1 is backwards compatible with Singularity so switching to Apptainer can be done incrementally.


=Using Apptainer=
=Using Apptainer=
Line 35: Line 35:
==Running Programs Within a Container==
==Running Programs Within a Container==


Text to come.
===Important Command Line Options===
 
Containers contain software (very likely) installed with a different environment, libraries, and tools than what is installed on a given system. It is, therefore, wise to run software within containers by '''not''' importing any environment settings or software defined outside of the container. By default Apptainer will run adopting the shell environment of the host which can create issues when executing programs within a container. When running Apptainer commands that execute programs installed inside the container, e.g., <code>apptainer run</code>, <code>apptainer shell</code>, <code>apptainer exec</code>, and </code>apptainer instance</code>, do consider using one of these options (with more preference to those options listed above other options):
 
{| class="wikitable"
|+Apptainer Environment Command Line Options
|-
! scope="col" |Option !! scope="col" | Description
|-
| <code>-C</code> || Isolates the running container from all file systems as well as the parent PID, IPC, and environment.
|-
| <code>-c</code> || Isolates the running container from most file systems only using a minimal <code>/dev</code>, an empty <code>/tmp</code> directory, and an empty <code>/home</code> directory.
|-
| <code>-e</code> || Cleans (some) shell environment variables before running container commands and applies settings for increased OCI/Docker compatibility. Using this option also implies the use of these options: <code>--containall</code>, <code>--no-init</code>, <code>--no-umask</code>, <code>--writable-tmpfs</code>.
|}
 
Not using any of these options will have the convenience of file systems being mounted and shell variables existing inside your container but be aware such can be the source of issues/errors when running software inside your container.
 
===Using GPUs===
 
When running software inside a container that requires the use of GPUs it is important to do the following:
* Ensure that you pass the <code>--nv</code> (for NVIDIA hardware) and <code>--rocm</code> (for AMD hardware) to Apptainer commands.
** These options will ensure the appropriate <code>/dev</code> entries are bind mounted inside the container.
** These options will locate and bind GPU-related libraries on the host (e.g., so such becomes bind-mounted inside the container) as well as setting the <code>LD_LIBRARY_PATH</code> environment variable to enable the aforementioned libraries will work inside the container.
* Ensure the application using the GPU inside the container was properly compiled to use the GPU and its libraries.
* If using OpenCL inside the container, besides using the mentioned options use the following bind mount: <code>--bind /etc/OpenCL</code>


===<code>apptainer run-help</code>===
===Container-Specific Help: <code>apptainer run-help</code>===


Text to come.
Text to come.


===<code>apptainer run</code>===
===Running Software (Preferred): <code>apptainer run</code>===


Text to come.
Text to come.


===<code>apptainer shell</code>===
===Interactively Running Software: <code>apptainer shell</code>===


Text to come.
Text to come.


===<code>apptainer exec</code>===
===Running Software (Basic): <code>apptainer exec</code>===


Text to come.
Text to come.


===<code>apptainer instance</code>===
===Running Daemons: <code>apptainer instance</code>===


Text to come.
Text to come.
cc_staff
156

edits

Navigation menu