Apptainer: Difference between revisions
No edit summary |
|||
Line 71: | Line 71: | ||
<pre> | <pre> | ||
$ | $ apptainer pull gpudocker.sif docker://registry.umiacs.umd.edu/derek/gpudocker | ||
INFO: Converting OCI blobs to SIF format | INFO: Converting OCI blobs to SIF format | ||
INFO: Starting build... | INFO: Starting build... | ||
Getting image source signatures | Getting image source signatures | ||
Copying blob | Copying blob 85386706b020 done | ||
Copying blob 45d437916d57 done | |||
Copying blob | Copying blob c1bbdc448b72 done | ||
Copying blob d8f1569ddae6 done | |||
Copying blob | Copying blob 7ddbc47eeb70 done | ||
Copying blob 8c3b70e39044 done | |||
Copying blob | Copying blob ee9b457b77d0 done | ||
Copying blob be4f3343ecd3 done | |||
Copying blob | Copying blob 30b4effda4fd done | ||
Copying blob b6f46848806c done | |||
Copying blob | Copying blob 44845dc671f7 done | ||
Copying config 1b2e5b7b99 done | |||
Copying blob | |||
Copying blob | |||
Copying blob | |||
Copying blob | |||
Copying blob | |||
Copying config | |||
Writing manifest to image destination | Writing manifest to image destination | ||
Storing signatures | Storing signatures | ||
2022/10/14 10:57:04 info unpack layer: sha256:7ddbc47eeb70dc7f08e410a6667948b87ff3883024eb41478b44ef9a81bf400c | |||
2022/10/14 10:57:06 info unpack layer: sha256:c1bbdc448b7263673926b8fe2e88491e5083a8b4b06ddfabf311f2fc5f27e2ff | |||
2022/10/14 10:57:06 info unpack layer: sha256:8c3b70e3904492c753652606df4726430426f42ea56e06ea924d6fea7ae162a1 | |||
2022/10/14 10:57:06 info unpack layer: sha256:45d437916d5781043432f2d72608049dcf74ddbd27daa01a25fa63c8f1b9adc4 | |||
2022/10/14 10:57:06 info unpack layer: sha256:d8f1569ddae616589c5a2dabf668fadd250ee9d89253ef16f0cb0c8a9459b322 | |||
2022/10/14 10:57:06 info unpack layer: sha256:85386706b02069c58ffaea9de66c360f9d59890e56f58485d05c1a532ca30db1 | |||
2022/10/14 10:57:07 info unpack layer: sha256:ee9b457b77d047ff322858e2de025e266ff5908aec569560e77e2e4451fc23f4 | |||
2022/10/14 10:57:07 info unpack layer: sha256:be4f3343ecd31ebf7ec8809f61b1d36c2c2f98fc4e63582401d9108575bc443a | |||
2022/10/14 10:57:44 info unpack layer: sha256:30b4effda4fdab95ec4eba8873f86e7574c2edddf4dc5df8212e3eda1545aafa | |||
2022/10/14 10:58:36 info unpack layer: sha256:b6f46848806c8750a68edc4463bf146ed6c3c4af18f5d3f23281dcdfb1c65055 | |||
2022/10/14 10:58:43 info unpack layer: sha256:44845dc671f759820baac0376198141ca683f554bb16a177a3cfe262c9e368ff | |||
INFO: Creating SIF file... | INFO: Creating SIF file... | ||
</pre> | </pre> | ||
<pre> | <pre> | ||
$ | $ apptainer run --nv gpudocker.sif python3 -c 'from __future__ import print_function; import torch; print(torch.cuda.current_device()); x = torch.rand(5, 3); print(x)' | ||
0 | 0 | ||
tensor([[0. | tensor([[0.9762, 0.9717, 0.1510], | ||
[0. | [0.0995, 0.8492, 0.9194], | ||
[0. | [0.2057, 0.7201, 0.1342], | ||
[0. | [0.4137, 0.8130, 0.6911], | ||
[0. | [0.7236, 0.1144, 0.0854]]) | ||
</pre> | </pre> |
Revision as of 15:20, 14 October 2022
Singularity was rebranded as Apptainer. You should still be able to run commands on the system with singularity
however should should start migrating to using the apptainer
command.
Apptainer is a container platform that doesn't elevate the privileges of a user running the container. This is important as UMIACS runs many multi-tenant hosts and doesn't provide administrative control to users on them.
You can find out what the current version is that we provide by running the apptainer --version command. If this instead says apptainer: command not found
please contact staff and we will ensure that the software is available on the host you are looking for it on.
# apptainer --version apptainer version 1.1.0-1.el7
Apptainer can run a variety of images including its own format and Docker images. To create images, you need to have administrative rights. Therefore, you will need to do this on a host that you have administrative access to (laptop or personal desktop) rather than a UMIACS-supported host.
If you are going to pull large images, you may run out of space in your home directory. We suggest you run the following commands to setup a alternate cache directory. We are using /scratch0
but you can substitute any large enough network scratch or project directory you would like.
export WORKDIR=/scratch0/$USER export APPTAINER_CACHEDIR=${WORKDIR}/.cache mkdir -p $APPTAINER_CACHEDIR
We do suggest you pull images down into an intermediate file (SIF file) as you then do not have to worry about re-caching the image.
$ apptainer pull cuda10.2.sif docker://nvidia/cuda:10.2-devel INFO: Converting OCI blobs to SIF format INFO: Starting build... Getting image source signatures Copying blob d5d706ce7b29 done Copying blob b4dc78aeafca done Copying blob 24a22c1b7260 done Copying blob 8dea37be3176 done Copying blob 25fa05cd42bd done Copying blob a57130ec8de1 done Copying blob 880a66924cf5 done Copying config db554d658b done Writing manifest to image destination Storing signatures 2022/10/14 10:31:17 info unpack layer: sha256:25fa05cd42bd8fabb25d2a6f3f8c9f7ab34637903d00fd2ed1c1d0fa980427dd 2022/10/14 10:31:19 info unpack layer: sha256:24a22c1b72605a4dbcec13b743ef60a6cbb43185fe46fd8a35941f9af7c11153 2022/10/14 10:31:19 info unpack layer: sha256:8dea37be3176a88fae41c265562d5fb438d9281c356dcb4edeaa51451dbdfdb2 2022/10/14 10:31:20 info unpack layer: sha256:b4dc78aeafca6321025300e9d3050c5ba3fb2ac743ae547c6e1efa3f9284ce0b 2022/10/14 10:31:20 info unpack layer: sha256:a57130ec8de1e44163e965620d5aed2abe6cddf48b48272964bfd8bca101df38 2022/10/14 10:31:20 info unpack layer: sha256:d5d706ce7b293ffb369d3bf0e3f58f959977903b82eb26433fe58645f79b778b 2022/10/14 10:31:49 info unpack layer: sha256:880a66924cf5e11df601a4f531f3741c6867a3e05238bc9b7cebb2a68d479204 INFO: Creating SIF file...
$ apptainer inspect cuda10.2.sif maintainer: NVIDIA CORPORATION <cudatools@nvidia.com> org.label-schema.build-arch: amd64 org.label-schema.build-date: Friday_14_October_2022_10:32:42_EDT org.label-schema.schema-version: 1.0 org.label-schema.usage.apptainer.version: 1.1.0-1.el7 org.label-schema.usage.singularity.deffile.bootstrap: docker org.label-schema.usage.singularity.deffile.from: nvidia/cuda:10.2-devel
Now you can run the local image with the run command or start a shell with the shell command. Please note that if you are in an environment with GPUs and you want to access them inside the container you need to specify the --nv flag.
$ apptainer run --nv cuda10.2.sif nvidia-smi -L GPU 0: NVIDIA GeForce GTX 1080 Ti (UUID: GPU-8e040d17-402e-cc86-4e83-eb2b1d501f1e) GPU 1: NVIDIA GeForce GTX 1080 Ti (UUID: GPU-d681a21a-8cdd-e624-6bf8-5b0234584ba2)
Example
We have a gpudocker example workflow using our GitLab as a Docker registry. You can clone the repository and further customize this to your needs. The workflow is:
- Run Docker on a laptop or personal desktop on to create the image.
- Tag the image and and push it to the repository.
- Pull the image down onto one of our workstations/clusters and run it with your data.
$ apptainer pull gpudocker.sif docker://registry.umiacs.umd.edu/derek/gpudocker INFO: Converting OCI blobs to SIF format INFO: Starting build... Getting image source signatures Copying blob 85386706b020 done Copying blob 45d437916d57 done Copying blob c1bbdc448b72 done Copying blob d8f1569ddae6 done Copying blob 7ddbc47eeb70 done Copying blob 8c3b70e39044 done Copying blob ee9b457b77d0 done Copying blob be4f3343ecd3 done Copying blob 30b4effda4fd done Copying blob b6f46848806c done Copying blob 44845dc671f7 done Copying config 1b2e5b7b99 done Writing manifest to image destination Storing signatures 2022/10/14 10:57:04 info unpack layer: sha256:7ddbc47eeb70dc7f08e410a6667948b87ff3883024eb41478b44ef9a81bf400c 2022/10/14 10:57:06 info unpack layer: sha256:c1bbdc448b7263673926b8fe2e88491e5083a8b4b06ddfabf311f2fc5f27e2ff 2022/10/14 10:57:06 info unpack layer: sha256:8c3b70e3904492c753652606df4726430426f42ea56e06ea924d6fea7ae162a1 2022/10/14 10:57:06 info unpack layer: sha256:45d437916d5781043432f2d72608049dcf74ddbd27daa01a25fa63c8f1b9adc4 2022/10/14 10:57:06 info unpack layer: sha256:d8f1569ddae616589c5a2dabf668fadd250ee9d89253ef16f0cb0c8a9459b322 2022/10/14 10:57:06 info unpack layer: sha256:85386706b02069c58ffaea9de66c360f9d59890e56f58485d05c1a532ca30db1 2022/10/14 10:57:07 info unpack layer: sha256:ee9b457b77d047ff322858e2de025e266ff5908aec569560e77e2e4451fc23f4 2022/10/14 10:57:07 info unpack layer: sha256:be4f3343ecd31ebf7ec8809f61b1d36c2c2f98fc4e63582401d9108575bc443a 2022/10/14 10:57:44 info unpack layer: sha256:30b4effda4fdab95ec4eba8873f86e7574c2edddf4dc5df8212e3eda1545aafa 2022/10/14 10:58:36 info unpack layer: sha256:b6f46848806c8750a68edc4463bf146ed6c3c4af18f5d3f23281dcdfb1c65055 2022/10/14 10:58:43 info unpack layer: sha256:44845dc671f759820baac0376198141ca683f554bb16a177a3cfe262c9e368ff INFO: Creating SIF file...
$ apptainer run --nv gpudocker.sif python3 -c 'from __future__ import print_function; import torch; print(torch.cuda.current_device()); x = torch.rand(5, 3); print(x)' 0 tensor([[0.9762, 0.9717, 0.1510], [0.0995, 0.8492, 0.9194], [0.2057, 0.7201, 0.1342], [0.4137, 0.8130, 0.6911], [0.7236, 0.1144, 0.0854]])