How to use the hpccm.config function in hpccm

To help you get started, we’ve selected a few hpccm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NVIDIA / hpc-container-maker / test / test_baseimage.py View on Github external
def test_arch_nonexistent(self):
        """Base image CPU architecture specification"""
        b = baseimage(image='foo', _arch='nonexistent')
        self.assertEqual(hpccm.config.g_cpu_arch, cpu_arch.X86_64)
github NVIDIA / hpc-container-maker / hpccm / recipe.py View on Github external
as the `USERARG` dictionary.

    """

    # Make user arguments available
    USERARG = {} # pylint: disable=unused-variable
    if userarg:
        USERARG = userarg # alias

    # Consider just 2 stages for the time being
    stages = [Stage(), Stage()]
    Stage0 = stages[0] # alias # pylint: disable=unused-variable
    Stage1 = stages[1] # alias # pylint: disable=unused-variable

    # Set the global container type
    hpccm.config.g_ctype = ctype

    # Set the global Singularity version
    hpccm.config.g_singularity_version = StrictVersion(singularity_version)

    # Any included recipes that are specified using relative paths will
    # need to prepend the path to the main recipe in order to be found.
    # Save the path to the main recipe.
    include.prepend_path = os.path.dirname(recipe_file)

    # Load in the recipe file
    include(recipe_file, _locals=locals(), _globals=globals(),
            prepend_path=False, raise_exceptions=raise_exceptions)

    # Only process the first stage of a recipe
    if single_stage:
        del stages[1:]
github NVIDIA / hpc-container-maker / hpccm / building_blocks / mvapich2.py View on Github external
def __distro(self):
        """Based on the Linux distribution, set values accordingly.  A user
        specified value overrides any defaults."""

        if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
            if not self.__ospackages:
                self.__ospackages = ['byacc', 'file', 'make',
                                     'openssh-client', 'wget']
            self.__runtime_ospackages = ['openssh-client']
        elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
            if not self.__ospackages:
                self.__ospackages = ['byacc', 'file', 'make',
                                     'openssh-clients', 'wget']
            self.__runtime_ospackages = ['openssh-clients']
        else: # pragma: no cover
            raise RuntimeError('Unknown Linux distribution')
github NVIDIA / hpc-container-maker / hpccm / building_blocks / libsim.py View on Github external
def __distro(self):
        """Based on the Linux distribution, set values accordingly.  A user
        specified value overrides any defaults."""

        if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
            if not self.__ospackages:
                self.__ospackages = ['gzip', 'make', 'patch', 'tar', 'wget',
                                     'zlib1g-dev', 'libxt-dev',
                                     'libgl1-mesa-dev', 'libglu1-mesa-dev']
            self.__runtime_ospackages = ['libxt6', 'libgl1-mesa-glx',
                                         'libglu1-mesa', 'zlib1g']
        elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
            if not self.__ospackages:
                self.__ospackages = ['gzip', 'make', 'patch', 'tar', 'wget',
                                     'which', 'zlib-devel', 'libXt-devel',
                                     'libglvnd-devel', 'mesa-libGL-devel',
                                     'mesa-libGLU-devel']
            self.__runtime_ospackages = ['libXt', 'libglvnd', 'mesa-libGL',
                                         'mesa-libGLU', 'zlib']
        else: # pragma: no cover
            raise RuntimeError('Unknown Linux distribution')
github NVIDIA / hpc-container-maker / hpccm / primitives / shell.py View on Github external
'equivalent: using regular RUN!')

                if self._appenv:
                    logging.warning('The Singularity specific _appenv argument '
                                    'was given: ignoring argument!')
                # Format:
                # RUN cmd1 && \
                #     cmd2 && \
                #     cmd3
                s = ['RUN ']
                if self._arguments:
                    s[0] += self._arguments + ' '
                s[0] += self.commands[0]
                s.extend(['    {}'.format(x) for x in self.commands[1:]])
                return ' && \\\n'.join(s)
            elif hpccm.config.g_ctype == container_type.SINGULARITY:
                if self._arguments:
                    logging.warning('The Docker specific _arguments was given: '
                                    'ignoring statement!')
                # Format:
                # %post [OR %appinstall app_name]
                #     cmd1
                #     cmd2
                #     cmd3
                if self._app:
                    s = ['%appinstall {0}'.format(self._app)]
                    if self._test:
                        s = ['%apptest {0}'.format(self._app)]
                    # Do not `cd /` here: Singularity %appinstall is already
                    # run in its own working directory at /scif/apps/[appname].

                    # %appinstall commands do not run in regular Singularity
github NVIDIA / hpc-container-maker / hpccm / primitives / baseimage.py View on Github external
#super(baseimage, self).__init__()

        self.__arch = kwargs.get('_arch', '')
        self.__as = kwargs.get('AS', '') # Deprecated
        self.__as = kwargs.get('_as', self.__as)
        self.__bootstrap = kwargs.get('_bootstrap', 'docker')
        self.image = kwargs.get('image', 'nvidia/cuda:9.0-devel-ubuntu16.04')
        self.__distro = kwargs.get('_distro', '')
        self.__docker_env = kwargs.get('_docker_env', True) # Singularity specific

        # Set the global CPU architecture.  User the user specified
        # value if available, otherwise try to figure it out based on
        # the image name.
        self.__arch = self.__arch.lower()
        if self.__arch == 'aarch64':
            hpccm.config.set_cpu_architecture('aarch64')
        elif self.__arch == 'ppc64le':
            hpccm.config.set_cpu_architecture('ppc64le')
        elif self.__arch == 'x86_64':
            hpccm.config.set_cpu_architecture('x86_64')
        elif re.search(r'aarch64|arm64v8', self.image):
            hpccm.config.set_cpu_architecture('aarch64')
        elif re.search(r'ppc64le', self.image):
            hpccm.config.set_cpu_architecture('ppc64le')
        else:
            hpccm.config.set_cpu_architecture('x86_64')

        # Set the global Linux distribution.  Use the user specified
        # value if available, otherwise try to figure it out based on
        # the image name.
        self.__distro = self.__distro.lower()
        if self.__distro == 'ubuntu':
github NVIDIA / hpc-container-maker / hpccm / building_blocks / multi_ofed.py View on Github external
def __distro(self):
        if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
            if not self.__ospackages:
                self.__ospackages = ['libnl-3-200', 'libnl-route-3-200',
                                     'libnuma1']
        elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
            if not self.__ospackages:
                if hpccm.config.g_linux_version >= StrictVersion('8.0'):
                    self.__ospackages = ['libnl3', 'numactl-libs']
                else:
                    self.__ospackages = ['libnl', 'libnl3', 'numactl-libs']
        else: # pragma: no cover
            raise RuntimeError('Unknown Linux distribution')