{"id":112638,"date":"2018-02-07T16:25:47","date_gmt":"2018-02-07T21:25:47","guid":{"rendered":"http:\/\/www.bu.edu\/tech\/?page_id=112638"},"modified":"2025-03-04T09:23:42","modified_gmt":"2025-03-04T14:23:42","slug":"singularity","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/tech\/support\/research\/software-and-programming\/containers\/singularity\/","title":{"rendered":"Using Singularity"},"content":{"rendered":"<p><a name=\"top\"><\/a><\/p>\n<div style=\"width: 85%;\">\n<div style=\"float: right; width: 40%;\"><img loading=\"lazy\" src=\"\/tech\/files\/2024\/01\/singularity-e1706624540369.png\" alt=\"\" width=\"293\" height=\"151\" class=\"alignnone size-full wp-image-150145\" \/><\/div>\n<div style=\"float: none;\"><strong>Sections<\/strong><\/p>\n<ul>\n<li><a href=\"#command\">Singularity on the SCC<\/a><\/li>\n<li><a href=\"#wrap\">Wrapper for Singularity<\/a><\/li>\n<li><a href=\"#interactive\">Interactive Usage<\/a><\/li>\n<li><a href=\"#batch\">Batch\u00a0Usage<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><a name=\"command\"><\/a>Singularity on the SCC<\/h2>\n<p>The standard singularity software is installed in <code>\/opt\/singularity<\/code>.<\/p>\n<p>The main command for using singularity is <code>\/opt\/singularity\/bin\/singularity<\/code> and can be called directly with <code><span class=\"command\">singularity<\/span><\/code>. Please refer to Singularity documentation at <a href=\"http:\/\/singularity.lbl.gov\/\"> http:\/\/singularity.lbl.gov\/<\/a> for general use information.<\/p>\n<h2><a name=\"wrap\"><\/a>Wrapper for Singularity<\/h2>\n<p>In order to facilitate integration with the SCC, we provide a command wrapper <code><span class=\"command\">scc-singularity<\/span><\/code>:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">scc-singularity run my_container.sif<\/span><\/code><\/pre>\n<p>The wrapper is available on the PATH for general use and provides the following features:<\/p>\n<ol>\n<li>Automatically binds:\n<ul>\n<li>user&#8217;s home directory<\/li>\n<li>user&#8217;s project spaces<\/li>\n<li>the node(s) <code>\/scratch<\/code><\/li>\n<li><code>\/usr\/local<\/code><\/li>\n<li><code>\/share<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Preserves and passes into the container SCC environment variables:\n<ul>\n<li><code>DISPLAY<\/code><\/li>\n<li><code>NSLOTS<\/code><\/li>\n<li><code>TMPDIR<\/code><\/li>\n<li><code>USER<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Will detect if using GPU(s) and pass <code>CUDA_VISIBLE_DEVICES<\/code> into the container.<\/li>\n<\/ol>\n<p>If the container has code installed into its own <code>\/usr\/local<\/code> directory, then pass the <code>--nolocal<\/code> flag to scc-singularity:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">scc-singularity --nolocal run my_container.sif<\/span><\/code><\/pre>\n<p>The <code>--scc-preview<\/code> and <code>--scc-debug<\/code> commands can be used to print out the command executed by the <code>scc-singularity<\/code> wrapper:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">scc-singularity --scc-preview run my_container.sif<\/span>\r\n\/usr\/bin\/singularity run -e  -B \/share -B \/usr1 -B \/usr2 -B \/usr3 -B \/usr4 -B \/var\/spool\/sge -B \/project -B \/projectnb -B \/projectnb2 -B \/scratch -B \/net -B \/ad -B \/usr\/local -B \/var\/lib\/dbus\/machine-id my_container.sif\r\npreview mode - command not executed\r\n<\/code><\/pre>\n<h2><a name=\"interactive\"><\/a>Interactive Usage<\/h2>\n<p>Singularity can be used to run a shell interactively inside a container. This is accomplished using the <code><span class=\"command\">shell<\/span><\/code> subcommand. To try these commands, first get a copy of a container running the Debian 11 operating system from the Sylabs container library. This will create a container file called <code><b>debian_11.sif<\/b><\/code>:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">singularity pull library:\/\/debian:11<\/span><\/code><\/pre>\n<p>Now try to run the container:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">singularity shell<\/span> <span class=\"placeholder\">debian_11.sif<\/span>\r\n<span class=\"prompt\">Singularity&gt;<\/span> <span class=\"command\">grep<\/span> <span class=\"placeholder\">PRETTY_NAME \/etc\/os-release<\/span>\r\nPRETTY_NAME=\"Debian GNU\/Linux 11 (bullseye)\"<\/code><\/pre>\n<p>It is important to note that standard &#8220;shell&#8221; mode will not provide full environment settings required to interact with modules and other SCC provided features.<\/p>\n<p>The <code><span class=\"command\">scc-singularity<\/span><\/code> command has an additional subcommand <code><span class=\"command\">myshell<\/span><\/code> which invokes your default login shell with your complete login environment.<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">scc-singularity myshell<\/span> <span class=\"placeholder\">debian_11.sif<\/span><\/code><\/pre>\n<p>&nbsp;<\/p>\n<h2><a name=\"batch\"><\/a>Batch Usage<\/h2>\n<p>There are two main subcommands for running Singularity in batch: <code><span class=\"command\">exec<\/span><\/code> and <code><span class=\"command\">run<\/span><\/code>.<\/p>\n<ul>\n<li>Use the <code><span class=\"command\">exec<\/span><\/code> subcommand to execute the specified command within the container.\n<pre><code class=\"code-block\">#!\/bin\/bash -l\r\n#$ -P proj_name\r\n#$ -N singularity_exec\r\n#$ -j y\r\n# Run the container and execute a command within it.\r\nscc-singularity exec debian_11.sif grep PRETTY_NAME \/etc\/os-release <\/code><\/pre>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>Use the <code><span class=\"command\">run<\/span><\/code> subcommand to run the command that the container is pre-configured to run.\n<pre><code class=\"code-block\">#!\/bin\/bash -l\r\n#$ -P proj_name\r\n#$ -N singularity_run\r\n#$ -j y\r\n# Run the container and run its preconfigured command.\r\nscc-singularity run debian_11.sif<\/code><\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Sections Singularity on the SCC Wrapper for Singularity Interactive Usage Batch\u00a0Usage &nbsp; Singularity on the SCC The standard singularity software is installed in \/opt\/singularity. The main command for using singularity is \/opt\/singularity\/bin\/singularity and can be called directly with singularity. Please refer to Singularity documentation at http:\/\/singularity.lbl.gov\/ for general use information. Wrapper for Singularity In order&#8230;<\/p>\n","protected":false},"author":3593,"featured_media":0,"parent":112635,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/112638"}],"collection":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/users\/3593"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/comments?post=112638"}],"version-history":[{"count":26,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/112638\/revisions"}],"predecessor-version":[{"id":156170,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/112638\/revisions\/156170"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/112635"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/media?parent=112638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}