How can I make Singularity take command line input during build?

953 views Asked by At

I have retrieved the following Docker image from NVIDIA NGC, using Singularity: https://ngc.nvidia.com/catalog/containers/nvidia:cuda.
I have pulled the tag '11.1-cudnn8-devel-ubuntu18.04' as follows:

singularity pull docker://nvcr.io/nvidia/cuda:11.1-cudnn8-devel-ubuntu18.04

This image is then available locally as 'cuda_11.1-cudnn8-devel-ubuntu18.04.sif'.
I then attempt to augment this image with some build tools and some Python according to the following definition file:

Bootstrap: localimage
From: cuda_11.1-cudnn8-devel-ubuntu18.04.sif

%post
    apt-get update && apt-get install -y libopenmpi-dev make gcc pkg-config g++ python3 python3-sklearn python3-requests python3-bs4 python3-urllib3

As follows:

singularity build --force --fakeroot cuda_11.1-cudnn8-python-devel-ubuntu18.04.sif cuda-python.def

During installation of tzdata in the image, it asks for user input to determine my time zone:

Setting up tzdata (2020a-0ubuntu0.18.04) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.
  1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area: 8

This halts the build process and even though I type in 8 and press ENTER, nothing happens.
It seems as if singularity is not providing a proper "hole through" for ordinary command line input. How can I fix this?

1

There are 1 answers

1
Thomas Arildsen On

Apparently, this a well-known problem among more experienced Docker/Singularity-users. It turns out I can work around it by setting, at the beginning of my %post script:

export DEBIAN_FRONTEND=noninteractive

and ending with:

unset DEBIAN_FRONTEND

I am not sure how tzdata ends up being configured then, but that is not really so important to me in this case.