{"id":1252,"date":"2023-10-25T13:38:26","date_gmt":"2023-10-25T13:38:26","guid":{"rendered":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/?page_id=1252"},"modified":"2023-10-25T13:38:26","modified_gmt":"2023-10-25T13:38:26","slug":"singularity","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/software\/applications\/singularity\/","title":{"rendered":"Singularity"},"content":{"rendered":"<h2>Overview<\/h2>\n<p><a href=\"https:\/\/www.sylabs.io\/docs\/\">Singularity<\/a> provides a mechanism to run containers where containers can be used to package entire scientific workflows, software and libraries, and even data.<\/p>\n<p>Version 3.8.6-1 is installed on the iCSF.<\/p>\n<h2>Restrictions on use<\/h2>\n<p>The software is licensed under the BSD 3-clause &#8220;New&#8221; or &#8220;Revised&#8221; <a href=\"https:\/\/github.com\/singularityware\/singularity\/blob\/master\/LICENSE.md\">License<\/a>.<\/p>\n<h2>Set up procedure<\/h2>\n<p><strong>Please note:<\/strong> you no longer need to use a modulefile. We have installed singularity as a system-wide command. So you can simply run the singularity commands you wish to run without loading any modulefiles.<\/p>\n<p>For example:<\/p>\n<pre># Ensure you have NO singularity modulefiles loaded ('module purge' will unload all modulefiles)\r\n\r\n[<em>username<\/em>@incline34 ~]$ singularity --version\r\nsingularity version 3.8.6-1.el7\r\n<\/pre>\n<h2>Running the application<\/h2>\n<p>You may run the command on its own to obtain a list of flags:<\/p>\n<pre>singularity\r\nUSAGE: singularity [global options...] <command><\/command> [command options...] ...\r\n\r\nONTAINER USAGE COMMANDS:\r\n    exec       Execute a command within container                               \r\n    run        Launch a runscript within container                              \r\n    shell      Run a Bourne shell within container                              \r\n    test       Launch a testscript within container                             \r\n\r\nCONTAINER MANAGEMENT COMMANDS:\r\n    apps       List available apps within a container                           \r\n    bootstrap  *Deprecated* use build instead                                   \r\n    build      Build a new Singularity container                                \r\n    check      Perform container lint checks                                    \r\n    inspect    Display container's metadata                                     \r\n    mount      Mount a Singularity container image                              \r\n    pull       Pull a Singularity\/Docker container to $PWD\r\n<\/pre>\n<p>Please note that users will not be permitted to run singularity containers in <code>--writeable<\/code> mode. You should build containers on your own platform where you have root access.<\/p>\n<h3>Running a container image<\/h3>\n<pre>\r\nsingularity run mystack.simg\r\n<\/pre>\n<h2>Further info<\/h2>\n<ul>\n<li><a href=\"http:\/\/singularity.lbl.gov\/docs\">Singularity Documentation<\/a><\/li>\n<\/ul>\n<h2>Using your own containers<\/h2>\n<p>You may want to use your own containers on the iCSF &#8211; that&#8217;s fine. You will need to have the &#8216;\/scratch&#8217; directory within the container to bind to the &#8216;\/scratch&#8217; directory on the iCSF.<\/p>\n<p>If building from a .def file, please include the line<\/p>\n<pre>\r\n%post\r\n...\r\nmkdir \/scratch\r\n<\/pre>\n<p>in the &#8220;%post&#8221; section.<\/p>\n<p>If using a prebuilt sif (or simg), then follow the steps below to rebuild with a &#8216;\/scratch&#8217; directory within:<\/p>\n<pre>\r\n# You must run these commands on your own Linux system (you don't have sudo rights on the iCSF)\r\nsudo singularity build --sandbox mysandbox myimage.sif\r\nsudo mkdir mysandbox\/scratch\r\nsudo singularity build myimage-icsf.sif mysandbox\r\n<\/pre>\n<p>Please note this will <strong>not<\/strong> work on the iCSF &#8211; as you cannot have sudo (admin) rights. The steps are necessary <em>before<\/em> the image is used on the iCSF. If you cannot, we can do this for you: <a href=\"&#x6d;&#97;i&#x6c;&#x74;&#111;:&#x69;&#x74;&#115;-&#x72;&#105;-&#x74;&#x65;&#97;m&#x40;&#x6d;&#97;n&#x63;&#104;&#101;&#x73;&#x74;&#101;r&#x2e;&#x61;&#99;&#46;&#x75;&#107;\">&#x69;&#x74;&#115;-r&#x69;&#x2d;&#116;&#101;a&#x6d;&#x40;&#109;&#97;n&#x63;&#x68;&#x65;&#115;te&#x72;&#x2e;&#97;&#99;&#46;&#x75;&#x6b;<\/a>.<\/p>\n<h3>Converting from a Docker container<\/h3>\n<p>Many Docker images exist that can be converted to singularity images, then uploaded to the iCSF and run. As before, these steps must be completed on your own machine with a singularity \/ apptainer install.<br \/>\nThe example below uses <a href=\"https:\/\/hub.docker.com\/r\/cp2k\/cp2k\/\">https:\/\/hub.docker.com\/r\/cp2k\/cp2k\/<\/a>.<\/p>\n<pre>\r\n# You must run these commands on your own Linux system (you don't have sudo rights on the iCSF)\r\nsudo singularity build cp2k.sif docker:\/\/cp2k\/cp2k\r\nsingularity run cp2k.sif cp2k --version | head -1\r\n# returns 'CP2K version 2023.1', which we use to label\r\nsudo singularity build --sandbox cp2k-2023.1-sandbox cp2k.sif \r\nsudo mkdir cp2k-2023.1-sandbox\/scratch\r\nsudo singularity build cp2k-2023.1-csf.sif cp2k-2023.1-sandbox\r\n<\/pre>\n<p>The <code>cp2k-2023.1-csf.sif<\/code> can then be uploaded and run on the iCSF.<\/p>\n<p>Please remember to bind scratch (and also \/mnt which will make your home directory available) and run your jobs from there:<\/p>\n<pre>\r\nsingularity run --bind \/scratch:\/scratch,\/mnt:\/mnt my_container.sif <em>arg1 arg2 ...<\/em>\r\n<\/pre>\n<p>Alternatively, you can set the following environment variable:<\/p>\n<pre>\r\nexport SINGULARITY_BINDPATH=\"\/scratch,\/mnt\"\r\nsingularity run my_container.sif <em>arg1 arg2 ...<\/em>\r\n<\/pre>\n<h3>Building your own Singularity image<\/h3>\n<p>You can build your own sifs for use on the iCSF via the online resource: <a href=\"https:\/\/cloud.sylabs.io\/builder\">https:\/\/cloud.sylabs.io\/builder<\/a><\/p>\n<p>Please remember to include <\/p>\n<pre>mkdir \/scratch<\/pre>\n<p> in the definition instructions. Be aware also that this resource is not affiliated with The University of Manchester.<\/p>\n<h2>Updates<\/h2>\n<p>None.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview Singularity provides a mechanism to run containers where containers can be used to package entire scientific workflows, software and libraries, and even data. Version 3.8.6-1 is installed on the iCSF. Restrictions on use The software is licensed under the BSD 3-clause &#8220;New&#8221; or &#8220;Revised&#8221; License. Set up procedure Please note: you no longer need to use a modulefile. We have installed singularity as a system-wide command. So you can simply run the singularity commands.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/software\/applications\/singularity\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":43,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1252","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/1252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/comments?post=1252"}],"version-history":[{"count":1,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/1252\/revisions"}],"predecessor-version":[{"id":1253,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/1252\/revisions\/1253"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/43"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/media?parent=1252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}