예제 #1
0
    def __instructions(self):
        """Fill in container instructions"""

        path = self.__run_file
        pkg = os.path.basename(path)

        install_cmds = [
            'sh ./{} --nox11 -- -noprompt -targetpath={}'.format(
                pkg, self.__target)
        ]

        install_cmds += self._predeploy_target_commands(self.__target)

        self.__bb = generic_build(
            annotations={'file': pkg},
            base_annotation=self.__class__.__name__,
            comment=False,
            package=self.__run_file,
            install=install_cmds,
            directory=self.__wd,
            target=self.__target,
            devel_environment={'PATH': '{}:$PATH'.format(self.__target)},
            unpack=False)

        self += comment('NVIDIA Nsight Compute {}'.format(pkg))
        self += packages(ospackages=self.__ospackages)
        self += self.__bb
예제 #2
0
    def __init__(self, **kwargs):
        """Initialize building block"""

        super(knem, self).__init__(**kwargs)

        self.__ospackages = kwargs.pop('ospackages',
                                       ['ca-certificates', 'git'])
        self.__prefix = kwargs.pop('prefix', '/usr/local/knem')
        self.__repository = kwargs.pop('repository', 'https://gforge.inria.fr/git/knem/knem.git')
        self.__version = kwargs.pop('version', '1.1.3')

        # Setup the environment variables
        self.environment_variables['CPATH'] = '{}:$CPATH'.format(
            posixpath.join(self.__prefix, 'include'))

        # Setup build configuration
        self.__bb = generic_build(
            base_annotation=self.__class__.__name__,
            branch='knem-{}'.format(self.__version),
            comment=False,
            devel_environment=self.environment_variables,
            install=['mkdir -p {}/include'.format(self.__prefix),
                     'cp common/*.h {}/include'.format(self.__prefix)],
            runtime_environment=self.environment_variables,
            prefix=self.__prefix,
            repository=self.__repository,
            **kwargs)

        # Container instructions
        self += comment('KNEM version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages)
        self += self.__bb
예제 #3
0
    def __init__(self, **kwargs):
        """Initialize building block"""

        super(gdrcopy, self).__init__(**kwargs)

        # Parameters
        self.__baseurl = kwargs.pop(
            'baseurl', 'https://github.com/NVIDIA/gdrcopy/archive')
        self.__ospackages = kwargs.pop('ospackages', ['make', 'wget'])
        self.__prefix = kwargs.pop('prefix', '/usr/local/gdrcopy')
        self.__toolchain = kwargs.pop('toolchain', toolchain())
        self.__version = kwargs.pop('version', '2.1')

        # Setup the environment variables
        self.environment_variables['CPATH'] = '{}:$CPATH'.format(
            posixpath.join(self.__prefix, 'include'))
        self.environment_variables['LIBRARY_PATH'] = '{}:$LIBRARY_PATH'.format(
            posixpath.join(self.__prefix, 'lib64'))
        if not self.ldconfig:
            self.environment_variables[
                'LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(
                    posixpath.join(self.__prefix, 'lib64'))

        # Since gdrcopy does not use autotools or CMake, the toolchain
        # requires special handling.
        make_opts = vars(self.__toolchain)
        if 'CFLAGS' in make_opts:
            # CFLAGS is derived from COMMONCFLAGS, so rename.  See
            # https://github.com/NVIDIA/gdrcopy/blob/master/src/Makefile#L9
            make_opts['COMMONCFLAGS'] = make_opts.pop('CFLAGS')
        make_opts['PREFIX'] = self.__prefix
        make_opts_str = ' '.join([
            '{0}={1}'.format(key, shlex_quote(value))
            for key, value in sorted(make_opts.items())
        ])

        # Setup build configuration
        self.__bb = generic_build(
            annotations={'version': self.__version},
            base_annotation=self.__class__.__name__,
            # Work around "install -D" issue on CentOS
            build=[
                'mkdir -p {0}/include {0}/lib64'.format(self.__prefix),
                'make {} lib lib_install'.format(make_opts_str)
            ],
            comment=False,
            devel_environment=self.environment_variables,
            directory='gdrcopy-{}'.format(self.__version),
            libdir='lib64',
            prefix=self.__prefix,
            runtime_environment=self.environment_variables,
            url='{0}/v{1}.tar.gz'.format(self.__baseurl, self.__version),
            **kwargs)

        # Container instructions
        self += comment('GDRCOPY version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages)
        self += self.__bb
예제 #4
0
    def test_runtime(self):
        """Runtime"""
        g = generic_build(build=['make ARCH=sm_70'],
                          install=['cp stream /usr/local/cuda-stream/bin/cuda-stream'],
                          prefix='/usr/local/cuda-stream/bin',
                          repository='https://github.com/bcumming/cuda-stream')
        r = g.runtime()
        self.assertEqual(r,
r'''# https://github.com/bcumming/cuda-stream
COPY --from=0 /usr/local/cuda-stream/bin /usr/local/cuda-stream/bin''')
예제 #5
0
    def test_defaults_ubuntu(self):
        """Default generic_build building block"""
        g = generic_build(build=['make ARCH=sm_70'],
                          install=['cp stream /usr/local/bin/cuda-stream'],
                          repository='https://github.com/bcumming/cuda-stream')
        self.assertEqual(str(g),
r'''# https://github.com/bcumming/cuda-stream
RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 https://github.com/bcumming/cuda-stream cuda-stream && cd - && \
    cd /var/tmp/cuda-stream && \
    make ARCH=sm_70 && \
    cd /var/tmp/cuda-stream && \
    cp stream /usr/local/bin/cuda-stream && \
    rm -rf /var/tmp/cuda-stream''')
예제 #6
0
    def __init__(self, **kwargs):
        """Initialize building block"""

        super(kokkos, self).__init__(**kwargs)

        self.__arch = kwargs.pop('arch', 'Pascal60')
        self.__baseurl = kwargs.pop(
            'baseurl', 'https://github.com/kokkos/kokkos/archive')
        self.__bootstrap_opts = kwargs.pop('bootstrap_opts', [])
        self.__cuda = kwargs.pop('cuda', True)
        self.__hwloc = kwargs.pop('hwloc', True)
        self.__opts = kwargs.pop('opts', [])
        self.__ospackages = kwargs.pop('ospackages', [])
        self.__parallel = kwargs.pop('parallel', '$(nproc)')
        self.__powertools = False  # enable the CentOS PowerTools repo
        self.__prefix = kwargs.pop('prefix', '/usr/local/kokkos')
        self.__version = kwargs.pop('version', '2.9.00')

        # Set the makefile generator options
        self.__generate()

        # Set the Linux distribution specific parameters
        self.__distro()

        # Setup the environment variables
        self.environment_variables['PATH'] = '{}/bin:$PATH'.format(
            self.__prefix)

        # Setup build configuration
        self.__bb = generic_build(
            annotations={'version': self.__version},
            base_annotation=self.__class__.__name__,
            build=[
                'mkdir build', 'cd build',
                '../generate_makefile.bash {}'.format(' '.join(self.__opts)),
                'make kokkoslib -j{}'.format(self.__parallel)
            ],
            comment=False,
            devel_environment=self.environment_variables,
            directory='kokkos-{}'.format(self.__version),
            install=['cd build', 'make install -j{}'.format(self.__parallel)],
            prefix=self.__prefix,
            runtime_environment=self.environment_variables,
            url='{0}/{1}.tar.gz'.format(self.__baseurl, self.__version),
            **kwargs)

        # Container instructions
        self += comment('Kokkos version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages,
                         powertools=self.__powertools)
        self += self.__bb
    def test_prefix(self):
        """prefix option"""
        g = generic_build(build=['make ARCH=sm_70'],
                          install=['cp stream /usr/local/cuda-stream/bin/cuda-stream'],
                          prefix='/usr/local/cuda-stream/bin',
                          repository='https://github.com/bcumming/cuda-stream')
        self.assertEqual(str(g),
r'''# https://github.com/bcumming/cuda-stream
RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 https://github.com/bcumming/cuda-stream cuda-stream && cd - && \
    cd /var/tmp/cuda-stream && \
    make ARCH=sm_70 && \
    mkdir -p /usr/local/cuda-stream/bin && \
    cd /var/tmp/cuda-stream && \
    cp stream /usr/local/cuda-stream/bin/cuda-stream && \
    rm -rf /var/tmp/cuda-stream''')
    def test_package(self):
        """local package"""
        g = generic_build(build=['make USE_OPENMP=1'],
                          directory='OpenBLAS-0.3.6',
                          install=['make install PREFIX=/usr/local/openblas'],
                          package='openblas/v0.3.6.tar.gz',
                          prefix='/usr/local/openblas')
        self.assertEqual(
            str(g), r'''# openblas/v0.3.6.tar.gz
COPY openblas/v0.3.6.tar.gz /var/tmp/v0.3.6.tar.gz
RUN mkdir -p /var/tmp && tar -x -f /var/tmp/v0.3.6.tar.gz -C /var/tmp -z && \
    cd /var/tmp/OpenBLAS-0.3.6 && \
    make USE_OPENMP=1 && \
    mkdir -p /usr/local/openblas && \
    cd /var/tmp/OpenBLAS-0.3.6 && \
    make install PREFIX=/usr/local/openblas && \
    rm -rf /var/tmp/OpenBLAS-0.3.6 /var/tmp/v0.3.6.tar.gz''')
예제 #9
0
    def test_url(self):
        """url option"""
        g = generic_build(build=['make USE_OPENMP=1'],
                          directory='OpenBLAS-0.3.6',
                          install=['make install PREFIX=/usr/local/openblas'],
                          prefix='/usr/local/openblas',
                          url='https://github.com/xianyi/OpenBLAS/archive/v0.3.6.tar.gz')
        self.assertEqual(str(g),
r'''# https://github.com/xianyi/OpenBLAS/archive/v0.3.6.tar.gz
RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/xianyi/OpenBLAS/archive/v0.3.6.tar.gz && \
    mkdir -p /var/tmp && tar -x -f /var/tmp/v0.3.6.tar.gz -C /var/tmp -z && \
    cd /var/tmp/OpenBLAS-0.3.6 && \
    make USE_OPENMP=1 && \
    mkdir -p /usr/local/openblas && \
    cd /var/tmp/OpenBLAS-0.3.6 && \
    make install PREFIX=/usr/local/openblas && \
    rm -rf /var/tmp/OpenBLAS-0.3.6 /var/tmp/v0.3.6.tar.gz''')
예제 #10
0
    def __init__(self, **kwargs):
        """Initialize building block"""

        super(gdrcopy, self).__init__(**kwargs)

        # Parameters
        self.__baseurl = kwargs.pop('baseurl', 'https://github.com/NVIDIA/gdrcopy/archive')
        self.__ospackages = kwargs.pop('ospackages', ['make', 'wget'])
        self.__prefix = kwargs.pop('prefix', '/usr/local/gdrcopy')
        self.__version = kwargs.pop('version', '2.1')

        # Setup the environment variables
        self.environment_variables['CPATH'] = '{}:$CPATH'.format(
            posixpath.join(self.__prefix, 'include'))
        self.environment_variables['LIBRARY_PATH'] = '{}:$LIBRARY_PATH'.format(
            posixpath.join(self.__prefix, 'lib64'))
        if not self.ldconfig:
            self.environment_variables['LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(
                posixpath.join(self.__prefix, 'lib64'))

        if StrictVersion(self.__version) >= StrictVersion('2.1'):
            url='{0}/{1}.tar.gz'.format(self.__baseurl, self.__version)
        else:
            url='{0}/v{1}.tar.gz'.format(self.__baseurl, self.__version)

        # Setup build configuration
        self.__bb = generic_build(
            annotations={'version': self.__version},
            base_annotation=self.__class__.__name__,
            # Work around "install -D" issue on CentOS
            build=['mkdir -p {0}/include {0}/lib64'.format(self.__prefix),
                   'make PREFIX={} lib lib_install'.format(self.__prefix)],
            comment=False,
            devel_environment=self.environment_variables,
            directory='gdrcopy-{}'.format(self.__version),
            libdir='lib64',
            prefix=self.__prefix,
            runtime_environment=self.environment_variables,
            url=url,
            **kwargs)

        # Container instructions
        self += comment('GDRCOPY version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages)
        self += self.__bb
예제 #11
0
    def __init__(self, **kwargs):
        """Initialize building block"""

        super(openblas, self).__init__(**kwargs)

        self.__baseurl = kwargs.pop(
            'baseurl', 'https://github.com/xianyi/OpenBLAS/archive')
        self.__make_opts = kwargs.pop('make_opts',
                                      [])  # Filled in by __cpu_arch()
        self.__ospackages = kwargs.pop('ospackages',
                                       ['make', 'perl', 'tar', 'wget'])
        self.__prefix = kwargs.pop('prefix', '/usr/local/openblas')
        self.__toolchain = kwargs.pop('toolchain', toolchain())
        self.__version = kwargs.pop('version', '0.3.10')

        # Set the make options
        self.__make()

        # Setup the environment variables
        if not self.ldconfig:
            self.environment_variables[
                'LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(
                    posixpath.join(self.__prefix, 'lib'))

        # Setup build configuration
        self.__bb = generic_build(
            annotations={'version': self.__version},
            base_annotation=self.__class__.__name__,
            build=['make {}'.format(' '.join(self.__make_opts))],
            comment=False,
            directory='OpenBLAS-{}'.format(self.__version),
            devel_environment=self.environment_variables,
            install=['make install PREFIX={}'.format(self.__prefix)],
            prefix=self.__prefix,
            runtime_environment=self.environment_variables,
            url='{0}/v{1}.tar.gz'.format(self.__baseurl, self.__version),
            **kwargs)

        # Container instructions
        self += comment('OpenBLAS version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages)
        self += self.__bb
예제 #12
0
    def __instructions_runfile(self):
        """Fill in container instructions"""

        pkg = os.path.basename(self.__runfile)

        install_cmds = [
            'sh ./{} --nox11 -- -noprompt -targetpath={}'.format(
                pkg, self.__prefix)
        ]

        # Commands needed to predeploy target-specific files. When
        # connecting through the GUI on another machine to the
        # container, this removes the need to copy the files over.
        install_cmds += [
            'mkdir -p /tmp/var/target',
            'ln -sf {}/target/* /tmp/var/target'.format(self.__prefix),
            'ln -sf {}/sections /tmp/var/'.format(self.__prefix),
            'chmod -R a+w /tmp/var'
        ]

        kwargs = {}
        if self.__runfile.strip().startswith(('http://', 'https://')):
            kwargs['url'] = self.__runfile
        else:
            kwargs['package'] = self.__runfile

        self.__bb = generic_build(
            annotations={'runfile': pkg},
            base_annotation=self.__class__.__name__,
            comment = False,
            devel_environment={'PATH': '{}:$PATH'.format(self.__prefix)},
            directory=self.__wd,
            install=install_cmds,
            unpack=False,
            wd=self.__wd,
            **kwargs
        )

        self += comment('NVIDIA Nsight Compute {}'.format(pkg), reformat=False)
        self += packages(ospackages=self.__ospackages)
        self += self.__bb
    def test_environment_ldconfig_annotate(self):
        """ldconfig and environment options"""
        g = generic_build(
            annotate=True,
            base_annotation='openblas',
            branch='v0.3.6',
            build=['make USE_OPENMP=1'],
            devel_environment={'CPATH': '/usr/local/openblas/include:$CPATH'},
            install=['make install PREFIX=/usr/local/openblas'],
            ldconfig=True,
            prefix='/usr/local/openblas',
            repository='https://github.com/xianyi/OpenBLAS.git',
            runtime_environment={
                'CPATH': '/usr/local/openblas/include:$CPATH'
            })
        self.assertEqual(
            str(g), r'''# https://github.com/xianyi/OpenBLAS.git
RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v0.3.6 https://github.com/xianyi/OpenBLAS.git OpenBLAS && cd - && \
    cd /var/tmp/OpenBLAS && \
    make USE_OPENMP=1 && \
    mkdir -p /usr/local/openblas && \
    cd /var/tmp/OpenBLAS && \
    make install PREFIX=/usr/local/openblas && \
    echo "/usr/local/openblas/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \
    rm -rf /var/tmp/OpenBLAS
ENV CPATH=/usr/local/openblas/include:$CPATH
LABEL hpccm.openblas.branch=v0.3.6 \
    hpccm.openblas.repository=https://github.com/xianyi/OpenBLAS.git''')

        r = g.runtime()
        self.assertEqual(
            r, r'''# https://github.com/xianyi/OpenBLAS.git
COPY --from=0 /usr/local/openblas /usr/local/openblas
RUN echo "/usr/local/openblas/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig
ENV CPATH=/usr/local/openblas/include:$CPATH
LABEL hpccm.openblas.branch=v0.3.6 \
    hpccm.openblas.repository=https://github.com/xianyi/OpenBLAS.git''')
예제 #14
0
 def test_both_repository_and_url(self):
     """both repository and url"""
     with self.assertRaises(RuntimeError):
         g = generic_build(repository='foo', url='bar')
예제 #15
0
 def test_no_url(self):
     """missing url"""
     with self.assertRaises(RuntimeError):
         g = generic_build()
예제 #16
0
def build(container_format='singularity',
          os='ubuntu20.04',
          cuda_version='11.0',
          tensorflow_version='2.2.0',
          pytorch_version='1.7.1',
          pycuda_version='v2020.1'):
    image = f'nvcr.io/nvidia/cuda:{cuda_version}-devel-{os}'
    config.set_container_format(container_format)
    stage0 = Stage(name='stage0')
    stage0 += baseimage(image=image, _bootstrap='docker')
    stage0 += label(metadata={
        'maintainer': 'Luhan Cheng',
        'email': '*****@*****.**'
    })
    stage0 += packages(
        apt=['libxml2-dev', 'libxslt-dev', 'python3-pip', 'git'])
    stage0 += conda(eula=True,
                    packages=[
                        'python=3.7', f'tensorflow-gpu={tensorflow_version}',
                        f'pytorch={pytorch_version}', 'torchvision',
                        'torchaudio'
                    ],
                    channels=['pytorch', 'anaconda', 'conda-forge'])
    stage0 += generic_build(
        repository='https://github.com/inducer/pycuda.git',
        branch=pycuda_version,
        build=[f'./configure.py --cuda-root=/usr/local/cuda-{cuda_version}'],
    )
    stage0 += environment(variables=from_prefix('/usr/local/pycuda'))
    version = "7.2.1.6"
    os = "Ubuntu-18.04"
    arch = 'x86_64'
    cuda = "cuda-11.0"
    cudnn = "cudnn8.0"
    filename = f'TensorRT-{version}.{os}.{arch}-gnu.{cuda}.{cudnn}.tar.gz'
    TENSORRT_ROOT = '/usr/local/tensorrt'
    stage0 += copy(src=f'{filename}', dest=f'/{filename}')
    stage0 += shell(commands=[
        f'mkdir -p {TENSORRT_ROOT}',
        f'tar -xf /TensorRT-7.2.1.6.Ubuntu-18.04.x86_64-gnu.cuda-11.0.cudnn8.0.tar.gz --strip-components 1 -C {TENSORRT_ROOT}',
        'rm -rf /TensorRT-7.2.1.6.Ubuntu-18.04.x86_64-gnu.cuda-11.0.cudnn8.0.tar.gz'
    ])
    stage0 += environment(
        variables={
            'LD_LIBRARY_PATH': f'$LD_LIBRARY_PATH:{TENSORRT_ROOT}/lib/',
            'PATH': f'$PATH:{TENSORRT_ROOT}/bin/',
            'C_INCLUDE_PATH': f'$C_INCLUDE_PATH:{TENSORRT_ROOT}/include/',
            **from_prefix('/usr/local/cuda'),
            **from_prefix('/usr/local/anaconda')
        })
    stage0 += pip(packages=[
        f'{TENSORRT_ROOT}/python/tensorrt-7.2.1.6-cp37-none-linux_x86_64.whl',
        f'{TENSORRT_ROOT}/uff/uff-0.6.9-py2.py3-none-any.whl',
        f'{TENSORRT_ROOT}/graphsurgeon/graphsurgeon-0.4.5-py2.py3-none-any.whl',
        f'{TENSORRT_ROOT}/onnx_graphsurgeon/onnx_graphsurgeon-0.2.6-py2.py3-none-any.whl'
    ],
                  pip='pip3')
    cudnn_src = 'cudnn-11.0-linux-x64-v8.0.5.39.tgz'
    stage0 += copy(src=cudnn_src, dest=f'/{cudnn_src}')
    stage0 += shell(commands=[
        'mkdir -p /cudnn',
        f'tar -xf /{cudnn_src} -C /cudnn --strip-components 1',
        'cp /cudnn/include/cudnn*.h /usr/local/cuda/include',
        'cp /cudnn/lib64/libcudnn* /usr/local/cuda/lib64',
        'chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*',
        'rm -rf /cudnn /cudnn-11.0-linux-x64-v8.0.5.39.tgz'
    ])

    return stage0
예제 #17
0
    def __init__(self, **kwargs):
        """Initialize building block"""

        super(nccl, self).__init__(**kwargs)

        self.__baseurl = kwargs.pop('baseurl',
                                    'https://github.com/NVIDIA/nccl/archive')
        self.__build = kwargs.pop('build', False)
        self.__build_environment = ''  # Filled in by __configure
        self.__default_repository = 'https://github.com/NVIDIA/nccl.git'
        self.__distro_label = ''  # Filled in by __distro
        self.__cuda = kwargs.pop('cuda', '11.0')
        self.__make_variables = kwargs.pop('make_variables', {})
        self.__ospackages = kwargs.pop('ospackages', [])
        self.__prefix = kwargs.pop('prefix', '/usr/local/nccl')
        self.__src_directory = kwargs.pop('src_directory', None)
        self.__version = kwargs.pop('version', '2.7.8-1')
        self.__wd = '/var/tmp'  # working directory

        if not self.__build:
            # Install prebuild package

            # Set the Linux distribution specific parameters
            self.__distro()

            self += comment('NCCL {}'.format(self.__version))
            self += packages(ospackages=self.__ospackages)
            self += packages(
                apt=[
                    'libnccl2={0}+cuda{1}'.format(self.__version, self.__cuda),
                    'libnccl-dev={0}+cuda{1}'.format(self.__version,
                                                     self.__cuda)
                ],
                apt_keys=[
                    'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}/7fa2af80.pub'
                    .format(self.__distro_label, get_cpu_architecture())
                ],
                apt_repositories=[
                    'deb https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1} /'
                    .format(self.__distro_label, get_cpu_architecture())
                ],
                yum=[
                    'libnccl-{0}+cuda{1}'.format(self.__version, self.__cuda),
                    'libnccl-devel-{0}+cuda{1}'.format(self.__version,
                                                       self.__cuda)
                ],
                yum_keys=[
                    'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}/7fa2af80.pub'
                    .format(self.__distro_label, get_cpu_architecture())
                ],
                yum_repositories=[
                    'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}'
                    .format(self.__distro_label, get_cpu_architecture())
                ])

        else:
            # Build from source

            # Set the build options
            self.__configure()

            self.__download()
            kwargs['repository'] = self.repository
            kwargs['url'] = self.url

            # Setup the environment variables
            self.environment_variables['CPATH'] = '{}:$CPATH'.format(
                posixpath.join(self.__prefix, 'include'))
            self.environment_variables[
                'LIBRARY_PATH'] = '{}:$LIBRARY_PATH'.format(
                    posixpath.join(self.__prefix, 'lib'))
            self.environment_variables['PATH'] = '{}:$PATH'.format(
                posixpath.join(self.__prefix, 'bin'))
            if not self.ldconfig:
                self.environment_variables[
                    'LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(
                        posixpath.join(self.__prefix, 'lib'))

            self.__bb = generic_build(
                base_annotation=self.__class__.__name__,
                build=[
                    '{} make -j$(nproc) install'.format(
                        self.__build_environment)
                ],
                comment=False,
                devel_environment=self.environment_variables,
                directory='nccl-{}'.format(self.__version)
                if not self.repository else None,
                prefix=self.__prefix,
                runtime_environment=self.environment_variables,
                **kwargs)

            self += comment('NCCL')
            self += packages(ospackages=self.__ospackages)
            self += self.__bb
예제 #18
0
 def test_invalid_package(self):
     """invalid package url"""
     with self.assertRaises(RuntimeError):
         g = generic_build(url='https://foo/bar.sh')
예제 #19
0
    def __init__(self, **kwargs):
        """Initialize building block"""

        super(nvshmem, self).__init__(**kwargs)

        self.__binary_tarball = kwargs.pop('binary_tarball', None)
        self.__cuda = kwargs.pop('cuda', '/usr/local/cuda')
        self.__gdrcopy = kwargs.pop('gdrcopy', None)
        self.__hydra = kwargs.pop('hydra', False)
        self.__make_variables = kwargs.pop('make_variables', {})
        self.__mpi = kwargs.pop('mpi', None)
        self.__ospackages = kwargs.pop('ospackages', ['make', 'wget'])
        self.__prefix = kwargs.pop('prefix', '/usr/local/nvshmem')
        self.__shmem = kwargs.pop('shmem', None)
        self.__src_directory = kwargs.pop('src_directory', None)
        self.__version = kwargs.pop('version', '1.0.1-0')
        self.__wd = kwargs.get('wd', hpccm.config.g_wd)  # working directory

        # Set the download specific parameters
        self.__download()
        kwargs['url'] = self.url
        if self.__src_directory:
            kwargs['directory'] = self.__src_directory

        # Setup the environment variables
        self.environment_variables['CPATH'] = '{}:$CPATH'.format(
            posixpath.join(self.__prefix, 'include'))
        self.environment_variables['LIBRARY_PATH'] = '{}:$LIBRARY_PATH'.format(
            posixpath.join(self.__prefix, 'lib'))
        self.environment_variables['PATH'] = '{}:$PATH'.format(
            posixpath.join(self.__prefix, 'bin'))

        # Add packages
        if self.__hydra:
            self.__ospackages.append('automake')

        if self.__version and not self.__binary_tarball and not self.package:
            self += comment('NVSHMEM {}'.format(self.__version))
        else:
            self += comment('NVSHMEM')
        self += packages(ospackages=self.__ospackages)

        if self.__binary_tarball:
            # Shorthand for the tarball file inside the container
            tarball = posixpath.join(self.__wd,
                                     os.path.basename(self.__binary_tarball))

            self += copy(src=self.__binary_tarball, dest=tarball)
            self += shell(commands=[
                # Untar binary package
                self.untar_step(
                    tarball=tarball,
                    # remove the leading directory, e.g., install in
                    # /usr/local/nvshmem not
                    # /usr/local/nvshmem/nvshmem_<version>_<arch>.
                    args=['--strip-components=1'],
                    directory=self.__prefix),
                # Install Hydra process launcher
                '{0}/scripts/install_hydra.sh {1} {0}'.
                format(self.__prefix, self.__wd) if self.__hydra else None,
                # Remove temporary files and cleanup
                self.cleanup_step(items=[tarball])
            ])
            self += environment(variables=self.environment_variables)

        else:
            # Build from source

            # Set the build options
            self.__configure()

            self.__bb = generic_build(
                build=[
                    '{} make -j$(nproc) install'.format(
                        self.__build_environment),
                    './scripts/install_hydra.sh {1} {0}'.format(
                        self.__prefix, self.__wd) if self.__hydra else None
                ],
                comment=False,
                devel_environment=self.environment_variables,
                prefix=self.__prefix,
                runtime_environment=self.environment_variables,
                **kwargs)
            self += self.__bb
예제 #20
0
 def test_both_branch_and_commit(self):
     """both branch and commit"""
     with self.assertRaises(RuntimeError):
         g = generic_build(branch='dev', commit='deadbeef',
                           repository='foo')