cc_staff
156
edits
Line 118: | Line 118: | ||
===Running Software (Preferred): <code>apptainer run</code>=== | ===Running Software (Preferred): <code>apptainer run</code>=== | ||
The <code>apptainer run</code> command will launch an Apptainer container, run the <code>%runscript</code> defined for that container (if one is defined), and then run the specific command (subject to the code in the <code>%runscript</code> script). Using this command is preferred over using the <code>apptainer exec</code> command which directly runs a command within the specified container. | |||
For example, suppose you wanted to run the <code>g++</code> compiler inside your container to compile a C++ program called <code>myprog.cpp</code>. To this this you might run this: | |||
apptainer run your-container-name.sif g++ -O2 -march=broadwell ./myprog.cpp | |||
where: | |||
* <code>your-container-name.sif</code> is the name of your SIF file | |||
* <code>g++ -O2 -march=broadwell ./myprog.cpp</code> is the command you want to run inside the container | |||
On our clusters, you will likely need to use a number of additional options (that appear after <code>run</code> and before <code>your-container-name.sif</code>). These options will include <code>-C</code>, <code>-c</code>, <code>-e</code>, <code>-W</code> as well as various bind mount options to make your disk space available to the programs that run in your container. For example, a more complete command might be: | |||
apptainer run -C -W $SLURM_TMPDIR -B /home -B /project -B /scratch your-container-name.sif g++ -O2 -march=broadwell ./myprog.cpp | |||
For more information on these options see the following sections on this page: | |||
* text to come | |||
as well as the [http://apptainer.org/docs/user/main/index.html official Apptainer documentation]. | |||
===Interactively Running Software: <code>apptainer shell</code>=== | ===Interactively Running Software: <code>apptainer shell</code>=== |