python_code
stringlengths
0
679k
repo_name
stringlengths
9
41
file_path
stringlengths
6
149
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the mpich module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.mpich import mpich from hpccm.toolchain import toolchain class Test_mpich(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default mpich building block""" m = mpich() self.assertEqual(str(m), r'''# MPICH version 3.3.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ gzip \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.mpich.org/static/downloads/3.3.2/mpich-3.3.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mpich-3.3.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/mpich-3.3.2 && ./configure --prefix=/usr/local/mpich && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/mpich-3.3.2 /var/tmp/mpich-3.3.2.tar.gz ENV LD_LIBRARY_PATH=/usr/local/mpich/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mpich/bin:$PATH''') @centos @docker def test_defaults_centos(self): """Default mpich building block""" m = mpich() self.assertEqual(str(m), r'''# MPICH version 3.3.2 RUN yum install -y \ file \ gzip \ make \ openssh-clients \ perl \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.mpich.org/static/downloads/3.3.2/mpich-3.3.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mpich-3.3.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/mpich-3.3.2 && ./configure --prefix=/usr/local/mpich && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/mpich-3.3.2 /var/tmp/mpich-3.3.2.tar.gz ENV LD_LIBRARY_PATH=/usr/local/mpich/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mpich/bin:$PATH''') @ubuntu @docker def test_ldconfig(self): """ldconfig option""" m = mpich(ldconfig=True, version='3.3') self.assertEqual(str(m), r'''# MPICH version 3.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ gzip \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.mpich.org/static/downloads/3.3/mpich-3.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mpich-3.3.tar.gz -C /var/tmp -z && \ cd /var/tmp/mpich-3.3 && ./configure --prefix=/usr/local/mpich && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/mpich/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/mpich-3.3 /var/tmp/mpich-3.3.tar.gz ENV PATH=/usr/local/mpich/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" m = mpich() r = m.runtime() self.assertEqual(r, r'''# MPICH RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ openssh-client && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/mpich /usr/local/mpich ENV LD_LIBRARY_PATH=/usr/local/mpich/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mpich/bin:$PATH''') def test_toolchain(self): """Toolchain""" m = mpich() tc = m.toolchain self.assertEqual(tc.CC, 'mpicc') self.assertEqual(tc.CXX, 'mpicxx') self.assertEqual(tc.FC, 'mpifort') self.assertEqual(tc.F77, 'mpif77') self.assertEqual(tc.F90, 'mpif90')
hpc-container-maker-master
test/test_mpich.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the knem module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.knem import knem class Test_knem(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default knem building block""" k = knem() self.assertEqual(str(k), r'''# KNEM version 1.1.4 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ git && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch knem-1.1.4 https://gitlab.inria.fr/knem/knem.git knem && cd - && \ mkdir -p /usr/local/knem && \ cd /var/tmp/knem && \ mkdir -p /usr/local/knem/include && \ cp common/*.h /usr/local/knem/include && \ rm -rf /var/tmp/knem ENV CPATH=/usr/local/knem/include:$CPATH''') @centos @docker def test_defaults_centos(self): """Default knem building block""" k = knem() self.assertEqual(str(k), r'''# KNEM version 1.1.4 RUN yum install -y \ ca-certificates \ git && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch knem-1.1.4 https://gitlab.inria.fr/knem/knem.git knem && cd - && \ mkdir -p /usr/local/knem && \ cd /var/tmp/knem && \ mkdir -p /usr/local/knem/include && \ cp common/*.h /usr/local/knem/include && \ rm -rf /var/tmp/knem ENV CPATH=/usr/local/knem/include:$CPATH''') @ubuntu @docker def test_runtime(self): """Runtime""" k = knem() r = k.runtime() self.assertEqual(r, r'''# KNEM COPY --from=0 /usr/local/knem /usr/local/knem ENV CPATH=/usr/local/knem/include:$CPATH''')
hpc-container-maker-master
test/test_knem.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the mlnx_ofed module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, centos8, docker, ppc64le, ubuntu, ubuntu18, ubuntu20, x86_64 from hpccm.building_blocks.mlnx_ofed import mlnx_ofed class Test_mlnx_ofed(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default mlnx_ofed building block""" mofed = mlnx_ofed() self.assertEqual(str(mofed), r'''# Mellanox OFED version 5.6-2.0.9.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox | apt-key add - && \ mkdir -p /etc/apt/sources.list.d && wget -q -nc --no-check-certificate -P /etc/apt/sources.list.d https://linux.mellanox.com/public/repo/mlnx_ofed/5.6-2.0.9.0/ubuntu16.04/mellanox_mlnx_ofed.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ibverbs-providers \ ibverbs-utils \ libibmad-dev \ libibmad5 \ libibumad-dev \ libibumad3 \ libibverbs-dev \ libibverbs1 \ librdmacm-dev \ librdmacm1 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu18 @docker def test_defaults_ubuntu18(self): """Default mlnx_ofed building block""" mofed = mlnx_ofed() self.assertEqual(str(mofed), r'''# Mellanox OFED version 5.6-2.0.9.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox | apt-key add - && \ mkdir -p /etc/apt/sources.list.d && wget -q -nc --no-check-certificate -P /etc/apt/sources.list.d https://linux.mellanox.com/public/repo/mlnx_ofed/5.6-2.0.9.0/ubuntu18.04/mellanox_mlnx_ofed.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ibverbs-providers \ ibverbs-utils \ libibmad-dev \ libibmad5 \ libibumad-dev \ libibumad3 \ libibverbs-dev \ libibverbs1 \ librdmacm-dev \ librdmacm1 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu20 @docker def test_defaults_ubuntu20(self): """Default mlnx_ofed building block""" mofed = mlnx_ofed() self.assertEqual(str(mofed), r'''# Mellanox OFED version 5.6-2.0.9.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox | apt-key add - && \ mkdir -p /etc/apt/sources.list.d && wget -q -nc --no-check-certificate -P /etc/apt/sources.list.d https://linux.mellanox.com/public/repo/mlnx_ofed/5.6-2.0.9.0/ubuntu20.04/mellanox_mlnx_ofed.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ibverbs-providers \ ibverbs-utils \ libibmad-dev \ libibmad5 \ libibumad-dev \ libibumad3 \ libibverbs-dev \ libibverbs1 \ librdmacm-dev \ librdmacm1 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @centos @docker def test_defaults_centos(self): """Default mlnx_ofed building block""" mofed = mlnx_ofed() self.assertEqual(str(mofed), r'''# Mellanox OFED version 5.6-2.0.9.0 RUN yum install -y \ ca-certificates \ gnupg \ wget && \ rm -rf /var/cache/yum/* RUN rpm --import https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox && \ yum install -y yum-utils && \ yum-config-manager --add-repo https://linux.mellanox.com/public/repo/mlnx_ofed/5.6-2.0.9.0/rhel7.2/mellanox_mlnx_ofed.repo && \ yum install -y \ libibumad \ libibverbs \ libibverbs-utils \ librdmacm \ rdma-core \ rdma-core-devel && \ rm -rf /var/cache/yum/*''') @x86_64 @centos8 @docker def test_defaults_centos8(self): """Default mlnx_ofed building block""" mofed = mlnx_ofed() self.assertEqual(str(mofed), r'''# Mellanox OFED version 5.6-2.0.9.0 RUN yum install -y \ ca-certificates \ gnupg \ wget && \ rm -rf /var/cache/yum/* RUN rpm --import https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox && \ yum install -y dnf-utils && \ yum-config-manager --add-repo https://linux.mellanox.com/public/repo/mlnx_ofed/5.6-2.0.9.0/rhel8.0/mellanox_mlnx_ofed.repo && \ yum install -y \ libibumad \ libibverbs \ libibverbs-utils \ librdmacm \ rdma-core \ rdma-core-devel && \ rm -rf /var/cache/yum/*''') @x86_64 @ubuntu @docker def test_prefix_ubuntu(self): """Prefix option""" mofed = mlnx_ofed(prefix='/opt/ofed', version='4.6-1.0.1.1') self.assertEqual(str(mofed), r'''# Mellanox OFED version 4.6-1.0.1.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ libnl-3-200 \ libnl-route-3-200 \ libnuma1 \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox | apt-key add - && \ mkdir -p /etc/apt/sources.list.d && wget -q -nc --no-check-certificate -P /etc/apt/sources.list.d https://linux.mellanox.com/public/repo/mlnx_ofed/4.6-1.0.1.1/ubuntu16.04/mellanox_mlnx_ofed.list && \ apt-get update -y && \ mkdir -m 777 -p /var/tmp/packages_download && cd /var/tmp/packages_download && \ DEBIAN_FRONTEND=noninteractive apt-get download -y --no-install-recommends \ ibverbs-utils \ libibmad \ libibmad-devel \ libibumad \ libibumad-devel \ libibverbs-dev \ libibverbs1 \ libmlx4-1 \ libmlx4-dev \ libmlx5-1 \ libmlx5-dev \ librdmacm-dev \ librdmacm1 && \ mkdir -p /opt/ofed && \ find /var/tmp/packages_download -regextype posix-extended -type f -regex "/var/tmp/packages_download/(ibverbs-utils|libibmad|libibmad-devel|libibumad|libibumad-devel|libibverbs-dev|libibverbs1|libmlx4-1|libmlx4-dev|libmlx5-1|libmlx5-dev|librdmacm-dev|librdmacm1).*deb" -exec dpkg --extract {} /opt/ofed \; && \ rm -rf /var/tmp/packages_download && \ rm -f /etc/apt/sources.list.d/mellanox_mlnx_ofed.list && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /etc/libibverbs.d''') @x86_64 @centos @docker def test_prefix_centos(self): """Prefix option""" mofed = mlnx_ofed(prefix='/opt/ofed', version='4.6-1.0.1.1') self.assertEqual(str(mofed), r'''# Mellanox OFED version 4.6-1.0.1.1 RUN yum install -y \ ca-certificates \ gnupg \ libnl \ libnl3 \ numactl-libs \ wget && \ rm -rf /var/cache/yum/* RUN rpm --import https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox && \ yum install -y yum-utils && \ yum-config-manager --add-repo https://linux.mellanox.com/public/repo/mlnx_ofed/4.6-1.0.1.1/rhel7.2/mellanox_mlnx_ofed.repo && \ yum install -y yum-utils && \ mkdir -p /var/tmp/packages_download && \ yumdownloader --destdir=/var/tmp/packages_download -x \*i?86 --archlist=x86_64 \ libibmad \ libibmad-devel \ libibumad \ libibumad-devel \ libibverbs \ libibverbs-devel \ libibverbs-utils \ libmlx4 \ libmlx4-devel \ libmlx5 \ libmlx5-devel \ librdmacm \ librdmacm-devel && \ mkdir -p /opt/ofed && cd /opt/ofed && \ find /var/tmp/packages_download -regextype posix-extended -type f -regex "/var/tmp/packages_download/(libibmad|libibmad-devel|libibumad|libibumad-devel|libibverbs|libibverbs-devel|libibverbs-utils|libmlx4|libmlx4-devel|libmlx5|libmlx5-devel|librdmacm|librdmacm-devel).*rpm" -exec sh -c "rpm2cpio {} | cpio -idm" \; && \ rm -rf /var/tmp/packages_download && \ rm -rf /var/cache/yum/* RUN mkdir -p /etc/libibverbs.d''') @aarch64 @centos @docker def test_aarch64_centos(self): """aarch64""" mofed = mlnx_ofed(version='4.6-1.0.1.1') self.assertEqual(str(mofed), r'''# Mellanox OFED version 4.6-1.0.1.1 RUN yum install -y \ ca-certificates \ gnupg \ wget && \ rm -rf /var/cache/yum/* RUN rpm --import https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox && \ yum install -y yum-utils && \ yum-config-manager --add-repo https://linux.mellanox.com/public/repo/mlnx_ofed/4.6-1.0.1.1/rhel7.6alternate/mellanox_mlnx_ofed.repo && \ yum install -y \ libibmad \ libibmad-devel \ libibumad \ libibumad-devel \ libibverbs \ libibverbs-devel \ libibverbs-utils \ libmlx4 \ libmlx4-devel \ libmlx5 \ libmlx5-devel \ librdmacm \ librdmacm-devel && \ rm -rf /var/cache/yum/*''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" mofed = mlnx_ofed(version='5.0-2.1.8.0') r = mofed.runtime() self.assertEqual(r, r'''# Mellanox OFED version 5.0-2.1.8.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox | apt-key add - && \ mkdir -p /etc/apt/sources.list.d && wget -q -nc --no-check-certificate -P /etc/apt/sources.list.d https://linux.mellanox.com/public/repo/mlnx_ofed/5.0-2.1.8.0/ubuntu16.04/mellanox_mlnx_ofed.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ibverbs-providers \ ibverbs-utils \ libibmad-dev \ libibmad5 \ libibumad-dev \ libibumad3 \ libibverbs-dev \ libibverbs1 \ librdmacm-dev \ librdmacm1 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu @docker def test_prefix_runtime(self): """Prefix runtime""" mofed = mlnx_ofed(prefix='/opt/ofed', version='5.0-2.1.8.0') r = mofed.runtime() self.assertEqual(r, r'''# Mellanox OFED version 5.0-2.1.8.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnl-3-200 \ libnl-route-3-200 \ libnuma1 && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /etc/libibverbs.d COPY --from=0 /opt/ofed /opt/ofed''')
hpc-container-maker-master
test/test_mlnx_ofed.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the annotate module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from hpccm.templates.annotate import annotate class Test_annotate(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_no_annotations(self): """No variables specified""" a = annotate() self.assertDictEqual(a.annotate_step(), {}) def test_no_base(self): """Basic annotations""" a = annotate(annotate=True, base_annotation=False) a.add_annotation('A', 'a') a.add_annotation('one', 1) self.assertDictEqual(a.annotate_step(), {'A': 'a', 'one': '1'}) def test_default_base(self): """Basic annotations""" a = annotate(annotate=True, base_annotation=True) a.add_annotation('A', 'a') a.add_annotation('one', 1) self.assertDictEqual(a.annotate_step(), {'hpccm.annotate.A': 'a', 'hpccm.annotate.one': '1'}) def test_custom_base(self): """Basic annotations""" a = annotate(annotate=True, base_annotation='foo') a.add_annotation('A', 'a') a.add_annotation('one', 1) self.assertDictEqual(a.annotate_step(), {'hpccm.foo.A': 'a', 'hpccm.foo.one': '1'}) def test_no_annotations(self): """Basic annotations""" a = annotate(annotate=False) a.add_annotation('A', 'a') a.add_annotation('one', 1) self.assertDictEqual(a.annotate_step(), {})
hpc-container-maker-master
test/test_annotate.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the python module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, centos8, docker, ubuntu, ubuntu22 from hpccm.building_blocks.python import python class Test_python(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default python building block""" p = python() self.assertEqual(str(p), r'''# Python RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python \ python3 && \ rm -rf /var/lib/apt/lists/*''') @ubuntu22 @docker def test_defaults_ubuntu22(self): """Default python building block""" p = python() self.assertEqual(str(p), r'''# Python RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python2 \ python3 && \ rm -rf /var/lib/apt/lists/*''') @centos @docker def test_defaults_centos(self): """Default python building block""" p = python() self.assertEqual(str(p), r'''# Python RUN yum install -y \ python2 \ python3 && \ rm -rf /var/cache/yum/*''') @centos8 @docker def test_defaults_alternatives(self): """Default python building block""" p = python(alternatives=True) self.assertEqual(str(p), r'''# Python RUN yum install -y \ python2 \ python3 && \ rm -rf /var/cache/yum/* RUN alternatives --set python /usr/bin/python2''') @ubuntu @docker def test_devel(self): """devel option""" p = python(devel=True) self.assertEqual(str(p), r'''# Python RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python \ python-dev \ python3 \ python3-dev && \ rm -rf /var/lib/apt/lists/*''') @ubuntu @docker def test_runtime(self): """Runtime""" p = python() r = p.runtime() self.assertEqual(r, r'''# Python RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python \ python3 && \ rm -rf /var/lib/apt/lists/*''')
hpc-container-maker-master
test/test_python.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the hdf5 module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.hdf5 import hdf5 class Test_hdf5(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default hdf5 building block""" h = hdf5() self.assertEqual(str(h), r'''# HDF5 version 1.12.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ make \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/src/hdf5-1.12.0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hdf5-1.12.0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/hdf5-1.12.0 && ./configure --prefix=/usr/local/hdf5 --enable-cxx --enable-fortran && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/hdf5-1.12.0 /var/tmp/hdf5-1.12.0.tar.bz2 ENV CPATH=/usr/local/hdf5/include:$CPATH \ HDF5_DIR=/usr/local/hdf5 \ LD_LIBRARY_PATH=/usr/local/hdf5/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/hdf5/lib:$LIBRARY_PATH \ PATH=/usr/local/hdf5/bin:$PATH''') @centos @docker def test_defaults_centos(self): """Default hdf5 building block""" h = hdf5() self.assertEqual(str(h), r'''# HDF5 version 1.12.0 RUN yum install -y \ bzip2 \ file \ make \ wget \ zlib-devel && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/src/hdf5-1.12.0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hdf5-1.12.0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/hdf5-1.12.0 && ./configure --prefix=/usr/local/hdf5 --enable-cxx --enable-fortran && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/hdf5-1.12.0 /var/tmp/hdf5-1.12.0.tar.bz2 ENV CPATH=/usr/local/hdf5/include:$CPATH \ HDF5_DIR=/usr/local/hdf5 \ LD_LIBRARY_PATH=/usr/local/hdf5/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/hdf5/lib:$LIBRARY_PATH \ PATH=/usr/local/hdf5/bin:$PATH''') @ubuntu @docker def test_ldconfig(self): """ldconfig option""" h = hdf5(ldconfig=True, version='1.10.4') self.assertEqual(str(h), r'''# HDF5 version 1.10.4 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ make \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.4/src/hdf5-1.10.4.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hdf5-1.10.4.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/hdf5-1.10.4 && ./configure --prefix=/usr/local/hdf5 --enable-cxx --enable-fortran && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/hdf5/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/hdf5-1.10.4 /var/tmp/hdf5-1.10.4.tar.bz2 ENV CPATH=/usr/local/hdf5/include:$CPATH \ HDF5_DIR=/usr/local/hdf5 \ LIBRARY_PATH=/usr/local/hdf5/lib:$LIBRARY_PATH \ PATH=/usr/local/hdf5/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" h = hdf5() r = h.runtime() self.assertEqual(r, r'''# HDF5 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ zlib1g && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/hdf5 /usr/local/hdf5 ENV CPATH=/usr/local/hdf5/include:$CPATH \ HDF5_DIR=/usr/local/hdf5 \ LD_LIBRARY_PATH=/usr/local/hdf5/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/hdf5/lib:$LIBRARY_PATH \ PATH=/usr/local/hdf5/bin:$PATH''')
hpc-container-maker-master
test/test_hdf5.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the envvars module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from hpccm.templates.envvars import envvars class Test_envvars(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_no_variables(self): """No variables specified""" e = envvars() self.assertDictEqual(e.environment_step(), {}) def test_basic(self): """Basic envvars""" d = {'A': 'a', 'B': 'b', 'one': 1} e = envvars() e.environment_variables = d self.assertDictEqual(e.environment_step(), d) e.environment = False self.assertDictEqual(e.environment_step(), {}) def test_include_exclude(self): """Include / exclude keys""" d = {'A': 'a', 'B': 'b', 'one': 1} e = envvars() e.environment_variables = d self.assertDictEqual(e.environment_step(exclude=['B']), {'A': 'a', 'one': 1}) self.assertDictEqual(e.environment_step(include_only=['A', 'one']), {'A': 'a', 'one': 1}) def test_runtime(self): """Runtime environment variables""" d = {'A': 'a', 'B': 'b', 'one': 1} r = {'A': 'alpha', 'B': 'b'} e = envvars() e.environment_variables = d e.runtime_environment_variables = r self.assertDictEqual(e.environment_step(runtime=True), {'A': 'alpha', 'B': 'b'})
hpc-container-maker-master
test/test_envvars.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the gnu module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import broadwell, centos, centos8, docker, ubuntu, ubuntu18, ubuntu20 from hpccm.building_blocks.gnu import gnu class Test_gnu(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default gnu building block""" g = gnu() self.assertEqual(str(g), r'''# GNU compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ gfortran && \ rm -rf /var/lib/apt/lists/*''') @centos @docker def test_defaults_centos(self): """Default gnu building block""" g = gnu() self.assertEqual(str(g), r'''# GNU compiler RUN yum install -y \ gcc \ gcc-c++ \ gcc-gfortran && \ rm -rf /var/cache/yum/*''') @ubuntu @docker def test_version_ubuntu(self): """GNU compiler version""" g = gnu(extra_repository=True, version='7') self.assertEqual(str(g), r'''# GNU compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common && \ apt-add-repository ppa:ubuntu-toolchain-r/test -y && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++-7 \ gcc-7 \ gfortran-7 && \ rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/g++ g++ $(which g++-7) 30 && \ update-alternatives --install /usr/bin/gcc gcc $(which gcc-7) 30 && \ update-alternatives --install /usr/bin/gcov gcov $(which gcov-7) 30 && \ update-alternatives --install /usr/bin/gfortran gfortran $(which gfortran-7) 30''') @centos @docker def test_version_centos7(self): """GNU compiler version""" g = gnu(extra_repository=True, version='7') self.assertEqual(str(g), r'''# GNU compiler RUN yum install -y centos-release-scl && \ yum install -y \ devtoolset-7-gcc \ devtoolset-7-gcc-c++ \ devtoolset-7-gcc-gfortran && \ rm -rf /var/cache/yum/* RUN update-alternatives --install /usr/bin/g++ g++ /opt/rh/devtoolset-7/root/usr/bin/g++ 30 && \ update-alternatives --install /usr/bin/gcc gcc /opt/rh/devtoolset-7/root/usr/bin/gcc 30 && \ update-alternatives --install /usr/bin/gcov gcov /opt/rh/devtoolset-7/root/usr/bin/gcov 30 && \ update-alternatives --install /usr/bin/gfortran gfortran /opt/rh/devtoolset-7/root/usr/bin/gfortran 30''') @centos8 @docker def test_version_centos8(self): """GNU compiler version""" g = gnu(version='9') self.assertEqual(str(g), r'''# GNU compiler RUN yum install -y centos-release-stream && \ yum install -y \ gcc-toolset-9-gcc \ gcc-toolset-9-gcc-c++ \ gcc-toolset-9-gcc-gfortran && \ rm -rf /var/cache/yum/* RUN update-alternatives --install /usr/bin/g++ g++ /opt/rh/gcc-toolset-9/root/usr/bin/g++ 30 && \ update-alternatives --install /usr/bin/gcc gcc /opt/rh/gcc-toolset-9/root/usr/bin/gcc 30 && \ update-alternatives --install /usr/bin/gcov gcov /opt/rh/gcc-toolset-9/root/usr/bin/gcov 30 && \ update-alternatives --install /usr/bin/gfortran gfortran /opt/rh/gcc-toolset-9/root/usr/bin/gfortran 30''') @ubuntu @docker def test_source_no_version(self): """GNU compiler from source with no version""" with self.assertRaises(RuntimeError): g = gnu(source=True) @ubuntu @docker def test_source_ubuntu(self): """GNU compiler from source""" g = gnu(source=True, version='9.1.0') self.assertEqual(str(g), r'''# GNU compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ g++ \ gcc \ git \ make \ perl \ tar \ wget \ xz-utils && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://ftpmirror.gnu.org/gcc/gcc-9.1.0/gcc-9.1.0.tar.xz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/gcc-9.1.0.tar.xz -C /var/tmp -J && \ cd /var/tmp/gcc-9.1.0 && ./contrib/download_prerequisites && \ mkdir -p /var/tmp/objdir && cd /var/tmp/objdir && /var/tmp/gcc-9.1.0/configure --prefix=/usr/local/gnu --disable-multilib --enable-languages=c,c++,fortran && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/gcc-9.1.0.tar.xz /var/tmp/gcc-9.1.0 /var/tmp/objdir ENV LD_LIBRARY_PATH=/usr/local/gnu/lib64:$LD_LIBRARY_PATH \ PATH=/usr/local/gnu/bin:$PATH''') @centos @docker def test_source_ldconfig_centos(self): """GNU compiler from source""" g = gnu(ldconfig=True, source=True, version='9.1.0') self.assertEqual(str(g), r'''# GNU compiler RUN yum install -y \ bzip2 \ file \ gcc \ gcc-c++ \ git \ make \ perl \ tar \ wget \ xz && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://ftpmirror.gnu.org/gcc/gcc-9.1.0/gcc-9.1.0.tar.xz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/gcc-9.1.0.tar.xz -C /var/tmp -J && \ cd /var/tmp/gcc-9.1.0 && ./contrib/download_prerequisites && \ mkdir -p /var/tmp/objdir && cd /var/tmp/objdir && /var/tmp/gcc-9.1.0/configure --prefix=/usr/local/gnu --disable-multilib --enable-languages=c,c++,fortran && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/gnu/lib64" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/gcc-9.1.0.tar.xz /var/tmp/gcc-9.1.0 /var/tmp/objdir ENV PATH=/usr/local/gnu/bin:$PATH''') @centos @docker def test_source_openacc_centos(self): """GNU compiler from source""" g = gnu(openacc=True, source=True, version='9.1.0') self.assertEqual(str(g), r'''# GNU compiler RUN yum install -y \ bzip2 \ file \ gcc \ gcc-c++ \ git \ make \ perl \ tar \ wget \ xz && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://ftpmirror.gnu.org/gcc/gcc-9.1.0/gcc-9.1.0.tar.xz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/gcc-9.1.0.tar.xz -C /var/tmp -J && \ cd /var/tmp/gcc-9.1.0 && ./contrib/download_prerequisites && \ mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch master https://github.com/MentorEmbedded/nvptx-tools.git nvptx-tools && cd - && \ cd /var/tmp/nvptx-tools && ./configure --prefix=/usr/local/gnu && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/nvptx-tools && \ cd /var/tmp && \ mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch master https://github.com/MentorEmbedded/nvptx-newlib nvptx-newlib && cd - && \ ln -s /var/tmp/nvptx-newlib/newlib /var/tmp/gcc-9.1.0/newlib && \ mkdir -p /var/tmp/accel_objdir && cd /var/tmp/accel_objdir && /var/tmp/gcc-9.1.0/configure --prefix=/usr/local/gnu --disable-multilib --disable-sjlj-exceptions --enable-as-accelerator-for=x86_64-pc-linux-gnu --enable-languages=c,c++,fortran,lto --enable-newlib-io-long-long --target=nvptx-none && \ make -j$(nproc) && \ make -j$(nproc) install && \ mkdir -p /var/tmp/objdir && cd /var/tmp/objdir && /var/tmp/gcc-9.1.0/configure --prefix=/usr/local/gnu --disable-multilib --enable-languages=c,c++,fortran,lto --enable-offload-targets=nvptx-none=/usr/local/gnu/nvptx-none --with-cuda-driver=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/gcc-9.1.0.tar.xz /var/tmp/gcc-9.1.0 /var/tmp/objdir && \ rm -rf /var/tmp/accel_objdir /var/tmp/nvptx-newlib ENV LD_LIBRARY_PATH=/usr/local/gnu/lib64:$LD_LIBRARY_PATH \ PATH=/usr/local/gnu/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" g = gnu() r = g.runtime() self.assertEqual(r, r'''# GNU compiler runtime RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libgfortran3 \ libgomp1 && \ rm -rf /var/lib/apt/lists/*''') @ubuntu18 @docker def test_runtime_ubuntu18(self): """Runtime""" g = gnu() r = g.runtime() self.assertEqual(r, r'''# GNU compiler runtime RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libgfortran4 \ libgomp1 && \ rm -rf /var/lib/apt/lists/*''') @ubuntu20 @docker def test_runtime_ubuntu20(self): """Runtime""" g = gnu() r = g.runtime() self.assertEqual(r, r'''# GNU compiler runtime RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libgfortran5 \ libgomp1 && \ rm -rf /var/lib/apt/lists/*''') @centos @docker def test_runtime_source(self): """Runtime""" g = gnu(source=True, version='9.1.0') r = g.runtime() self.assertEqual(r, r'''# GNU compiler runtime COPY --from=0 /usr/local/gnu/lib64 /usr/local/gnu/lib64 ENV LD_LIBRARY_PATH=/usr/local/gnu/lib64:$LD_LIBRARY_PATH''') @centos @docker def test_runtime_source_ldconfig(self): """Runtime""" g = gnu(ldconfig=True, source=True, version='9.1.0') r = g.runtime() self.assertEqual(r, r'''# GNU compiler runtime COPY --from=0 /usr/local/gnu/lib64 /usr/local/gnu/lib64 RUN echo "/usr/local/gnu/lib64" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig''') def test_toolchain(self): """Toolchain""" g = gnu() tc = g.toolchain self.assertEqual(tc.CC, 'gcc') self.assertEqual(tc.CXX, 'g++') self.assertEqual(tc.FC, 'gfortran') self.assertEqual(tc.F77, 'gfortran') self.assertEqual(tc.F90, 'gfortran') def test_toolchain_source(self): g = gnu(source=True, prefix='/usr/local/gnu', version='9.1.0') tc = g.toolchain self.assertEqual(tc.CC, "/usr/local/gnu/bin/gcc") self.assertEqual(tc.CXX, "/usr/local/gnu/bin/g++") self.assertEqual(tc.FC, "/usr/local/gnu/bin/gfortran") self.assertEqual(tc.F77, "/usr/local/gnu/bin/gfortran") self.assertEqual(tc.F90, "/usr/local/gnu/bin/gfortran") if tc.LD_LIBRARY_PATH: self.assertTrue("/usr/local/gnu/lib64" in tc.LD_LIBRARY_PATH) @broadwell def test_toolchain_broadwell(self): """CPU arch optimization flags""" g = gnu() tc = g.toolchain self.assertEqual(tc.CFLAGS, '-march=broadwell -mtune=broadwell') self.assertEqual(tc.CXXFLAGS, '-march=broadwell -mtune=broadwell') self.assertEqual(tc.FFLAGS, '-march=broadwell -mtune=broadwell') self.assertEqual(tc.FCFLAGS, '-march=broadwell -mtune=broadwell')
hpc-container-maker-master
test/test_gnu.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the Stage module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, singularity32 from hpccm.building_blocks import boost from hpccm.building_blocks import gnu from hpccm.primitives.baseimage import baseimage from hpccm.primitives.shell import shell from hpccm.Stage import Stage class Test_Stage(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_value(self): """Single layer""" s = Stage() self.assertFalse(len(s)) s += 1 self.assertTrue(len(s)) def test_list(self): """List of layers""" s = Stage() self.assertEqual(len(s), 0) s += [1, 2] self.assertEqual(len(s), 2) @docker def test_baseimage(self): """Base image specification""" s = Stage() s.name = 'bar' s.baseimage('foo') self.assertEqual(str(s), 'FROM foo AS bar') @docker def test_baseimage_first(self): """Base image is always first""" s = Stage() s += shell(commands=['abc']) s.name = 'bar' s.baseimage('foo') self.assertEqual(str(s), 'FROM foo AS bar\n\nRUN abc') @centos @docker def test_runtime(self): """Runtime from a previous stage""" s0 = Stage() s0 += gnu() s0 += shell(commands=['gcc -o hello hello.c']) s1 = Stage() s1 += s0.runtime() self.assertEqual(str(s1), r'''# GNU compiler runtime RUN yum install -y \ libgfortran \ libgomp && \ rm -rf /var/cache/yum/*''') @centos @docker def test_runtime_exclude(self): """Runtime from a previous stage with exclude""" s0 = Stage() s0 += gnu() s0 += boost() s1 = Stage() s1 += s0.runtime(exclude=['boost']) self.assertEqual(str(s1), r'''# GNU compiler runtime RUN yum install -y \ libgfortran \ libgomp && \ rm -rf /var/cache/yum/*''') @docker def test_multistage_noas_docker(self): """Multistage naming""" s0 = Stage() s0 += baseimage(image='centos:7') s0 += boost() s1 = Stage() s1 += s0.runtime() self.assertEqual(str(s1), r'''# Boost COPY --from=0 /usr/local/boost /usr/local/boost ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @singularity32 def test_multistage_noas_singularity(self): """Multistage naming""" s0 = Stage() s0 += baseimage(image='centos:7') s0 += boost() s1 = Stage() s1 += s0.runtime() self.assertEqual(str(s1), r'''# Boost %files from 0 /usr/local/boost /usr/local/boost %environment export LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH %post export LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @docker def test_multistage_as_docker(self): """Multistage naming""" s0 = Stage() s0 += baseimage(image='centos:7', _as='devel') s0 += boost() s1 = Stage() s1 += s0.runtime() self.assertEqual(str(s1), r'''# Boost COPY --from=devel /usr/local/boost /usr/local/boost ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @singularity32 def test_multistage_as_singularity(self): """Multistage naming""" s0 = Stage() s0 += baseimage(image='centos:7', _as='devel') s0 += boost() s1 = Stage() s1 += s0.runtime() self.assertEqual(str(s1), r'''# Boost %files from devel /usr/local/boost /usr/local/boost %environment export LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH %post export LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @docker def test_multistage_as_override_docker(self): """Multistage naming""" s0 = Stage() s0 += baseimage(image='centos:7', _as='devel') s0 += boost() s1 = Stage() s1 += s0.runtime(_from='build') self.assertEqual(str(s1), r'''# Boost COPY --from=build /usr/local/boost /usr/local/boost ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @singularity32 def test_multistage_as_override_singularity(self): """Multistage naming""" s0 = Stage() s0 += baseimage(image='centos:7', _as='devel') s0 += boost() s1 = Stage() s1 += s0.runtime(_from='build') self.assertEqual(str(s1), r'''# Boost %files from build /usr/local/boost /usr/local/boost %environment export LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH %post export LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''')
hpc-container-maker-master
test/test_Stage.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the recipe module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import os import unittest from helpers import x86_64 from hpccm.common import container_type from hpccm.recipe import recipe class Test_recipe(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_no_arguments(self): """No arguments""" with self.assertRaises(TypeError): recipe() def test_bad_recipe(self): """Bad (invalid) recipe file""" path = os.path.dirname(__file__) rf = os.path.join(path, 'bad_recipe.py') with self.assertRaises(SystemExit): recipe(rf) def test_raise_exceptions(self): """Bad (invalid) recipe file with raise exceptions enabled""" path = os.path.dirname(__file__) rf = os.path.join(path, 'bad_recipe.py') with self.assertRaises(SyntaxError): recipe(rf, raise_exceptions=True) def test_basic_example(self): """Basic example""" path = os.path.dirname(__file__) rf = os.path.join(path, '..', 'recipes', 'examples', 'basic.py') r = recipe(rf) self.assertEqual(r.strip(), r'''FROM ubuntu:16.04 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ gfortran && \ rm -rf /var/lib/apt/lists/*''') def test_basic_example_singularity(self): """ctype option""" path = os.path.dirname(__file__) rf = os.path.join(path, '..', 'recipes', 'examples', 'basic.py') r = recipe(rf, ctype=container_type.SINGULARITY) self.assertEqual(r.strip(), r'''BootStrap: docker From: ubuntu:16.04 %post . /.singularity.d/env/10-docker*.sh %post apt-get update -y DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ gfortran rm -rf /var/lib/apt/lists/*''') @x86_64 def test_multistage_example_singlestage(self): """Single_stage option""" path = os.path.dirname(__file__) rf = os.path.join(path, '..', 'recipes', 'examples', 'multistage.py') r = recipe(rf, single_stage=True) self.assertEqual(r.strip(), r'''FROM nvcr.io/nvidia/cuda:9.0-devel-ubuntu16.04 AS devel # GNU compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ gfortran && \ rm -rf /var/lib/apt/lists/* # FFTW version 3.3.10 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.10.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.10.tar.gz -C /var/tmp -z && \ cd /var/tmp/fftw-3.3.10 && ./configure --prefix=/usr/local/fftw --enable-openmp --enable-shared --enable-sse2 --enable-threads && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/fftw-3.3.10 /var/tmp/fftw-3.3.10.tar.gz ENV LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') @x86_64 def test_multistage_example_singularity26(self): """Multi-stage recipe with Singularity container type""" path = os.path.dirname(__file__) rf = os.path.join(path, '..', 'recipes', 'examples', 'multistage.py') r = recipe(rf, ctype=container_type.SINGULARITY, singularity_version='2.6') self.assertEqual(r.strip(), r'''BootStrap: docker From: nvcr.io/nvidia/cuda:9.0-devel-ubuntu16.04 %post . /.singularity.d/env/10-docker*.sh # GNU compiler %post apt-get update -y DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ gfortran rm -rf /var/lib/apt/lists/* # FFTW version 3.3.10 %post apt-get update -y DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget rm -rf /var/lib/apt/lists/* %post cd / mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.10.tar.gz mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.10.tar.gz -C /var/tmp -z cd /var/tmp/fftw-3.3.10 && ./configure --prefix=/usr/local/fftw --enable-openmp --enable-shared --enable-sse2 --enable-threads make -j$(nproc) make -j$(nproc) install rm -rf /var/tmp/fftw-3.3.10 /var/tmp/fftw-3.3.10.tar.gz %environment export LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH %post export LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') @x86_64 def test_multistage_example_singularity32(self): """Multi-stage recipe with Singularity container type""" path = os.path.dirname(__file__) rf = os.path.join(path, '..', 'recipes', 'examples', 'multistage.py') r = recipe(rf, ctype=container_type.SINGULARITY, singularity_version='3.2') self.maxDiff = None self.assertEqual(r.strip(), r'''# NOTE: this definition file depends on features only available in # Singularity 3.2 and later. BootStrap: docker From: nvcr.io/nvidia/cuda:9.0-devel-ubuntu16.04 Stage: devel %post . /.singularity.d/env/10-docker*.sh # GNU compiler %post apt-get update -y DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ gfortran rm -rf /var/lib/apt/lists/* # FFTW version 3.3.10 %post apt-get update -y DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget rm -rf /var/lib/apt/lists/* %post cd / mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.10.tar.gz mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.10.tar.gz -C /var/tmp -z cd /var/tmp/fftw-3.3.10 && ./configure --prefix=/usr/local/fftw --enable-openmp --enable-shared --enable-sse2 --enable-threads make -j$(nproc) make -j$(nproc) install rm -rf /var/tmp/fftw-3.3.10 /var/tmp/fftw-3.3.10.tar.gz %environment export LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH %post export LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH BootStrap: docker From: nvcr.io/nvidia/cuda:9.0-runtime-ubuntu16.04 %post . /.singularity.d/env/10-docker*.sh # GNU compiler runtime %post apt-get update -y DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libgfortran3 \ libgomp1 rm -rf /var/lib/apt/lists/* # FFTW %files from devel /usr/local/fftw /usr/local/fftw %environment export LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH %post export LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') def test_userarg_example(self): """userarg option""" path = os.path.dirname(__file__) rf = os.path.join(path, '..', 'recipes', 'examples', 'userargs.py') r = recipe(rf, userarg={'cuda': '9.0', 'ompi': '2.1.2'}) self.assertEqual(r.strip(), r'''FROM nvcr.io/nvidia/cuda:9.0-devel-ubuntu16.04 # OpenMPI version 2.1.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ hwloc \ libnuma-dev \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.2.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/openmpi-2.1.2.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/openmpi-2.1.2 && ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda --without-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/openmpi-2.1.2 /var/tmp/openmpi-2.1.2.tar.bz2 ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') def test_include(self): """recipe include""" path = os.path.dirname(__file__) rf = os.path.join(path, 'include3.py') r = recipe(rf) self.assertEqual(r.strip(), r'''FROM ubuntu:16.04 # GNU compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ gfortran && \ rm -rf /var/lib/apt/lists/*''')
hpc-container-maker-master
test/test_recipe.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the rdma_core module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu, x86_64 from hpccm.building_blocks.rdma_core import rdma_core class Test_rdma_core(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default rdma_core building block""" r = rdma_core() self.assertEqual(str(r), r'''# RDMA Core version 31.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnl-3-dev \ libnl-route-3-dev \ libudev-dev \ make \ pandoc \ pkg-config \ python3-docutils \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/linux-rdma/rdma-core/archive/v31.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v31.2.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/rdma-core-31.2/build && cd /var/tmp/rdma-core-31.2/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/rdma-core /var/tmp/rdma-core-31.2 && \ cmake --build /var/tmp/rdma-core-31.2/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/rdma-core-31.2/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/rdma-core-31.2 /var/tmp/v31.2.tar.gz ENV CPATH=/usr/local/rdma-core/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LIBRARY_PATH \ PATH=/usr/local/rdma-core/bin:$PATH''') @x86_64 @centos @docker def test_defaults_centos(self): """Default rdma_core building block""" r = rdma_core() self.assertEqual(str(r), r'''# RDMA Core version 31.2 RUN yum install -y epel-release && \ yum install -y \ libnl3-devel \ libudev-devel \ make \ pandoc \ pkgconfig \ python-docutils \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/linux-rdma/rdma-core/archive/v31.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v31.2.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/rdma-core-31.2/build && cd /var/tmp/rdma-core-31.2/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/rdma-core /var/tmp/rdma-core-31.2 && \ cmake --build /var/tmp/rdma-core-31.2/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/rdma-core-31.2/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/rdma-core-31.2 /var/tmp/v31.2.tar.gz ENV CPATH=/usr/local/rdma-core/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LIBRARY_PATH \ PATH=/usr/local/rdma-core/bin:$PATH''') @x86_64 @ubuntu @docker def test_ldconfig(self): """ldconfig option""" r = rdma_core(ldconfig=True, version='31.2') self.assertEqual(str(r), r'''# RDMA Core version 31.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnl-3-dev \ libnl-route-3-dev \ libudev-dev \ make \ pandoc \ pkg-config \ python3-docutils \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/linux-rdma/rdma-core/archive/v31.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v31.2.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/rdma-core-31.2/build && cd /var/tmp/rdma-core-31.2/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/rdma-core /var/tmp/rdma-core-31.2 && \ cmake --build /var/tmp/rdma-core-31.2/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/rdma-core-31.2/build --target install -- -j$(nproc) && \ echo "/usr/local/rdma-core/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/rdma-core-31.2 /var/tmp/v31.2.tar.gz ENV CPATH=/usr/local/rdma-core/include:$CPATH \ LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LIBRARY_PATH \ PATH=/usr/local/rdma-core/bin:$PATH''') @x86_64 @ubuntu @docker def test_git_repository_true(self): r = rdma_core(repository=True) self.assertEqual(str(r), r'''# RDMA Core https://github.com/linux-rdma/rdma-core.git RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ git \ libnl-3-dev \ libnl-route-3-dev \ libudev-dev \ make \ pandoc \ pkg-config \ python3-docutils \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 https://github.com/linux-rdma/rdma-core.git rdma-core && cd - && \ mkdir -p /var/tmp/rdma-core/build && cd /var/tmp/rdma-core/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/rdma-core /var/tmp/rdma-core && \ cmake --build /var/tmp/rdma-core/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/rdma-core/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/rdma-core ENV CPATH=/usr/local/rdma-core/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LIBRARY_PATH \ PATH=/usr/local/rdma-core/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" r = rdma_core() r2 = r.runtime() self.assertEqual(r2, r'''# RDMA Core RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnl-3-200 \ libnl-route-3-200 \ libnuma1 && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/rdma-core /usr/local/rdma-core ENV CPATH=/usr/local/rdma-core/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/rdma-core/lib:/usr/local/rdma-core/lib64:$LIBRARY_PATH \ PATH=/usr/local/rdma-core/bin:$PATH''')
hpc-container-maker-master
test/test_rdma_core.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the cgns module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.cgns import cgns class Test_cgns(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default cgns building block""" c = cgns() self.assertEqual(str(c), r'''# CGNS version 4.1.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/CGNS/CGNS/archive/v4.1.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v4.1.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/CGNS-4.1.2/src && FLIBS='-Wl,--no-as-needed -ldl' LIBS='-Wl,--no-as-needed -ldl' ./configure --prefix=/usr/local/cgns --with-hdf5=/usr/local/hdf5 --with-zlib && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/CGNS-4.1.2/src /var/tmp/v4.1.2.tar.gz''') @centos @docker def test_defaults_centos(self): """Default cgns building block""" c = cgns() self.assertEqual(str(c), r'''# CGNS version 4.1.2 RUN yum install -y \ bzip2 \ file \ make \ wget \ zlib-devel && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/CGNS/CGNS/archive/v4.1.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v4.1.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/CGNS-4.1.2/src && FLIBS='-Wl,--no-as-needed -ldl' LIBS='-Wl,--no-as-needed -ldl' ./configure --prefix=/usr/local/cgns --with-hdf5=/usr/local/hdf5 --with-zlib && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/CGNS-4.1.2/src /var/tmp/v4.1.2.tar.gz''') @ubuntu @docker def test_runtime(self): """Runtime""" c = cgns() r = c.runtime() self.assertEqual(r, r'''# CGNS RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ zlib1g && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/cgns /usr/local/cgns''')
hpc-container-maker-master
test/test_cgns.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the julia module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, docker, ubuntu, x86_64 from hpccm.building_blocks.julia import julia class Test_julia(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default julia building block""" j = julia() self.assertEqual(str(j), r'''# Julia version 1.5.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.1-linux-x86_64.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/julia-1.5.1-linux-x86_64.tar.gz -C /var/tmp -z && \ cp -a /var/tmp/julia-1.5.1 /usr/local/julia && \ rm -rf /var/tmp/julia-1.5.1-linux-x86_64.tar.gz /var/tmp/julia-1.5.1 ENV LD_LIBRARY_PATH=/usr/local/julia/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/julia/bin:$PATH''') @aarch64 @ubuntu @docker def test_aarch64(self): """aarch64""" j = julia() self.assertEqual(str(j), r'''# Julia version 1.5.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://julialang-s3.julialang.org/bin/linux/aarch64/1.5/julia-1.5.1-linux-aarch64.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/julia-1.5.1-linux-aarch64.tar.gz -C /var/tmp -z && \ cp -a /var/tmp/julia-1.5.1 /usr/local/julia && \ rm -rf /var/tmp/julia-1.5.1-linux-aarch64.tar.gz /var/tmp/julia-1.5.1 ENV LD_LIBRARY_PATH=/usr/local/julia/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/julia/bin:$PATH''') @x86_64 @ubuntu @docker def test_depot_history_packages(self): """depot, history, and packages options""" j = julia(depot='~/.julia-ngc', history='/tmp/julia_history.jl', packages=['CUDAnative', 'CuArrays'], version='1.2.0') self.assertEqual(str(j), r'''# Julia version 1.2.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://julialang-s3.julialang.org/bin/linux/x64/1.2/julia-1.2.0-linux-x86_64.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/julia-1.2.0-linux-x86_64.tar.gz -C /var/tmp -z && \ cp -a /var/tmp/julia-1.2.0 /usr/local/julia && \ JULIA_DEPOT_PATH=/usr/local/julia/share/julia /usr/local/julia/bin/julia -e 'using Pkg; Pkg.add([PackageSpec(name="CUDAnative"), PackageSpec(name="CuArrays")])' && \ echo "DEPOT_PATH[1] = \"~/.julia-ngc\"" >> /usr/local/julia/etc/julia/startup.jl && \ rm -rf /var/tmp/julia-1.2.0-linux-x86_64.tar.gz /var/tmp/julia-1.2.0 ENV JULIA_HISTORY=/tmp/julia_history.jl \ LD_LIBRARY_PATH=/usr/local/julia/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/julia/bin:$PATH''') @x86_64 @ubuntu @docker def test_cuda_ldconfig(self): """cuda and ldconfig options""" j = julia(cuda=True, ldconfig=True, version='1.2.0') self.assertEqual(str(j), r'''# Julia version 1.2.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://julialang-s3.julialang.org/bin/linux/x64/1.2/julia-1.2.0-linux-x86_64.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/julia-1.2.0-linux-x86_64.tar.gz -C /var/tmp -z && \ cp -a /var/tmp/julia-1.2.0 /usr/local/julia && \ JULIA_DEPOT_PATH=/usr/local/julia/share/julia /usr/local/julia/bin/julia -e 'using Pkg; Pkg.add([PackageSpec(name="CUDAapi"), PackageSpec(name="CUDAdrv"), PackageSpec(name="CUDAnative"), PackageSpec(name="CuArrays")])' && \ echo "/usr/local/julia/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/julia-1.2.0-linux-x86_64.tar.gz /var/tmp/julia-1.2.0 ENV PATH=/usr/local/julia/bin:$PATH''') @x86_64 @ubuntu @docker def test_runtime(self): """runtime""" j = julia() r = j.runtime() self.assertEqual(str(j), str(r))
hpc-container-maker-master
test/test_julia.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the rm module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from hpccm.templates.rm import rm class Test_rm(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_missing_files(self): """Missing files""" r = rm() self.assertEqual(r.cleanup_step(), '') def test_basic(self): """Basic file removal""" r = rm() self.assertEqual(r.cleanup_step(items=['a', 'b', 'c']), 'rm -rf a b c')
hpc-container-maker-master
test/test_rm.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the copy module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import bash, docker, invalid_ctype, singularity, singularity26, singularity32, singularity37 from hpccm.primitives.copy import copy class Test_copy(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @docker def test_empty(self): """No source or destination specified""" c = copy() self.assertEqual(str(c), '') @invalid_ctype def test_invalid_ctype(self): """Invalid container type specified""" c = copy(src='a', dest='b') with self.assertRaises(RuntimeError): str(c) @docker def test_single_docker(self): """Single source file specified""" c = copy(src='a', dest='b') self.assertEqual(str(c), 'COPY a b') @singularity def test_single_singularity(self): """Single source file specified""" c = copy(src='a', dest='b') self.assertEqual(str(c), '%files\n a b') @bash def test_single_bash(self): """Single source file specified""" c = copy(src='a', dest='b') self.assertEqual(str(c), '') @docker def test_multiple_docker(self): """Multiple source files specified""" c = copy(src=['a1', 'a2', 'a3'], dest='b') self.assertEqual(str(c), 'COPY a1 \\\n a2 \\\n a3 \\\n b/') @singularity def test_multiple_singularity(self): """Multiple source files specified""" c = copy(src=['a1', 'a2', 'a3'], dest='b') self.assertEqual(str(c), '%files\n a1 b\n a2 b\n a3 b') @docker def test_files_docker(self): """Pairs of files specified""" c = copy(files={'a1': 'b1', 'a2': 'b2', 'a3': 'b3'}) self.assertEqual(str(c), 'COPY a1 b1\nCOPY a2 b2\nCOPY a3 b3') @singularity def test_files_singularity(self): """Pairs of files specified""" c = copy(files={'a1': 'b1', 'a2': 'b2', 'a3': 'b3'}) self.assertEqual(str(c), '%files\n a1 b1\n a2 b2\n a3 b3') @docker def test_from_docker(self): """Docker --from syntax""" c = copy(src='a', dest='b', _from='dev') self.assertEqual(str(c), 'COPY --from=dev a b') @singularity26 def test_from_singularity26(self): """Singularity from syntax""" c = copy(src='a', dest='b', _from='dev') self.assertEqual(str(c), '%files\n a b') @singularity32 def test_from_singularity32(self): """Singularity from syntax""" c = copy(src='a', dest='b', _from='dev') self.assertEqual(str(c), '%files from dev\n a b') @singularity def test_appfiles_multiple_singularity(self): """Multiple app-specific source files specified""" c = copy(src=['a1', 'a2', 'a3'], dest='b', _app='foo') self.assertEqual(str(c), '%appfiles foo\n a1 b\n a2 b\n a3 b') @singularity def test_appfiles_files_singularity(self): """Pairs of app-specific files specified""" c = copy(files={'a1': 'b1', 'a2': 'b2', 'a3': 'b3'}, _app='foo') self.assertEqual(str(c), '%appfiles foo\n a1 b1\n a2 b2\n a3 b3') @docker def test_appfiles_docker(self): """app-parameter is ignored in Docker""" c = copy(src=['a1', 'a2', 'a3'], dest='b', _app='foo') self.assertEqual(str(c), 'COPY a1 \\\n a2 \\\n a3 \\\n b/') @singularity def test_post_file_singularity(self): """Move file during post""" c = copy(src='a', dest='/opt/a', _post=True) self.assertEqual(str(c), '%files\n a /\n%post\n mv /a /opt/a') c = copy(src='a', dest='/opt/', _post=True) self.assertEqual(str(c), '%files\n a /\n%post\n mv /a /opt/') @singularity def test_post_multiple_singularity(self): """move file during post""" c = copy(src=['a', 'b'], dest='/opt', _post=True) self.assertEqual(str(c), '%files\n a /\n b /\n%post\n mv /a /opt/a\n mv /b /opt/b') @singularity def test_mkdir_file_singularity(self): """mkdir folder with setup, single file""" c = copy(src='a', dest='/opt/foo/a', _mkdir=True) self.assertEqual(str(c), '%setup\n mkdir -p ${SINGULARITY_ROOTFS}/opt/foo\n%files\n a /opt/foo/a') @singularity def test_mkdir_files_singularity(self): """mkdir folder with setup, multiple files""" c = copy(src=['a', 'b'], dest='/opt/foo', _mkdir=True) self.assertEqual(str(c), '%setup\n mkdir -p ${SINGULARITY_ROOTFS}/opt/foo\n%files\n a /opt/foo\n b /opt/foo') @docker def test_merge_file_docker(self): """merge primitives""" c = [] c.append(copy(src='a', dest='A')) c.append(copy(src='b', dest='B')) merged = c[0].merge(c) self.assertEqual(str(merged), 'COPY a A\nCOPY b B') @singularity def test_merge_file_singularity(self): """merge primitives""" c = [] c.append(copy(src='a', dest='A')) c.append(copy(src='b', dest='B')) merged = c[0].merge(c) self.assertEqual(str(merged), '%files\n a A\n b B') @docker def test_merge_multiple_docker(self): """merge primitives""" c = [] c.append(copy(src=['a1', 'a2'], dest='A')) c.append(copy(src='b', dest='B')) merged = c[0].merge(c) self.assertEqual(str(merged), 'COPY a1 A\nCOPY a2 A\nCOPY b B') @singularity def test_merge_multiple_singularity(self): """merge primitives""" c = [] c.append(copy(src=['a1', 'a2'], dest='A')) c.append(copy(src='b', dest='B')) merged = c[0].merge(c) self.assertEqual(str(merged), '%files\n a1 A\n a2 A\n b B') @docker def test_merge_mixed_docker(self): """merge primitives""" c = [] c.append(copy(src='foo', dest='bar')) c.append(copy(src=['1', '2', '3'], dest='/infinity')) c.append(copy(files={'a': '/A', 'b': '/B'})) merged = c[0].merge(c) self.assertEqual(str(merged), r'''COPY 1 /infinity COPY 2 /infinity COPY 3 /infinity COPY a /A COPY b /B COPY foo bar''') @singularity def test_merge_mixed_singularity(self): """merge primitives""" c = [] c.append(copy(src='foo', dest='bar')) c.append(copy(src=['1', '2', '3'], dest='/infinity')) c.append(copy(files={'a': '/A', 'b': '/B'})) merged = c[0].merge(c) self.assertEqual(str(merged), r'''%files 1 /infinity 2 /infinity 3 /infinity a /A b /B foo bar''') @docker def test_chown_docker(self): """Docker --chown syntax""" c = copy(_chown='alice:alice', src='foo', dest='bar') self.assertEqual(str(c), 'COPY --chown=alice:alice foo bar') @singularity def test_chown_singularity(self): """Singularity --chown syntax""" c = copy(_chown='alice:alice', src='foo', dest='bar') self.assertEqual(str(c), '%files\n foo bar') @singularity37 def test_temp_staging(self): """Singularity staged files through tmp""" c = copy(src='foo', dest='/var/tmp/foo') with self.assertRaises(RuntimeError): str(c) @singularity37 def test_from_temp_staging(self): """Singularity files from previous stage in tmp""" c = copy(_from='base', src='foo', dest='/var/tmp/foo') self.assertEqual(str(c), '%files from base\n foo /var/tmp/foo')
hpc-container-maker-master
test/test_copy.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the arm_allinea_studio module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, centos8, docker, thunderx2, ubuntu20, ubuntu from hpccm.building_blocks.arm_allinea_studio import arm_allinea_studio class Test_arm_allinea_studio(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @aarch64 @ubuntu20 @docker def test_defaults_ubuntu(self): """Default arm_allinea_studio building block""" a = arm_allinea_studio(eula=True) self.assertEqual(str(a), r'''# Arm Allinea Studio version 22.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libc6-dev \ lmod \ python \ tar \ tcl \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://developer.arm.com/-/media/Files/downloads/hpc/arm-allinea-studio/22-0/ACfL/arm-compiler-for-linux_22.0_Ubuntu-20.04_aarch64.tar && \ mkdir -p /var/tmp && tar -x -f /var/tmp/arm-compiler-for-linux_22.0_Ubuntu-20.04_aarch64.tar -C /var/tmp && \ cd /var/tmp/arm-compiler-for-linux_22.0_Ubuntu-20.04 && ./arm-compiler-for-linux_22.0_Ubuntu-20.04.sh --install-to /opt/arm --accept && \ rm -rf /var/tmp/arm-compiler-for-linux_22.0_Ubuntu-20.04_aarch64.tar /var/tmp/arm-compiler-for-linux_22.0_Ubuntu-20.04 ENV MODULEPATH=/opt/arm/modulefiles:$MODULEPATH''') @aarch64 @centos @docker def test_defaults_centos(self): """Default arm_allinea_studio building block""" a = arm_allinea_studio(eula=True) self.assertEqual(str(a), r'''# Arm Allinea Studio version 22.0 RUN yum install -y epel-release && \ yum install -y \ Lmod \ glibc-devel \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://developer.arm.com/-/media/Files/downloads/hpc/arm-allinea-studio/22-0/ACfL/arm-compiler-for-linux_22.0_RHEL-7_aarch64.tar && \ mkdir -p /var/tmp && tar -x -f /var/tmp/arm-compiler-for-linux_22.0_RHEL-7_aarch64.tar -C /var/tmp && \ cd /var/tmp/arm-compiler-for-linux_22.0_RHEL-7 && ./arm-compiler-for-linux_22.0_RHEL-7.sh --install-to /opt/arm --accept && \ rm -rf /var/tmp/arm-compiler-for-linux_22.0_RHEL-7_aarch64.tar /var/tmp/arm-compiler-for-linux_22.0_RHEL-7 ENV MODULEPATH=/opt/arm/modulefiles:$MODULEPATH''') @aarch64 @centos8 @docker def test_thunderx2_centos8(self): """Default arm_allinea_studio building block""" a = arm_allinea_studio(eula=True, version='20.3', microarchitectures=['generic', 'thunderx2t99']) self.assertEqual(str(a), r'''# Arm Allinea Studio version 20.3 RUN yum install -y epel-release && \ yum install -y \ Lmod \ glibc-devel \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://developer.arm.com/-/media/Files/downloads/hpc/arm-allinea-studio/20-3/RHEL8/arm-compiler-for-linux_20.3_RHEL-8_aarch64.tar && \ mkdir -p /var/tmp && tar -x -f /var/tmp/arm-compiler-for-linux_20.3_RHEL-8_aarch64.tar -C /var/tmp && \ cd /var/tmp/arm-compiler-for-linux_20.3_RHEL-8_aarch64 && ./arm-compiler-for-linux_20.3_RHEL-8.sh --install-to /opt/arm --accept --only-install-microarchitectures=generic,thunderx2t99 && \ rm -rf /var/tmp/arm-compiler-for-linux_20.3_RHEL-8_aarch64.tar /var/tmp/arm-compiler-for-linux_20.3_RHEL-8_aarch64 ENV MODULEPATH=/opt/arm/modulefiles:$MODULEPATH''') @aarch64 @ubuntu @docker def test_eula(self): """Decline EULA""" with self.assertRaises(RuntimeError): a = arm_allinea_studio(eula=False) str(a) @aarch64 @ubuntu @docker def test_tarball(self): """tarball""" a = arm_allinea_studio(eula=True, tarball='arm-compiler-for-linux_22.0_Ubuntu-18.04_aarch64.tar') self.assertEqual(str(a), r'''# Arm Allinea Studio version 22.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libc6-dev \ lmod \ python \ tar \ tcl \ wget && \ rm -rf /var/lib/apt/lists/* COPY arm-compiler-for-linux_22.0_Ubuntu-18.04_aarch64.tar /var/tmp RUN mkdir -p /var/tmp && tar -x -f /var/tmp/arm-compiler-for-linux_22.0_Ubuntu-18.04_aarch64.tar -C /var/tmp && \ cd /var/tmp/arm-compiler-for-linux_22.0_Ubuntu-18.04 && ./arm-compiler-for-linux_22.0_Ubuntu-18.04.sh --install-to /opt/arm --accept && \ rm -rf /var/tmp/arm-compiler-for-linux_22.0_Ubuntu-18.04_aarch64.tar /var/tmp/arm-compiler-for-linux_22.0_Ubuntu-18.04 ENV MODULEPATH=/opt/arm/modulefiles:$MODULEPATH''') @aarch64 @centos @docker def test_runtime_centos(self): """Runtime""" a = arm_allinea_studio(eula=True) r = a.runtime() self.assertEqual(r, r'''# Arm Allinea Studio COPY --from=0 /opt/arm/arm-linux-compiler-22.0_Generic-AArch64_RHEL-7_aarch64-linux/lib/libgomp.so \ /opt/arm/arm-linux-compiler-22.0_Generic-AArch64_RHEL-7_aarch64-linux/lib/libiomp5.so \ /opt/arm/arm-linux-compiler-22.0_Generic-AArch64_RHEL-7_aarch64-linux/lib/libomp.so \ /opt/arm/arm-linux-compiler-22.0_Generic-AArch64_RHEL-7_aarch64-linux/lib/libflang.so \ /opt/arm/arm-linux-compiler-22.0_Generic-AArch64_RHEL-7_aarch64-linux/lib/libflangrti.so \ /opt/arm/arm-linux-compiler-22.0_Generic-AArch64_RHEL-7_aarch64-linux/lib/ COPY --from=0 /opt/arm/armpl-22.0.0_AArch64_RHEL-7_arm-linux-compiler_aarch64-linux/lib/libamath.so \ /opt/arm/armpl-22.0.0_AArch64_RHEL-7_arm-linux-compiler_aarch64-linux/lib/libastring.so \ /opt/arm/armpl-22.0.0_AArch64_RHEL-7_arm-linux-compiler_aarch64-linux/lib/ COPY --from=0 /opt/arm/armpl-22.0.0_AArch64_RHEL-7_gcc_aarch64-linux/lib/libamath.so \ /opt/arm/armpl-22.0.0_AArch64_RHEL-7_gcc_aarch64-linux/lib/libastring.so \ /opt/arm/armpl-22.0.0_AArch64_RHEL-7_gcc_aarch64-linux/lib/ ENV LD_LIBRARY_PATH=/opt/arm/arm-linux-compiler-22.0_Generic-AArch64_RHEL-7_aarch64-linux/lib:/opt/arm/armpl-22.0.0_AArch64_RHEL-7_arm-linux-compiler_aarch64-linux/lib:/opt/arm/armpl-22.0.0_AArch64_RHEL-7_gcc_aarch64-linux/lib:$LD_LIBRARY_PATH''') def test_toolchain(self): """Toolchain""" a = arm_allinea_studio(eula=True) tc = a.toolchain self.assertEqual(tc.CC, 'armclang') self.assertEqual(tc.CXX, 'armclang++') self.assertEqual(tc.FC, 'armflang') self.assertEqual(tc.F77, 'armflang') self.assertEqual(tc.F90, 'armflang') @thunderx2 def test_toolchain_thunderx2(self): """CPU target optimization flags""" a = arm_allinea_studio(eula=True) tc = a.toolchain self.assertEqual(tc.CFLAGS, '-mcpu=thunderx2t99') self.assertEqual(tc.CXXFLAGS, '-mcpu=thunderx2t99')
hpc-container-maker-master
test/test_arm_allinea_studio.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the git module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from hpccm.templates.git import git class Test_git(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_missing_repo(self): """Missing repository option""" g = git() self.assertEqual(g.clone_step(), '') def test_basic(self): """Basic git""" g = git() self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git'), 'mkdir -p /tmp && cd /tmp && git clone --depth=1 https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') def test_branch_recursive(self): """git with specified branch and recursive""" g = git() self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', branch='master', recursive=True), 'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch master --recursive https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') def test_commit(self): """git with specified commit""" g = git() self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', commit='ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c'), 'mkdir -p /tmp && cd /tmp && git clone https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c && cd -') self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', commit='ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c', verify='fatal'), 'mkdir -p /tmp && cd /tmp && git clone https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c && cd -') def test_branch_and_commit(self): """git with both specified branch and specified commit""" g = git() self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', branch='master', commit='ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c'), 'mkdir -p /tmp && cd /tmp && git clone https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c && cd -') def test_tag(self): """git with specified tag""" g = git() valid_tag='v20.5.0' invalid_tag='v-1.-2.-3' self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', branch=valid_tag), 'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch v20.5.0 https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', branch=invalid_tag), 'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch v-1.-2.-3 https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', branch=valid_tag, verify='fatal'), 'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch v20.5.0 https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') with self.assertRaises(RuntimeError): g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', branch=invalid_tag, verify='fatal') def test_path(self): """git with non-default base path""" g = git() self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', path='/scratch'), 'mkdir -p /scratch && cd /scratch && git clone --depth=1 https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') def test_directory(self): """git with non-default directory to clone into""" g = git() self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', directory='hpccm'), 'mkdir -p /tmp && cd /tmp && git clone --depth=1 https://github.com/NVIDIA/hpc-container-maker.git hpccm && cd -') def test_lfs(self): """Basic git""" g = git() self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git', lfs=True), 'mkdir -p /tmp && cd /tmp && git lfs clone --depth=1 https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') def test_opts(self): """git with non-default command line options""" g = git(opts=['--single-branch']) self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git'), 'mkdir -p /tmp && cd /tmp && git clone --single-branch https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') # This test will fail if git is not installed on the system def test_verify(self): """git with verification enabled""" g = git() repository = 'https://github.com/NVIDIA/hpc-container-maker.git' valid_branch = 'master' invalid_branch = 'does_not_exist' valid_commit = '23996b03b3e72f77a41498e94d90de920935644a' invalid_commit = 'deadbeef' self.assertEqual(g.clone_step(repository=repository, branch=valid_branch, verify=True), 'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch master https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') self.assertEqual(g.clone_step(repository=repository, branch=invalid_branch, verify=True), 'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch does_not_exist https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -') self.assertEqual(g.clone_step(repository=repository, commit=valid_commit, verify=True), 'mkdir -p /tmp && cd /tmp && git clone https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout 23996b03b3e72f77a41498e94d90de920935644a && cd -') self.assertEqual(g.clone_step(repository=repository, commit=invalid_commit, verify=True), 'mkdir -p /tmp && cd /tmp && git clone https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout deadbeef && cd -') with self.assertRaises(RuntimeError): g.clone_step(repository=repository, branch=invalid_branch, verify='fatal')
hpc-container-maker-master
test/test_git.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the pgi module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ppc64le, ubuntu, x86_64 from hpccm.building_blocks.pgi import pgi class Test_pgi(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default pgi building block""" with self.assertRaises(RuntimeError): # no tarball specified p = pgi() @x86_64 @ubuntu @docker def test_eula(self): """Test EULA""" p = pgi(tarball='pgilinux-2017-1710-x86_64.tar.gz') self.assertEqual(str(p), r'''# PGI compiler version 17.10 COPY pgilinux-2017-1710-x86_64.tar.gz /var/tmp/pgilinux-2017-1710-x86_64.tar.gz RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ libnuma1 \ perl && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp/pgi && tar -x -f /var/tmp/pgilinux-2017-1710-x86_64.tar.gz -C /var/tmp/pgi -z && \ cd /var/tmp/pgi && PGI_ACCEPT_EULA=decline PGI_INSTALL_DIR=/opt/pgi PGI_INSTALL_MPI=false PGI_INSTALL_NVIDIA=true PGI_MPI_GPU_SUPPORT=false PGI_SILENT=false ./install && \ echo "variable LIBRARY_PATH is environment(LIBRARY_PATH);" >> /opt/pgi/linux86-64/17.10/bin/siterc && \ echo "variable library_path is default(\$if(\$LIBRARY_PATH,\$foreach(ll,\$replace(\$LIBRARY_PATH,":",), -L\$ll)));" >> /opt/pgi/linux86-64/17.10/bin/siterc && \ echo "append LDLIBARGS=\$library_path;" >> /opt/pgi/linux86-64/17.10/bin/siterc && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/17.10/lib/libnuma.so && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/17.10/lib/libnuma.so.1 && \ rm -rf /var/tmp/pgilinux-2017-1710-x86_64.tar.gz /var/tmp/pgi ENV LD_LIBRARY_PATH=/opt/pgi/linux86-64/17.10/lib:$LD_LIBRARY_PATH \ PATH=/opt/pgi/linux86-64/17.10/bin:$PATH''') @x86_64 @ubuntu @docker def test_tarball(self): """tarball""" p = pgi(eula=True, tarball='pgilinux-2017-1710-x86_64.tar.gz') self.assertEqual(str(p), r'''# PGI compiler version 17.10 COPY pgilinux-2017-1710-x86_64.tar.gz /var/tmp/pgilinux-2017-1710-x86_64.tar.gz RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ libnuma1 \ perl && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp/pgi && tar -x -f /var/tmp/pgilinux-2017-1710-x86_64.tar.gz -C /var/tmp/pgi -z && \ cd /var/tmp/pgi && PGI_ACCEPT_EULA=accept PGI_INSTALL_DIR=/opt/pgi PGI_INSTALL_MPI=false PGI_INSTALL_NVIDIA=true PGI_MPI_GPU_SUPPORT=false PGI_SILENT=true ./install && \ echo "variable LIBRARY_PATH is environment(LIBRARY_PATH);" >> /opt/pgi/linux86-64/17.10/bin/siterc && \ echo "variable library_path is default(\$if(\$LIBRARY_PATH,\$foreach(ll,\$replace(\$LIBRARY_PATH,":",), -L\$ll)));" >> /opt/pgi/linux86-64/17.10/bin/siterc && \ echo "append LDLIBARGS=\$library_path;" >> /opt/pgi/linux86-64/17.10/bin/siterc && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/17.10/lib/libnuma.so && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/17.10/lib/libnuma.so.1 && \ rm -rf /var/tmp/pgilinux-2017-1710-x86_64.tar.gz /var/tmp/pgi ENV LD_LIBRARY_PATH=/opt/pgi/linux86-64/17.10/lib:$LD_LIBRARY_PATH \ PATH=/opt/pgi/linux86-64/17.10/bin:$PATH''') @x86_64 @ubuntu @docker def test_tarball2(self): """tarball""" p = pgi(eula=True, tarball='pkg/pgilinux-2018-1804-x86_64.tar.gz') self.assertEqual(str(p), r'''# PGI compiler version 18.4 COPY pkg/pgilinux-2018-1804-x86_64.tar.gz /var/tmp/pgilinux-2018-1804-x86_64.tar.gz RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ libnuma1 \ perl && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp/pgi && tar -x -f /var/tmp/pgilinux-2018-1804-x86_64.tar.gz -C /var/tmp/pgi -z && \ cd /var/tmp/pgi && PGI_ACCEPT_EULA=accept PGI_INSTALL_DIR=/opt/pgi PGI_INSTALL_MPI=false PGI_INSTALL_NVIDIA=true PGI_MPI_GPU_SUPPORT=false PGI_SILENT=true ./install && \ echo "variable LIBRARY_PATH is environment(LIBRARY_PATH);" >> /opt/pgi/linux86-64/18.4/bin/siterc && \ echo "variable library_path is default(\$if(\$LIBRARY_PATH,\$foreach(ll,\$replace(\$LIBRARY_PATH,":",), -L\$ll)));" >> /opt/pgi/linux86-64/18.4/bin/siterc && \ echo "append LDLIBARGS=\$library_path;" >> /opt/pgi/linux86-64/18.4/bin/siterc && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/18.4/lib/libnuma.so && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/18.4/lib/libnuma.so.1 && \ rm -rf /var/tmp/pgilinux-2018-1804-x86_64.tar.gz /var/tmp/pgi ENV LD_LIBRARY_PATH=/opt/pgi/linux86-64/18.4/lib:$LD_LIBRARY_PATH \ PATH=/opt/pgi/linux86-64/18.4/bin:$PATH''') @x86_64 @ubuntu @docker def test_tarball_no_leading_zero(self): """tarball""" p = pgi(eula=True, tarball='pgilinux-2018-184-x86_64.tar.gz') self.assertEqual(str(p), r'''# PGI compiler version 18.4 COPY pgilinux-2018-184-x86_64.tar.gz /var/tmp/pgilinux-2018-184-x86_64.tar.gz RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ libnuma1 \ perl && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp/pgi && tar -x -f /var/tmp/pgilinux-2018-184-x86_64.tar.gz -C /var/tmp/pgi -z && \ cd /var/tmp/pgi && PGI_ACCEPT_EULA=accept PGI_INSTALL_DIR=/opt/pgi PGI_INSTALL_MPI=false PGI_INSTALL_NVIDIA=true PGI_MPI_GPU_SUPPORT=false PGI_SILENT=true ./install && \ echo "variable LIBRARY_PATH is environment(LIBRARY_PATH);" >> /opt/pgi/linux86-64/18.4/bin/siterc && \ echo "variable library_path is default(\$if(\$LIBRARY_PATH,\$foreach(ll,\$replace(\$LIBRARY_PATH,":",), -L\$ll)));" >> /opt/pgi/linux86-64/18.4/bin/siterc && \ echo "append LDLIBARGS=\$library_path;" >> /opt/pgi/linux86-64/18.4/bin/siterc && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/18.4/lib/libnuma.so && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/18.4/lib/libnuma.so.1 && \ rm -rf /var/tmp/pgilinux-2018-184-x86_64.tar.gz /var/tmp/pgi ENV LD_LIBRARY_PATH=/opt/pgi/linux86-64/18.4/lib:$LD_LIBRARY_PATH \ PATH=/opt/pgi/linux86-64/18.4/bin:$PATH''') @x86_64 @ubuntu @docker def test_runtime_ubuntu(self): """Runtime""" p = pgi(tarball='pgilinux-2019-1910-x86_64.tar.gz') r = p.runtime() self.assertEqual(r, r'''# PGI compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnuma1 && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /opt/pgi/linux86-64-llvm/19.10/REDIST/*.so* /opt/pgi/linux86-64/19.10/lib/ RUN ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/19.10/lib/libnuma.so && \ ln -sf /usr/lib/x86_64-linux-gnu/libnuma.so.1 /opt/pgi/linux86-64/19.10/lib/libnuma.so.1 ENV LD_LIBRARY_PATH=/opt/pgi/linux86-64/19.10/lib:$LD_LIBRARY_PATH''') @x86_64 @centos @docker def test_runtime_centos(self): """Runtime""" p = pgi(tarball='pgilinux-2019-1910-x86_64.tar.gz') r = p.runtime() self.assertEqual(r, r'''# PGI compiler RUN yum install -y \ numactl-libs && \ rm -rf /var/cache/yum/* COPY --from=0 /opt/pgi/linux86-64-llvm/19.10/REDIST/*.so* /opt/pgi/linux86-64/19.10/lib/ RUN ln -sf /usr/lib64/libnuma.so.1 /opt/pgi/linux86-64/19.10/lib/libnuma.so && \ ln -sf /usr/lib64/libnuma.so.1 /opt/pgi/linux86-64/19.10/lib/libnuma.so.1 ENV LD_LIBRARY_PATH=/opt/pgi/linux86-64/19.10/lib:$LD_LIBRARY_PATH''') @x86_64 @centos @docker def test_runtime_mpi_centos(self): """Runtime""" p = pgi(mpi=True, tarball='pgilinux-2019-1910-x86_64.tar.gz') r = p.runtime() self.assertEqual(r, r'''# PGI compiler RUN yum install -y \ numactl-libs \ openssh-clients && \ rm -rf /var/cache/yum/* COPY --from=0 /opt/pgi/linux86-64-llvm/19.10/REDIST/*.so* /opt/pgi/linux86-64/19.10/lib/ COPY --from=0 /opt/pgi/linux86-64/19.10/mpi/openmpi-3.1.3 /opt/pgi/linux86-64/19.10/mpi/openmpi-3.1.3 RUN ln -sf /usr/lib64/libnuma.so.1 /opt/pgi/linux86-64/19.10/lib/libnuma.so && \ ln -sf /usr/lib64/libnuma.so.1 /opt/pgi/linux86-64/19.10/lib/libnuma.so.1 ENV LD_LIBRARY_PATH=/opt/pgi/linux86-64/19.10/mpi/openmpi-3.1.3/lib:/opt/pgi/linux86-64/19.10/lib:$LD_LIBRARY_PATH \ PATH=/opt/pgi/linux86-64/19.10/mpi/openmpi-3.1.3/bin:$PATH''') def test_toolchain(self): """Toolchain""" p = pgi(tarball='foo') tc = p.toolchain self.assertEqual(tc.CC, 'pgcc') self.assertEqual(tc.CXX, 'pgc++') self.assertEqual(tc.FC, 'pgfortran') self.assertEqual(tc.F77, 'pgfortran') self.assertEqual(tc.F90, 'pgfortran')
hpc-container-maker-master
test/test_pgi.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the kokkos module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, centos8, docker, ubuntu from hpccm.building_blocks.kokkos import kokkos class Test_kokkos(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default kokkos building block""" k = kokkos() self.assertEqual(str(k), r'''# Kokkos version 3.2.00 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ gzip \ libhwloc-dev \ make \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/kokkos/kokkos/archive/3.2.00.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/3.2.00.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/kokkos-3.2.00/build && cd /var/tmp/kokkos-3.2.00/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/kokkos -DCMAKE_BUILD_TYPE=RELEASE -DKokkos_ARCH_VOLTA70=ON -DKokkos_ENABLE_CUDA=ON -DCMAKE_CXX_COMPILER=$(pwd)/../bin/nvcc_wrapper -DKokkos_ENABLE_HWLOC=ON /var/tmp/kokkos-3.2.00 && \ cmake --build /var/tmp/kokkos-3.2.00/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/kokkos-3.2.00/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/kokkos-3.2.00 /var/tmp/3.2.00.tar.gz ENV PATH=/usr/local/kokkos/bin:$PATH''') @centos @docker def test_defaults_centos(self): """Default kokkos building block""" k = kokkos() self.assertEqual(str(k), r'''# Kokkos version 3.2.00 RUN yum install -y \ gzip \ hwloc-devel \ make \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/kokkos/kokkos/archive/3.2.00.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/3.2.00.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/kokkos-3.2.00/build && cd /var/tmp/kokkos-3.2.00/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/kokkos -DCMAKE_BUILD_TYPE=RELEASE -DKokkos_ARCH_VOLTA70=ON -DKokkos_ENABLE_CUDA=ON -DCMAKE_CXX_COMPILER=$(pwd)/../bin/nvcc_wrapper -DKokkos_ENABLE_HWLOC=ON /var/tmp/kokkos-3.2.00 && \ cmake --build /var/tmp/kokkos-3.2.00/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/kokkos-3.2.00/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/kokkos-3.2.00 /var/tmp/3.2.00.tar.gz ENV PATH=/usr/local/kokkos/bin:$PATH''') @centos8 @docker def test_defaults_centos8(self): """Default kokkos building block""" k = kokkos() self.assertEqual(str(k), r'''# Kokkos version 3.2.00 RUN yum install -y dnf-utils && \ yum-config-manager --set-enabled powertools && \ yum install -y \ gzip \ hwloc-devel \ make \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/kokkos/kokkos/archive/3.2.00.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/3.2.00.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/kokkos-3.2.00/build && cd /var/tmp/kokkos-3.2.00/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/kokkos -DCMAKE_BUILD_TYPE=RELEASE -DKokkos_ARCH_VOLTA70=ON -DKokkos_ENABLE_CUDA=ON -DCMAKE_CXX_COMPILER=$(pwd)/../bin/nvcc_wrapper -DKokkos_ENABLE_HWLOC=ON /var/tmp/kokkos-3.2.00 && \ cmake --build /var/tmp/kokkos-3.2.00/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/kokkos-3.2.00/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/kokkos-3.2.00 /var/tmp/3.2.00.tar.gz ENV PATH=/usr/local/kokkos/bin:$PATH''') @ubuntu @docker def test_check_and_repository(self): """Check and repository options""" k = kokkos(check=True, repository=True, version='3.1.01') self.assertEqual(str(k), r'''# Kokkos version 3.1.01 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ git \ libhwloc-dev \ make && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 https://github.com/kokkos/kokkos.git kokkos && cd - && \ mkdir -p /var/tmp/kokkos/build && cd /var/tmp/kokkos/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/kokkos -DCMAKE_BUILD_TYPE=RELEASE -DKokkos_ARCH_VOLTA70=ON -DKokkos_ENABLE_TESTS=ON -DKokkos_ENABLE_CUDA=ON -DCMAKE_CXX_COMPILER=$(pwd)/../bin/nvcc_wrapper -DKokkos_ENABLE_HWLOC=ON /var/tmp/kokkos && \ cmake --build /var/tmp/kokkos/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/kokkos/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/kokkos ENV PATH=/usr/local/kokkos/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" k = kokkos() r = k.runtime() self.assertEqual(r, r'''# Kokkos COPY --from=0 /usr/local/kokkos /usr/local/kokkos ENV PATH=/usr/local/kokkos/bin:$PATH''')
hpc-container-maker-master
test/test_kokkos.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the magma module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.magma import magma from hpccm.toolchain import toolchain class Test_sensei(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default magma building block""" m = magma() self.assertEqual(str(m), r'''# MAGMA version 2.5.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://icl.utk.edu/projectsfiles/magma/downloads/magma-2.5.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/magma-2.5.3.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/magma-2.5.3/build && cd /var/tmp/magma-2.5.3/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/magma -DGPU_TARGET="Pascal Volta Turing" /var/tmp/magma-2.5.3 && \ cmake --build /var/tmp/magma-2.5.3/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/magma-2.5.3/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/magma-2.5.3 /var/tmp/magma-2.5.3.tar.gz ENV CPATH=/usr/local/magma/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/magma/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/magma/lib:$LIBRARY_PATH''') @centos @docker def test_defaults_centos(self): """Default magma building block""" m = magma() self.assertEqual(str(m), r'''# MAGMA version 2.5.3 RUN yum install -y \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://icl.utk.edu/projectsfiles/magma/downloads/magma-2.5.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/magma-2.5.3.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/magma-2.5.3/build && cd /var/tmp/magma-2.5.3/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/magma -DGPU_TARGET="Pascal Volta Turing" /var/tmp/magma-2.5.3 && \ cmake --build /var/tmp/magma-2.5.3/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/magma-2.5.3/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/magma-2.5.3 /var/tmp/magma-2.5.3.tar.gz ENV CPATH=/usr/local/magma/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/magma/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/magma/lib:$LIBRARY_PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" m = magma() r = m.runtime() self.assertEqual(r, r'''# MAGMA COPY --from=0 /usr/local/magma /usr/local/magma ENV CPATH=/usr/local/magma/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/magma/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/magma/lib:$LIBRARY_PATH''')
hpc-container-maker-master
test/test_magma.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the nccl module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, centos8, docker, ppc64le, ubuntu, ubuntu18, x86_64 from hpccm.building_blocks.nccl import nccl class Test_nccl(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """nccl defaults""" n = nccl() self.assertEqual(str(n), r'''# NCCL 2.12.10-1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub | apt-key add - && \ echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnccl-dev=2.12.10-1+cuda11.6 \ libnccl2=2.12.10-1+cuda11.6 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu18 @docker def test_defaults_ubuntu18(self): """nccl defaults""" n = nccl() self.assertEqual(str(n), r'''# NCCL 2.12.10-1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub | apt-key add - && \ echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnccl-dev=2.12.10-1+cuda11.6 \ libnccl2=2.12.10-1+cuda11.6 && \ rm -rf /var/lib/apt/lists/*''') @ppc64le @ubuntu @docker def test_ubuntu_ppc64le(self): """nccl ppc64le""" n = nccl(cuda=9.2, version='2.4.8-1') self.assertEqual(str(n), r'''# NCCL 2.4.8-1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/ppc64el/3bf863cc.pub | apt-key add - && \ echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/ppc64el /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnccl-dev=2.4.8-1+cuda9.2 \ libnccl2=2.4.8-1+cuda9.2 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu @docker def test_build_ubuntu(self): """nccl build""" n = nccl(build=True) self.assertEqual(str(n), r'''# NCCL RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/nccl/archive/v2.12.10-1.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2.12.10-1.tar.gz -C /var/tmp -z && \ cd /var/tmp/nccl-2.12.10-1 && \ PREFIX=/usr/local/nccl make -j$(nproc) install && \ rm -rf /var/tmp/nccl-2.12.10-1 /var/tmp/v2.12.10-1.tar.gz ENV CPATH=/usr/local/nccl/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nccl/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nccl/lib:$LIBRARY_PATH \ PATH=/usr/local/nccl/bin:$PATH''') @x86_64 @centos @docker def test_defaults_centos(self): """nccl defaults""" n = nccl() self.assertEqual(str(n), r'''# NCCL 2.12.10-1 RUN rpm --import https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/3bf863cc.pub && \ yum install -y yum-utils && \ yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64 && \ yum install -y \ libnccl-2.12.10-1+cuda11.6 \ libnccl-devel-2.12.10-1+cuda11.6 && \ rm -rf /var/cache/yum/*''') @x86_64 @centos8 @docker def test_defaults_centos8(self): """nccl defaults""" n = nccl() self.assertEqual(str(n), r'''# NCCL 2.12.10-1 RUN rpm --import https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/3bf863cc.pub && \ yum install -y dnf-utils && \ yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64 && \ yum install -y \ libnccl-2.12.10-1+cuda11.6 \ libnccl-devel-2.12.10-1+cuda11.6 && \ rm -rf /var/cache/yum/*''') @x86_64 @ubuntu @docker def test_build_repo_ubuntu(self): """nccl build from git""" n = nccl(build=True, make_variables={'CUDA_HOME': '/usr/local/cuda'}, repository=True) self.assertEqual(str(n), r'''# NCCL RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ git \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 https://github.com/NVIDIA/nccl.git nccl && cd - && \ cd /var/tmp/nccl && \ CUDA_HOME=/usr/local/cuda PREFIX=/usr/local/nccl make -j$(nproc) install && \ rm -rf /var/tmp/nccl ENV CPATH=/usr/local/nccl/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nccl/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nccl/lib:$LIBRARY_PATH \ PATH=/usr/local/nccl/bin:$PATH''') @centos @docker def test_build_centos(self): """nccl build""" n = nccl(build=True, version='2.7.6-1') self.assertEqual(str(n), r'''# NCCL RUN yum install -y \ make \ wget \ which && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/nccl/archive/v2.7.6-1.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2.7.6-1.tar.gz -C /var/tmp -z && \ cd /var/tmp/nccl-2.7.6-1 && \ PREFIX=/usr/local/nccl make -j$(nproc) install && \ rm -rf /var/tmp/nccl-2.7.6-1 /var/tmp/v2.7.6-1.tar.gz ENV CPATH=/usr/local/nccl/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nccl/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nccl/lib:$LIBRARY_PATH \ PATH=/usr/local/nccl/bin:$PATH''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" n = nccl() r = n.runtime() self.assertEqual(r, r'''# NCCL RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub | apt-key add - && \ echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnccl2=2.12.10-1+cuda11.6 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu @docker def test_build_runtime(self): """Runtime""" n = nccl(build=True) r = n.runtime() self.assertEqual(r, r'''# NCCL COPY --from=0 /usr/local/nccl /usr/local/nccl ENV CPATH=/usr/local/nccl/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nccl/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nccl/lib:$LIBRARY_PATH \ PATH=/usr/local/nccl/bin:$PATH''')
hpc-container-maker-master
test/test_nccl.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the ucx module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ppc64le, ubuntu, x86_64 from hpccm.building_blocks.ucx import ucx class Test_ucx(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default ucx building block""" u = ucx() self.assertEqual(str(u), r'''# UCX version 1.9.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ binutils-dev \ file \ libnuma-dev \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openucx/ucx/releases/download/v1.9.0/ucx-1.9.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/ucx-1.9.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/ucx-1.9.0 && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx-1.9.0 /var/tmp/ucx-1.9.0.tar.gz ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @x86_64 @centos @docker def test_defaults_centos(self): """Default ucx building block""" u = ucx() self.assertEqual(str(u), r'''# UCX version 1.9.0 RUN yum install -y \ binutils-devel \ file \ make \ numactl-devel \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openucx/ucx/releases/download/v1.9.0/ucx-1.9.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/ucx-1.9.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/ucx-1.9.0 && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx-1.9.0 /var/tmp/ucx-1.9.0.tar.gz ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @x86_64 @ubuntu @docker def test_with_paths_ubuntu(self): """ucx building block with paths""" u = ucx(cuda='/cuda', gdrcopy='/gdrcopy', knem='/knem', ofed='/ofed', xpmem='/xpmem', version='1.8.0') self.assertEqual(str(u), r'''# UCX version 1.8.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ binutils-dev \ file \ libnuma-dev \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openucx/ucx/releases/download/v1.8.0/ucx-1.8.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/ucx-1.8.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/ucx-1.8.0 && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-cuda=/cuda --with-gdrcopy=/gdrcopy --with-knem=/knem --with-rdmacm=/ofed --with-verbs=/ofed --with-xpmem=/xpmem && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx-1.8.0 /var/tmp/ucx-1.8.0.tar.gz ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @x86_64 @ubuntu @docker def test_with_true_ubuntu(self): """ucx building block with True values""" u = ucx(cuda=True, gdrcopy=True, knem=True, ofed=True, xpmem=True, version='1.8.0') self.assertEqual(str(u), r'''# UCX version 1.8.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ binutils-dev \ file \ libnuma-dev \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openucx/ucx/releases/download/v1.8.0/ucx-1.8.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/ucx-1.8.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/ucx-1.8.0 && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-cuda=/usr/local/cuda --with-gdrcopy --with-knem --with-rdmacm --with-verbs --with-xpmem && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx-1.8.0 /var/tmp/ucx-1.8.0.tar.gz ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @x86_64 @ubuntu @docker def test_with_false_ubuntu(self): """ucx building block with False values""" u = ucx(cuda=False, gdrcopy=False, knem=False, ofed=False, xpmem=False, version='1.8.0') self.assertEqual(str(u), r'''# UCX version 1.8.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ binutils-dev \ file \ libnuma-dev \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openucx/ucx/releases/download/v1.8.0/ucx-1.8.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/ucx-1.8.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/ucx-1.8.0 && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --without-cuda --without-gdrcopy --without-knem --without-rdmacm --without-verbs --without-xpmem && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx-1.8.0 /var/tmp/ucx-1.8.0.tar.gz ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @x86_64 @ubuntu @docker def test_ldconfig(self): """ldconfig option""" u = ucx(ldconfig=True, version='1.4.0') self.assertEqual(str(u), r'''# UCX version 1.4.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ binutils-dev \ file \ libnuma-dev \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openucx/ucx/releases/download/v1.4.0/ucx-1.4.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/ucx-1.4.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/ucx-1.4.0 && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/ucx/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/ucx-1.4.0 /var/tmp/ucx-1.4.0.tar.gz ENV CPATH=/usr/local/ucx/include:$CPATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @x86_64 @ubuntu @docker def test_environment(self): """environment option""" u = ucx(environment=False, version='1.4.0') self.assertEqual(str(u), r'''# UCX version 1.4.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ binutils-dev \ file \ libnuma-dev \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openucx/ucx/releases/download/v1.4.0/ucx-1.4.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/ucx-1.4.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/ucx-1.4.0 && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx-1.4.0 /var/tmp/ucx-1.4.0.tar.gz''') @ppc64le @centos @docker def test_ppc64le(self): """ppc64le""" u = ucx(cuda=False, knem='/usr/local/knem', version='1.5.2') self.assertEqual(str(u), r'''# UCX version 1.5.2 RUN yum install -y \ binutils-devel \ file \ make \ numactl-devel \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openucx/ucx/releases/download/v1.5.2/ucx-1.5.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/ucx-1.5.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/ucx-1.5.2 && CFLAGS=-Wno-error=format ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-knem=/usr/local/knem --without-cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx-1.5.2 /var/tmp/ucx-1.5.2.tar.gz ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @x86_64 @ubuntu @docker def test_git_repository_true(self): u = ucx(repository=True) self.assertEqual(str(u), r'''# UCX https://github.com/openucx/ucx.git RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ binutils-dev \ ca-certificates \ file \ git \ libnuma-dev \ libtool \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 https://github.com/openucx/ucx.git ucx && cd - && \ cd /var/tmp/ucx && \ ./autogen.sh && \ cd /var/tmp/ucx && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @x86_64 @ubuntu @docker def test_git_repository_value(self): u = ucx(branch='v1.8.x', repository='https://github.com/openucx-fork/ucx.git') self.assertEqual(str(u), r'''# UCX https://github.com/openucx-fork/ucx.git v1.8.x RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ binutils-dev \ ca-certificates \ file \ git \ libnuma-dev \ libtool \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v1.8.x https://github.com/openucx-fork/ucx.git ucx && cd - && \ cd /var/tmp/ucx && \ ./autogen.sh && \ cd /var/tmp/ucx && ./configure --prefix=/usr/local/ucx --disable-assertions --disable-debug --disable-doxygen-doc --disable-logging --disable-params-check --enable-optimizations --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ucx ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" u = ucx() r = u.runtime() self.assertEqual(r, r'''# UCX RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ binutils && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/ucx /usr/local/ucx ENV CPATH=/usr/local/ucx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/ucx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/ucx/lib:$LIBRARY_PATH \ PATH=/usr/local/ucx/bin:$PATH''')
hpc-container-maker-master
test/test_ucx.py
from hpccm.common import container_type if hpccm.config.g_ctype != container_type.SINGULARITY: raise Exception("Global variable g_ctype not set correctly!")
hpc-container-maker-master
test/global_vars_recipe.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the openmpi module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.nvhpc import nvhpc from hpccm.building_blocks.openmpi import openmpi class Test_openmpi(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default openmpi building block""" ompi = openmpi() self.assertEqual(str(ompi), r'''# OpenMPI version 4.0.5 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ hwloc \ libnuma-dev \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.5.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/openmpi-4.0.5.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/openmpi-4.0.5 && ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda --with-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/openmpi-4.0.5 /var/tmp/openmpi-4.0.5.tar.bz2 ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') @centos @docker def test_defaults_centos(self): """Default openmpi building block""" ompi = openmpi() self.assertEqual(str(ompi), r'''# OpenMPI version 4.0.5 RUN yum install -y \ bzip2 \ file \ hwloc \ make \ numactl-devel \ openssh-clients \ perl \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.5.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/openmpi-4.0.5.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/openmpi-4.0.5 && ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda --with-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/openmpi-4.0.5 /var/tmp/openmpi-4.0.5.tar.bz2 ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') @ubuntu @docker def test_ldconfig(self): """ldconfig option""" ompi = openmpi(ldconfig=True, version='3.1.2') self.assertEqual(str(ompi), r'''# OpenMPI version 3.1.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ hwloc \ libnuma-dev \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.open-mpi.org/software/ompi/v3.1/downloads/openmpi-3.1.2.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/openmpi-3.1.2.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/openmpi-3.1.2 && ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda --with-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/openmpi/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/openmpi-3.1.2 /var/tmp/openmpi-3.1.2.tar.bz2 ENV PATH=/usr/local/openmpi/bin:$PATH''') @ubuntu @docker def test_nvhpc(self): """HPC SDK toolchain""" compiler = nvhpc(eula=True) ompi = openmpi(toolchain=compiler.toolchain, version='4.0.4') self.assertEqual(str(ompi), r'''# OpenMPI version 4.0.4 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ hwloc \ libnuma-dev \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.4.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/openmpi-4.0.4.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/openmpi-4.0.4 && CC=nvc CFLAGS=-O1 CXX=nvc++ F77=nvfortran F90=nvfortran FC=nvfortran FCFLAGS='-fpic -DPIC' ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda --with-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/openmpi-4.0.4 /var/tmp/openmpi-4.0.4.tar.bz2 ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') @ubuntu @docker def test_pmi(self): """pmi options""" ompi = openmpi(pmi='/usr/local/slurm-pmi2', pmix='internal', version='4.0.1') self.assertEqual(str(ompi), r'''# OpenMPI version 4.0.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ hwloc \ libnuma-dev \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.1.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/openmpi-4.0.1.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/openmpi-4.0.1 && ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda --with-pmi=/usr/local/slurm-pmi2 --with-pmix=internal --with-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/openmpi-4.0.1 /var/tmp/openmpi-4.0.1.tar.bz2 ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') @ubuntu @docker def test_git_repository_true(self): """git repository True""" ompi = openmpi(repository=True) self.assertEqual(str(ompi), r'''# OpenMPI https://github.com/open-mpi/ompi.git RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ bzip2 \ ca-certificates \ file \ git \ hwloc \ libnuma-dev \ libtool \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --recursive https://github.com/open-mpi/ompi.git ompi && cd - && \ cd /var/tmp/ompi && \ ./autogen.pl && \ cd /var/tmp/ompi && ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda --with-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ompi ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') @ubuntu @docker def test_git_repository_value(self): """git repository value""" ompi = openmpi(branch='v4.0.x', repository='https://github.com/open-mpi-fork/ompi.git') self.assertEqual(str(ompi), r'''# OpenMPI https://github.com/open-mpi-fork/ompi.git v4.0.x RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ bzip2 \ ca-certificates \ file \ git \ hwloc \ libnuma-dev \ libtool \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v4.0.x --recursive https://github.com/open-mpi-fork/ompi.git ompi && cd - && \ cd /var/tmp/ompi && \ ./autogen.pl && \ cd /var/tmp/ompi && ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda --with-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ompi ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') @ubuntu @docker def test_cuda_path(self): """git repository value""" ompi = openmpi(branch='v4.0.x', repository='https://github.com/open-mpi-fork/ompi.git', cuda='/usr/local/cuda2') self.assertEqual(str(ompi), r'''# OpenMPI https://github.com/open-mpi-fork/ompi.git v4.0.x RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ bzip2 \ ca-certificates \ file \ git \ hwloc \ libnuma-dev \ libtool \ make \ openssh-client \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v4.0.x --recursive https://github.com/open-mpi-fork/ompi.git ompi && cd - && \ cd /var/tmp/ompi && \ ./autogen.pl && \ cd /var/tmp/ompi && ./configure --prefix=/usr/local/openmpi --disable-getpwuid --enable-orterun-prefix-by-default --with-cuda=/usr/local/cuda2 --with-verbs && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/ompi ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" ompi = openmpi() r = ompi.runtime() self.assertEqual(r, r'''# OpenMPI RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ hwloc \ openssh-client && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/openmpi /usr/local/openmpi ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/openmpi/bin:$PATH''') def test_toolchain(self): """Toolchain""" ompi = openmpi() tc = ompi.toolchain self.assertEqual(tc.CC, 'mpicc') self.assertEqual(tc.CXX, 'mpicxx') self.assertEqual(tc.FC, 'mpifort') self.assertEqual(tc.F77, 'mpif77') self.assertEqual(tc.F90, 'mpif90')
hpc-container-maker-master
test/test_openmpi.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the nsight_compute module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, centos8, docker, ppc64le, ubuntu, ubuntu18, x86_64 from hpccm.building_blocks.nsight_compute import nsight_compute class Test_nsight_compute(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_basic_ubuntu(self): """Default nsight_compute building block""" n = nsight_compute() self.assertEqual(str(n), r'''# NVIDIA Nsight Compute 2022.4.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/nvidia.gpg && \ wget -qO - https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/nvidia.pub | gpg --dearmor -o /usr/share/keyrings/nvidia.gpg && \ echo "deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/ /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nsight-compute-2022.4.0 && \ rm -rf /var/lib/apt/lists/* ENV NV_COMPUTE_PROFILER_DISABLE_STOCK_FILE_DEPLOYMENT=1 \ PATH=/opt/nvidia/nsight-compute/2022.4.0:$PATH''') @x86_64 @centos8 @docker def test_basic_centos8(self): """Default nsight_compute building block""" n = nsight_compute() self.assertEqual(str(n), r'''# NVIDIA Nsight Compute 2022.4.0 RUN rpm --import https://developer.download.nvidia.com/devtools/repos/rhel8/x86_64/nvidia.pub && \ yum install -y dnf-utils && \ (yum-config-manager --add-repo https://developer.download.nvidia.com/devtools/repos/rhel8/x86_64 || true) && \ yum install -y \ nsight-compute-2022.4.0 && \ rm -rf /var/cache/yum/* ENV NV_COMPUTE_PROFILER_DISABLE_STOCK_FILE_DEPLOYMENT=1 \ PATH=/opt/nvidia/nsight-compute/2022.4.0:$PATH''') @x86_64 @ubuntu @docker def test_version(self): """Version option""" n = nsight_compute(version='2020.2.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Compute 2020.2.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/nvidia.gpg && \ wget -qO - https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/nvidia.pub | gpg --dearmor -o /usr/share/keyrings/nvidia.gpg && \ echo "deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/ /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nsight-compute-2020.2.1 && \ rm -rf /var/lib/apt/lists/* ENV NV_COMPUTE_PROFILER_DISABLE_STOCK_FILE_DEPLOYMENT=1 \ PATH=/opt/nvidia/nsight-compute/2020.2.1:$PATH''') @ppc64le @ubuntu18 @docker def test_ppc64le_ubuntu18(self): """Power""" n = nsight_compute(version='2020.2.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Compute 2020.2.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/nvidia.gpg && \ wget -qO - https://developer.download.nvidia.com/devtools/repos/ubuntu1804/ppc64el/nvidia.pub | gpg --dearmor -o /usr/share/keyrings/nvidia.gpg && \ echo "deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/devtools/repos/ubuntu1804/ppc64el/ /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nsight-compute-2020.2.1 && \ rm -rf /var/lib/apt/lists/* ENV NV_COMPUTE_PROFILER_DISABLE_STOCK_FILE_DEPLOYMENT=1 \ PATH=/opt/nvidia/nsight-compute/2020.2.1:$PATH''') @ppc64le @centos @docker def test_ppc64le_centos(self): """Power""" n = nsight_compute(version='2020.2.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Compute 2020.2.1 RUN rpm --import https://developer.download.nvidia.com/devtools/repos/rhel7/ppc64le/nvidia.pub && \ yum install -y yum-utils && \ (yum-config-manager --add-repo https://developer.download.nvidia.com/devtools/repos/rhel7/ppc64le || true) && \ yum install -y \ nsight-compute-2020.2.1 && \ rm -rf /var/cache/yum/* ENV NV_COMPUTE_PROFILER_DISABLE_STOCK_FILE_DEPLOYMENT=1 \ PATH=/opt/nvidia/nsight-compute/2020.2.1:$PATH''') @aarch64 @centos @docker def test_aarch64_centos(self): """Arm""" n = nsight_compute(version='2020.2.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Compute 2020.2.1 RUN rpm --import https://developer.download.nvidia.com/devtools/repos/rhel7/arm64/nvidia.pub && \ yum install -y yum-utils && \ (yum-config-manager --add-repo https://developer.download.nvidia.com/devtools/repos/rhel7/arm64 || true) && \ yum install -y \ nsight-compute-2020.2.1 && \ rm -rf /var/cache/yum/* ENV NV_COMPUTE_PROFILER_DISABLE_STOCK_FILE_DEPLOYMENT=1 \ PATH=/opt/nvidia/nsight-compute/2020.2.1:$PATH''') @x86_64 @ubuntu @docker def test_runfile(self): """Runfile""" n = nsight_compute(eula=True, runfile='nsight_compute-linux-x86_64-2020.2.0.18_28964561.run') self.assertEqual(str(n), r'''# NVIDIA Nsight Compute nsight_compute-linux-x86_64-2020.2.0.18_28964561.run RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ perl \ wget && \ rm -rf /var/lib/apt/lists/* COPY nsight_compute-linux-x86_64-2020.2.0.18_28964561.run /var/tmp/nsight_compute/nsight_compute-linux-x86_64-2020.2.0.18_28964561.run RUN cd /var/tmp/nsight_compute && \ sh ./nsight_compute-linux-x86_64-2020.2.0.18_28964561.run --nox11 -- -noprompt -targetpath=/usr/local/NVIDIA-Nsight-Compute && \ mkdir -p /tmp/var/target && \ ln -sf /usr/local/NVIDIA-Nsight-Compute/target/* /tmp/var/target && \ ln -sf /usr/local/NVIDIA-Nsight-Compute/sections /tmp/var/ && \ chmod -R a+w /tmp/var && \ rm -rf /var/tmp/nsight_compute /var/tmp/nsight_compute/nsight_compute-linux-x86_64-2020.2.0.18_28964561.run ENV PATH=/usr/local/NVIDIA-Nsight-Compute:$PATH ENV NV_COMPUTE_PROFILER_DISABLE_STOCK_FILE_DEPLOYMENT=1''') @x86_64 @ubuntu @docker def test_basic_ubuntu_url(self): """Default nsight_compute building block""" n = nsight_compute(eula=True, runfile='https://foo/bar/nsight_compute-linux-x86_64-2020.2.0.18_28964561.run') self.assertEqual(str(n), r'''# NVIDIA Nsight Compute nsight_compute-linux-x86_64-2020.2.0.18_28964561.run RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ perl \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp/nsight_compute && wget -q -nc --no-check-certificate -P /var/tmp/nsight_compute https://foo/bar/nsight_compute-linux-x86_64-2020.2.0.18_28964561.run && \ cd /var/tmp/nsight_compute && \ sh ./nsight_compute-linux-x86_64-2020.2.0.18_28964561.run --nox11 -- -noprompt -targetpath=/usr/local/NVIDIA-Nsight-Compute && \ mkdir -p /tmp/var/target && \ ln -sf /usr/local/NVIDIA-Nsight-Compute/target/* /tmp/var/target && \ ln -sf /usr/local/NVIDIA-Nsight-Compute/sections /tmp/var/ && \ chmod -R a+w /tmp/var && \ rm -rf /var/tmp/nsight_compute /var/tmp/nsight_compute/nsight_compute-linux-x86_64-2020.2.0.18_28964561.run ENV PATH=/usr/local/NVIDIA-Nsight-Compute:$PATH ENV NV_COMPUTE_PROFILER_DISABLE_STOCK_FILE_DEPLOYMENT=1''')
hpc-container-maker-master
test/test_nsight_compute.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the mvapich2 module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.mvapich2 import mvapich2 from hpccm.toolchain import toolchain class Test_mvapich2(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default mvapich2 building block""" mv2 = mvapich2() self.assertEqual(str(mv2), r'''# MVAPICH2 version 2.3.4 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ byacc \ file \ flex \ make \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.3.4.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mvapich2-2.3.4.tar.gz -C /var/tmp -z && \ cd /var/tmp/mvapich2-2.3.4 && \ ln -s /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/stubs/libnvidia-ml.so.1 && \ ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ cd /var/tmp/mvapich2-2.3.4 && LD_LIBRARY_PATH='/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH' ./configure --prefix=/usr/local/mvapich2 --disable-mcast --enable-cuda --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/mvapich2-2.3.4 /var/tmp/mvapich2-2.3.4.tar.gz ENV LD_LIBRARY_PATH=/usr/local/mvapich2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mvapich2/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml -lcuda"''') @ubuntu @docker def test_pgi_cuda(self): """mvapich2 with pgi and cuda""" tc = toolchain() tc.CC = 'pgcc' tc.CXX = 'pgc++' tc.F77 = 'pgfortran' tc.FC = 'pgfortran' mv2 = mvapich2(toolchain=tc, cuda=True, version='2.3.3') self.assertEqual(str(mv2), r'''# MVAPICH2 version 2.3.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ byacc \ file \ flex \ make \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.3.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mvapich2-2.3.3.tar.gz -C /var/tmp -z && \ cd /var/tmp/mvapich2-2.3.3 && \ ln -s /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/stubs/libnvidia-ml.so.1 && \ ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ cd /var/tmp/mvapich2-2.3.3 && CC=pgcc CFLAGS=-ta=tesla:nordc CPPFLAGS='-D__x86_64 -D__align__\(n\)=__attribute__\(\(aligned\(n\)\)\) -D__location__\(a\)=__annotate__\(a\) -DCUDARTAPI=' CXX=pgc++ F77=pgfortran FC=pgfortran LD_LIBRARY_PATH='/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH' ./configure --prefix=/usr/local/mvapich2 --disable-mcast --enable-cuda=basic --with-cuda=/usr/local/cuda --enable-fast=O1 && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/mvapich2-2.3.3 /var/tmp/mvapich2-2.3.3.tar.gz ENV LD_LIBRARY_PATH=/usr/local/mvapich2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mvapich2/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml -lcuda"''') @ubuntu @docker def test_nvhpc(self): """mvapich2 with NVIDIA HPC SDK""" tc = toolchain() tc.CC = 'nvc' tc.CXX = 'nvc++' tc.F77 = 'nvfortran' tc.FC = 'nvfortran' mv2 = mvapich2(toolchain=tc, cuda=False, version='2.3.3') self.assertEqual(str(mv2), r'''# MVAPICH2 version 2.3.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ byacc \ file \ flex \ make \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.3.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mvapich2-2.3.3.tar.gz -C /var/tmp -z && \ cd /var/tmp/mvapich2-2.3.3 && CC=nvc CFLAGS='-fpic -DPIC' CXX=nvc++ F77=nvfortran FC=nvfortran FCFLAGS='-fpic -DPIC' FFLAGS='-fpic -DPIC' ./configure --prefix=/usr/local/mvapich2 --disable-cuda --disable-mcast ac_cv_c_compiler_gnu=no && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/mvapich2-2.3.3 /var/tmp/mvapich2-2.3.3.tar.gz ENV LD_LIBRARY_PATH=/usr/local/mvapich2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mvapich2/bin:$PATH''') @ubuntu @docker def test_gpu_arch(self): """mvapich2 GPU architecture""" mv2 = mvapich2(version='2.3b', gpu_arch='sm_60') self.assertEqual(str(mv2), r'''# MVAPICH2 version 2.3b RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ byacc \ file \ flex \ make \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.3b.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mvapich2-2.3b.tar.gz -C /var/tmp -z && \ cd /var/tmp/mvapich2-2.3b && \ ln -s /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/stubs/libnvidia-ml.so.1 && \ ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ sed -i -e 's/-arch sm_20/-arch sm_60/g' Makefile.in && \ cd /var/tmp/mvapich2-2.3b && LD_LIBRARY_PATH='/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH' ./configure --prefix=/usr/local/mvapich2 --disable-mcast --enable-cuda --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/mvapich2-2.3b /var/tmp/mvapich2-2.3b.tar.gz ENV LD_LIBRARY_PATH=/usr/local/mvapich2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mvapich2/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml -lcuda"''') @ubuntu @docker def test_nocuda(self): """Disable CUDA""" mv2 = mvapich2(cuda=False, version='2.3.3') self.assertEqual(str(mv2), r'''# MVAPICH2 version 2.3.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ byacc \ file \ flex \ make \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.3.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mvapich2-2.3.3.tar.gz -C /var/tmp -z && \ cd /var/tmp/mvapich2-2.3.3 && ./configure --prefix=/usr/local/mvapich2 --disable-cuda --disable-mcast && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/mvapich2-2.3.3 /var/tmp/mvapich2-2.3.3.tar.gz ENV LD_LIBRARY_PATH=/usr/local/mvapich2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mvapich2/bin:$PATH''') @centos @docker def test_defaults_centos(self): """Default mvapich2 building block""" mv2 = mvapich2() self.assertEqual(str(mv2), r'''# MVAPICH2 version 2.3.4 RUN yum install -y \ byacc \ file \ flex \ make \ openssh-clients \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.3.4.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mvapich2-2.3.4.tar.gz -C /var/tmp -z && \ cd /var/tmp/mvapich2-2.3.4 && \ ln -s /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/stubs/libnvidia-ml.so.1 && \ ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ cd /var/tmp/mvapich2-2.3.4 && LD_LIBRARY_PATH='/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH' ./configure --prefix=/usr/local/mvapich2 --disable-mcast --enable-cuda --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/mvapich2-2.3.4 /var/tmp/mvapich2-2.3.4.tar.gz ENV LD_LIBRARY_PATH=/usr/local/mvapich2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mvapich2/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml -lcuda"''') @ubuntu @docker def test_ldconfig(self): """ldconfig option""" mv2 = mvapich2(ldconfig=True, version='2.3') self.assertEqual(str(mv2), r'''# MVAPICH2 version 2.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ byacc \ file \ flex \ make \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/mvapich2-2.3.tar.gz -C /var/tmp -z && \ cd /var/tmp/mvapich2-2.3 && \ ln -s /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/stubs/libnvidia-ml.so.1 && \ ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ cd /var/tmp/mvapich2-2.3 && LD_LIBRARY_PATH='/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH' ./configure --prefix=/usr/local/mvapich2 --disable-mcast --enable-cuda --with-cuda=/usr/local/cuda && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/mvapich2/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/mvapich2-2.3 /var/tmp/mvapich2-2.3.tar.gz ENV PATH=/usr/local/mvapich2/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml -lcuda"''') @ubuntu @docker def test_runtime(self): """Runtime""" mv2 = mvapich2() r = mv2.runtime() self.assertEqual(r, r'''# MVAPICH2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ openssh-client && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/mvapich2 /usr/local/mvapich2 ENV LD_LIBRARY_PATH=/usr/local/mvapich2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/mvapich2/bin:$PATH''') def test_toolchain(self): """Toolchain""" mv2 = mvapich2() tc = mv2.toolchain self.assertEqual(tc.CC, 'mpicc') self.assertEqual(tc.CXX, 'mpicxx') self.assertEqual(tc.FC, 'mpifort') self.assertEqual(tc.F77, 'mpif77') self.assertEqual(tc.F90, 'mpif90')
hpc-container-maker-master
test/test_mvapich2.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the slurm_pmi2 module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu, x86_64 from hpccm.building_blocks.slurm_pmi2 import slurm_pmi2 class Test_slurm_pmi2(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default slurm_pmi2 building block""" p = slurm_pmi2() self.assertEqual(str(p), r'''# SLURM PMI2 version 21.08.8 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ make \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://download.schedmd.com/slurm/slurm-21.08.8.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/slurm-21.08.8.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/slurm-21.08.8 && ./configure --prefix=/usr/local/slurm-pmi2 && \ cd /var/tmp/slurm-21.08.8 && \ make -C contribs/pmi2 install && \ rm -rf /var/tmp/slurm-21.08.8 /var/tmp/slurm-21.08.8.tar.bz2''') @x86_64 @ubuntu @docker def test_ldconfig(self): """ldconfig option""" p = slurm_pmi2(ldconfig=True, version='20.02.7') self.assertEqual(str(p), r'''# SLURM PMI2 version 20.02.7 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ file \ make \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://download.schedmd.com/slurm/slurm-20.02.7.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/slurm-20.02.7.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/slurm-20.02.7 && ./configure --prefix=/usr/local/slurm-pmi2 && \ cd /var/tmp/slurm-20.02.7 && \ make -C contribs/pmi2 install && \ echo "/usr/local/slurm-pmi2/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/slurm-20.02.7 /var/tmp/slurm-20.02.7.tar.bz2''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" p = slurm_pmi2() r = p.runtime() self.assertEqual(r, r'''# SLURM PMI2 COPY --from=0 /usr/local/slurm-pmi2 /usr/local/slurm-pmi2''')
hpc-container-maker-master
test/test_slurm_pmi2.py
"""This is bad python""" Stage0 += baseimage() # missing parenthesis Stage0 += apt_get(['gcc'] Stage0 += apt_get(['make'])
hpc-container-maker-master
test/bad_recipe.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the mvapich2_gdr module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu, x86_64 from hpccm.building_blocks.mvapich2_gdr import mvapich2_gdr class Test_mvapich2_gdr(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default mvapich2_gdr building block""" mv2 = mvapich2_gdr(cuda_version='9.2', mlnx_ofed_version='4.5', release='2', version='2.3.3') self.assertEqual(str(mv2), r'''# MVAPICH2-GDR version 2.3.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ cpio \ libgfortran3 \ libnuma1 \ libpciaccess0 \ openssh-client \ rpm2cpio \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/gdr/2.3.3/mofed4.5/mvapich2-gdr-mcast.cuda9.2.mofed4.5.gnu4.8.5-2.3.3-2.el7.x86_64.rpm && \ cd / && rpm2cpio /var/tmp/mvapich2-gdr-mcast.cuda9.2.mofed4.5.gnu4.8.5-2.3.3-2.el7.x86_64.rpm | cpio -id && \ (test -f /usr/bin/bash || ln -s /bin/bash /usr/bin/bash) && \ ln -s /usr/local/cuda/lib64/stubs/nvidia-ml.so /usr/local/cuda/lib64/stubs/nvidia-ml.so.1 && \ rm -rf /var/tmp/mvapich2-gdr-mcast.cuda9.2.mofed4.5.gnu4.8.5-2.3.3-2.el7.x86_64.rpm ENV LD_LIBRARY_PATH=/opt/mvapich2/gdr/2.3.3/mcast/no-openacc/cuda9.2/mofed4.5/mpirun/gnu4.8.5/lib64:$LD_LIBRARY_PATH \ PATH=/opt/mvapich2/gdr/2.3.3/mcast/no-openacc/cuda9.2/mofed4.5/mpirun/gnu4.8.5/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml"''') @x86_64 @centos @docker def test_default_centos(self): """Default mvapich2_gdr building block""" mv2 = mvapich2_gdr() self.assertEqual(str(mv2), r'''# MVAPICH2-GDR version 2.3.4 RUN yum install -y \ libgfortran \ libpciaccess \ numactl-libs \ openssh-clients \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/gdr/2.3.4/mofed4.7/mvapich2-gdr-mcast.cuda10.2.mofed4.7.gnu4.8.5-2.3.4-1.el7.x86_64.rpm && \ rpm --install --nodeps /var/tmp/mvapich2-gdr-mcast.cuda10.2.mofed4.7.gnu4.8.5-2.3.4-1.el7.x86_64.rpm && \ (test -f /usr/bin/bash || ln -s /bin/bash /usr/bin/bash) && \ ln -s /usr/local/cuda/lib64/stubs/nvidia-ml.so /usr/local/cuda/lib64/stubs/nvidia-ml.so.1 && \ rm -rf /var/tmp/mvapich2-gdr-mcast.cuda10.2.mofed4.7.gnu4.8.5-2.3.4-1.el7.x86_64.rpm ENV LD_LIBRARY_PATH=/opt/mvapich2/gdr/2.3.4/mcast/no-openacc/cuda10.2/mofed4.7/mpirun/gnu4.8.5/lib64:$LD_LIBRARY_PATH \ PATH=/opt/mvapich2/gdr/2.3.4/mcast/no-openacc/cuda10.2/mofed4.7/mpirun/gnu4.8.5/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml"''') @x86_64 @ubuntu @docker def test_ldconfig(self): """ldconfig option""" mv2 = mvapich2_gdr(cuda_version='9.2', ldconfig=True, mlnx_ofed_version='4.5', release='2', version='2.3.3') self.assertEqual(str(mv2), r'''# MVAPICH2-GDR version 2.3.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ cpio \ libgfortran3 \ libnuma1 \ libpciaccess0 \ openssh-client \ rpm2cpio \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/gdr/2.3.3/mofed4.5/mvapich2-gdr-mcast.cuda9.2.mofed4.5.gnu4.8.5-2.3.3-2.el7.x86_64.rpm && \ cd / && rpm2cpio /var/tmp/mvapich2-gdr-mcast.cuda9.2.mofed4.5.gnu4.8.5-2.3.3-2.el7.x86_64.rpm | cpio -id && \ (test -f /usr/bin/bash || ln -s /bin/bash /usr/bin/bash) && \ ln -s /usr/local/cuda/lib64/stubs/nvidia-ml.so /usr/local/cuda/lib64/stubs/nvidia-ml.so.1 && \ rm -rf /var/tmp/mvapich2-gdr-mcast.cuda9.2.mofed4.5.gnu4.8.5-2.3.3-2.el7.x86_64.rpm && \ echo "/opt/mvapich2/gdr/2.3.3/mcast/no-openacc/cuda9.2/mofed4.5/mpirun/gnu4.8.5/lib64" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig ENV PATH=/opt/mvapich2/gdr/2.3.3/mcast/no-openacc/cuda9.2/mofed4.5/mpirun/gnu4.8.5/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml"''') @x86_64 @ubuntu @docker def test_options(self): """PGI compiler and different Mellanox OFED version""" mv2 = mvapich2_gdr(pgi=True, gnu=False, cuda_version='9.2', mlnx_ofed_version='3.4', pgi_version='17.10', release='1', version='2.3') self.assertEqual(str(mv2), r'''# MVAPICH2-GDR version 2.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ cpio \ libnuma1 \ libpciaccess0 \ openssh-client \ rpm2cpio \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/gdr/2.3/mofed3.4/mvapich2-gdr-mcast.cuda9.2.mofed3.4.pgi17.10-2.3-1.el7.x86_64.rpm && \ cd / && rpm2cpio /var/tmp/mvapich2-gdr-mcast.cuda9.2.mofed3.4.pgi17.10-2.3-1.el7.x86_64.rpm | cpio -id && \ (test -f /usr/bin/bash || ln -s /bin/bash /usr/bin/bash) && \ ln -s /usr/local/cuda/lib64/stubs/nvidia-ml.so /usr/local/cuda/lib64/stubs/nvidia-ml.so.1 && \ rm -rf /var/tmp/mvapich2-gdr-mcast.cuda9.2.mofed3.4.pgi17.10-2.3-1.el7.x86_64.rpm ENV LD_LIBRARY_PATH=/opt/mvapich2/gdr/2.3/mcast/no-openacc/cuda9.2/mofed3.4/mpirun/pgi17.10/lib64:$LD_LIBRARY_PATH \ PATH=/opt/mvapich2/gdr/2.3/mcast/no-openacc/cuda9.2/mofed3.4/mpirun/pgi17.10/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml"''') @x86_64 @ubuntu @docker def test_package(self): """Manually specified download package""" mv2 = mvapich2_gdr(package='mvapich2-gdr-mcast.cuda10.0.mofed4.3.gnu4.8.5-2.3-1.el7.x86_64.rpm') self.assertEqual(str(mv2), r'''# MVAPICH2-GDR version 2.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ cpio \ libgfortran3 \ libnuma1 \ libpciaccess0 \ openssh-client \ rpm2cpio \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mvapich.cse.ohio-state.edu/download/mvapich/gdr/2.3/mofed4.3/mvapich2-gdr-mcast.cuda10.0.mofed4.3.gnu4.8.5-2.3-1.el7.x86_64.rpm && \ cd / && rpm2cpio /var/tmp/mvapich2-gdr-mcast.cuda10.0.mofed4.3.gnu4.8.5-2.3-1.el7.x86_64.rpm | cpio -id && \ (test -f /usr/bin/bash || ln -s /bin/bash /usr/bin/bash) && \ ln -s /usr/local/cuda/lib64/stubs/nvidia-ml.so /usr/local/cuda/lib64/stubs/nvidia-ml.so.1 && \ rm -rf /var/tmp/mvapich2-gdr-mcast.cuda10.0.mofed4.3.gnu4.8.5-2.3-1.el7.x86_64.rpm ENV LD_LIBRARY_PATH=/opt/mvapich2/gdr/2.3/mcast/no-openacc/cuda10.0/mofed4.3/mpirun/gnu4.8.5/lib64:$LD_LIBRARY_PATH \ PATH=/opt/mvapich2/gdr/2.3/mcast/no-openacc/cuda10.0/mofed4.3/mpirun/gnu4.8.5/bin:$PATH \ PROFILE_POSTLIB="-L/usr/local/cuda/lib64/stubs -lnvidia-ml"''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" mv2 = mvapich2_gdr() r = mv2.runtime() self.assertEqual(r, r'''# MVAPICH2-GDR RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libgfortran3 \ libnuma1 \ libpciaccess0 \ openssh-client && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /opt/mvapich2/gdr/2.3.4/mcast/no-openacc/cuda10.2/mofed4.7/mpirun/gnu4.8.5 /opt/mvapich2/gdr/2.3.4/mcast/no-openacc/cuda10.2/mofed4.7/mpirun/gnu4.8.5 ENV LD_LIBRARY_PATH=/opt/mvapich2/gdr/2.3.4/mcast/no-openacc/cuda10.2/mofed4.7/mpirun/gnu4.8.5/lib64:$LD_LIBRARY_PATH \ PATH=/opt/mvapich2/gdr/2.3.4/mcast/no-openacc/cuda10.2/mofed4.7/mpirun/gnu4.8.5/bin:$PATH''') def test_toolchain(self): """Toolchain""" mv2 = mvapich2_gdr() tc = mv2.toolchain self.assertEqual(tc.CC, 'mpicc') self.assertEqual(tc.CXX, 'mpicxx') self.assertEqual(tc.FC, 'mpifort') self.assertEqual(tc.F77, 'mpif77') self.assertEqual(tc.F90, 'mpif90')
hpc-container-maker-master
test/test_mvapich2_gdr.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the raw module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import bash, docker, invalid_ctype, singularity from hpccm.primitives.raw import raw class Test_raw(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @docker def test_empty(self): """No raw strings specified""" r = raw() self.assertEqual(str(r), '') @invalid_ctype def test_invalid_ctype(self): """Invalid container type specified""" r = raw(docker='RAW') with self.assertRaises(RuntimeError): str(r) @docker def test_docker_only_docker(self): """Only Docker string specified""" r = raw(docker='RAW string') self.assertEqual(str(r), 'RAW string') @singularity def test_docker_only_singularity(self): """Only Docker string specified""" r = raw(docker='RAW string') self.assertEqual(str(r), '') @docker def test_singularity_only_docker(self): """Only Singularity string specified""" r = raw(singularity='%raw\n string') self.assertEqual(str(r), '') @singularity def test_singularity_only_singularity(self): """Only Singularity string specified""" r = raw(singularity='%raw\n string') self.assertEqual(str(r), '%raw\n string') @docker def test_all_docker(self): """Both Docker and Singularity strings specified""" r = raw(docker='RAW string', singularity='%raw\n string') self.assertEqual(str(r), 'RAW string') @singularity def test_all_singularity(self): """Both Docker and Singularity strings specified""" r = raw(docker='RAW string', singularity='%raw\n string') self.assertEqual(str(r), '%raw\n string') @bash def test_all_bash(self): """Both Docker and Singularity strings specified""" r = raw(docker='RAW string', singularity='%raw\n string') self.assertEqual(str(r), '')
hpc-container-maker-master
test/test_raw.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the ConfigureMake module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from hpccm.templates.ConfigureMake import ConfigureMake from hpccm.toolchain import toolchain class Test_ConfigureMake(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_defaults(self): """Default values""" cm = ConfigureMake() # configure step configure = cm.configure_step() self.assertEqual(configure, './configure --prefix=/usr/local') # build step build = cm.build_step() self.assertEqual(build, 'make -j$(nproc)') # check step check = cm.check_step() self.assertEqual(check, 'make -j$(nproc) check') # install step install = cm.install_step() self.assertEqual(install, 'make -j$(nproc) install') def test_toolchain(self): """Toolchain specified""" cm = ConfigureMake() tc = toolchain(CC='mycc', CXX='mycxx', FC='myfc', F77='myf77', F90='myf90', CFLAGS='-g -O3', CPPFLAGS='-DFOO -DBAR', CXXFLAGS='-g -O3', FCFLAGS='-g -O3', FFLAGS='-g -O3', FLIBS='-ldl', LD_LIBRARY_PATH='/opt/mysw/lib:/opt/yoursw/lib', LDFLAGS='-Wl,--start-group foo.o bar.o -Wl,--endgroup', LIBS='-ldl -lpthread') configure = cm.configure_step(toolchain=tc) self.assertEqual(configure, '''CC=mycc CFLAGS='-g -O3' CPPFLAGS='-DFOO -DBAR' CXX=mycxx CXXFLAGS='-g -O3' F77=myf77 F90=myf90 FC=myfc FCFLAGS='-g -O3' FFLAGS='-g -O3' FLIBS=-ldl LD_LIBRARY_PATH=/opt/mysw/lib:/opt/yoursw/lib LDFLAGS='-Wl,--start-group foo.o bar.o -Wl,--endgroup' LIBS='-ldl -lpthread' ./configure --prefix=/usr/local''') def test_directory(self): """Source directory specified""" cm = ConfigureMake() configure = cm.configure_step(directory='/tmp/foo') # Note extra whitespace self.assertEqual(configure, 'cd /tmp/foo && ./configure --prefix=/usr/local') def test_build_directory(self): """Build directory specified""" cm = ConfigureMake() configure = cm.configure_step(build_directory='/tmp/build', directory='/tmp/src') # Note extra whitespace self.assertEqual(configure, 'mkdir -p /tmp/build && cd /tmp/build && /tmp/src/configure --prefix=/usr/local') def test_parallel(self): """Parallel count specified""" cm = ConfigureMake(parallel=7) # Function arguments override constructor build = cm.build_step(parallel=11) self.assertEqual(build, 'make -j11') # Use constructor arguments build = cm.build_step() self.assertEqual(build, 'make -j7') def test_prefix(self): """Prefix specified""" cm = ConfigureMake(prefix='/my/prefix') configure = cm.configure_step() self.assertEqual(configure, './configure --prefix=/my/prefix') def test_configure_opts(self): """Configure options specified""" cm = ConfigureMake(opts=['--with-foo', '--without-bar']) # Function arguments override constructor configure = cm.configure_step(opts=['--without-foo', '--with-bar']) self.assertEqual(configure, './configure --prefix=/usr/local --with-bar --without-foo') # Use constructor arguments configure = cm.configure_step() self.assertEqual(configure, './configure --prefix=/usr/local --with-foo --without-bar') def test_kwargs(self): """kwargs""" cm = ConfigureMake(disable_long_option=True, enable_foo=True, with_foo=True, with_foo2='/usr', without_bar=True, prefix=None) configure = cm.configure_step() self.assertEqual(configure, './configure --disable-long-option --enable-foo --with-foo --with-foo2=/usr --without-bar') def test_export_environment(self): """export_environment""" cm = ConfigureMake() tc = toolchain(CC='mpicc', CXX='mpicxx', FC='mpifc') env = ['OMPI_CC=mycc', 'OMPI_CXX=mycxx', 'OMPI_FC=myfc'] configure = cm.configure_step(environment=env, toolchain=tc) self.assertEqual(configure, 'OMPI_CC=mycc OMPI_CXX=mycxx OMPI_FC=myfc CC=mpicc CXX=mpicxx FC=mpifc ./configure --prefix=/usr/local') ex_configure = cm.configure_step(environment=env, export_environment=True, toolchain=tc) self.assertEqual(ex_configure, 'export OMPI_CC=mycc OMPI_CXX=mycxx OMPI_FC=myfc CC=mpicc CXX=mpicxx FC=mpifc && ./configure --prefix=/usr/local')
hpc-container-maker-master
test/test_ConfigureMake.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the pip module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, centos8, docker, ubuntu from hpccm.building_blocks.pip import pip class Test_pip(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default pip building block""" p = pip(packages=['hpccm']) self.assertEqual(str(p), r'''# pip RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python-pip \ python-setuptools \ python-wheel && \ rm -rf /var/lib/apt/lists/* RUN pip --no-cache-dir install hpccm''') @centos @docker def test_defaults_centos(self): """Default pip building block""" p = pip(packages=['hpccm']) self.assertEqual(str(p), r'''# pip RUN yum install -y epel-release && \ yum install -y \ python2-pip && \ rm -rf /var/cache/yum/* RUN pip --no-cache-dir install hpccm''') @centos8 @docker def test_alternatives_centos8(self): """Default pip building block""" p = pip(packages=['hpccm'], alternatives=True) self.assertEqual(str(p), r'''# pip RUN yum install -y \ python2-pip && \ rm -rf /var/cache/yum/* RUN alternatives --set python /usr/bin/python2 && \ alternatives --install /usr/bin/pip pip /usr/bin/pip2 30 RUN pip --no-cache-dir install hpccm''') @ubuntu @docker def test_pip3_ubuntu(self): """pip3 w/ pip building block""" p = pip(packages=['hpccm'], pip='pip3') self.assertEqual(str(p), r'''# pip RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python3-pip \ python3-setuptools \ python3-wheel && \ rm -rf /var/lib/apt/lists/* RUN pip3 --no-cache-dir install hpccm''') @centos @docker def test_pip3_centos(self): """pip3 w/ pip building block""" p = pip(packages=['hpccm'], pip='pip3') self.assertEqual(str(p), r'''# pip RUN yum install -y \ python3-pip && \ rm -rf /var/cache/yum/* RUN pip3 --no-cache-dir install hpccm''') @centos @docker def test_no_args(self): """empty args option""" p = pip(args=[], packages=['hpccm'], pip='pip3') self.assertEqual(str(p), r'''# pip RUN yum install -y \ python3-pip && \ rm -rf /var/cache/yum/* RUN pip3 install hpccm''') @ubuntu @docker def test_no_ospackages(self): """empty ospackages option""" p = pip(ospackages=[], packages=['hpccm']) self.assertEqual(str(p), r'''# pip RUN pip --no-cache-dir install hpccm''') @ubuntu @docker def test_ospackages(self): """specify ospackages option""" p = pip(ospackages=['foo'], packages=['hpccm']) self.assertEqual(str(p), r'''# pip RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ foo && \ rm -rf /var/lib/apt/lists/* RUN pip --no-cache-dir install hpccm''') @ubuntu @docker def test_requirements(self): """specify requirements options""" p = pip(requirements='foo/requirements.txt') self.assertEqual(str(p), r'''# pip RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python-pip \ python-setuptools \ python-wheel && \ rm -rf /var/lib/apt/lists/* COPY foo/requirements.txt /var/tmp/requirements.txt RUN pip --no-cache-dir install -r /var/tmp/requirements.txt && \ rm -rf /var/tmp/requirements.txt''') @ubuntu @docker def test_upgrade(self): """upgrade option""" p = pip(packages=['hpccm'], upgrade=True) self.assertEqual(str(p), r'''# pip RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python-pip \ python-setuptools \ python-wheel && \ rm -rf /var/lib/apt/lists/* RUN pip --no-cache-dir install --upgrade "pip < 21.0" && \ pip --no-cache-dir install hpccm''')
hpc-container-maker-master
test/test_pip.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the pmix module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu, x86_64 from hpccm.building_blocks.pmix import pmix class Test_pmix(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default pmix building block""" p = pmix() self.assertEqual(str(p), r'''# PMIX version 4.1.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ hwloc \ libevent-dev \ make \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openpmix/openpmix/releases/download/v4.1.2/pmix-4.1.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/pmix-4.1.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/pmix-4.1.2 && ./configure --prefix=/usr/local/pmix && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/pmix-4.1.2 /var/tmp/pmix-4.1.2.tar.gz ENV CPATH=/usr/local/pmix/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/pmix/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/pmix/bin:$PATH''') @x86_64 @centos @docker def test_ldconfig(self): """ldconfig option""" p = pmix(ldconfig=True, version='3.1.4') self.assertEqual(str(p), r'''# PMIX version 3.1.4 RUN yum install -y \ file \ hwloc \ libevent-devel \ make \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/openpmix/openpmix/releases/download/v3.1.4/pmix-3.1.4.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/pmix-3.1.4.tar.gz -C /var/tmp -z && \ cd /var/tmp/pmix-3.1.4 && ./configure --prefix=/usr/local/pmix && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/pmix/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/pmix-3.1.4 /var/tmp/pmix-3.1.4.tar.gz ENV CPATH=/usr/local/pmix/include:$CPATH \ PATH=/usr/local/pmix/bin:$PATH''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" p = pmix() r = p.runtime() self.assertEqual(r, r'''# PMIX RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libevent-2.* \ libevent-pthreads-2.* && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/pmix /usr/local/pmix ENV CPATH=/usr/local/pmix/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/pmix/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/pmix/bin:$PATH''')
hpc-container-maker-master
test/test_pmix.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the hpcx module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, centos8, docker, ppc64le, ubuntu, ubuntu18, ubuntu20, ubuntu22, x86_64 from hpccm.building_blocks.hpcx import hpcx class Test_mlnx_ofed(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu18 @docker def test_defaults_ubuntu18(self): """Default hpcx building block""" h = hpcx() self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.16 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libnuma1 \ openssh-client \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.16/hpcx-v2.16-gcc-mlnx_ofed-ubuntu18.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu18.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu18.04-cuda12-gdrcopy2-nccl2.18-x86_64 /usr/local/hpcx && \ echo "source /usr/local/hpcx/hpcx-init-ompi.sh" >> /etc/bash.bashrc && \ echo "hpcx_load" >> /etc/bash.bashrc && \ rm -rf /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu18.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu18.04-cuda12-gdrcopy2-nccl2.18-x86_64''') @x86_64 @ubuntu20 @docker def test_defaults_ubuntu20(self): """Default hpcx building block""" h = hpcx() self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.16 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libnuma1 \ openssh-client \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.16/hpcx-v2.16-gcc-mlnx_ofed-ubuntu20.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu20.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu20.04-cuda12-gdrcopy2-nccl2.18-x86_64 /usr/local/hpcx && \ echo "source /usr/local/hpcx/hpcx-init-ompi.sh" >> /etc/bash.bashrc && \ echo "hpcx_load" >> /etc/bash.bashrc && \ rm -rf /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu20.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu20.04-cuda12-gdrcopy2-nccl2.18-x86_64''') @x86_64 @centos @docker def test_defaults_centos7(self): """Default mlnx_ofed building block""" h = hpcx() self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.16 RUN yum install -y \ bzip2 \ numactl-libs \ openssh-clients \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.16/hpcx-v2.16-gcc-mlnx_ofed-redhat7-cuda12-gdrcopy2-nccl2.18-x86_64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-redhat7-cuda12-gdrcopy2-nccl2.18-x86_64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-redhat7-cuda12-gdrcopy2-nccl2.18-x86_64 /usr/local/hpcx && \ echo "source /usr/local/hpcx/hpcx-init-ompi.sh" >> /etc/bashrc && \ echo "hpcx_load" >> /etc/bashrc && \ rm -rf /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-redhat7-cuda12-gdrcopy2-nccl2.18-x86_64.tbz /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-redhat7-cuda12-gdrcopy2-nccl2.18-x86_64''') @x86_64 @centos8 @docker def test_defaults_centos8(self): """Default mlnx_ofed building block""" h = hpcx() self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.16 RUN yum install -y \ bzip2 \ numactl-libs \ openssh-clients \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.16/hpcx-v2.16-gcc-mlnx_ofed-redhat8-cuda12-gdrcopy2-nccl2.18-x86_64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-redhat8-cuda12-gdrcopy2-nccl2.18-x86_64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-redhat8-cuda12-gdrcopy2-nccl2.18-x86_64 /usr/local/hpcx && \ echo "source /usr/local/hpcx/hpcx-init-ompi.sh" >> /etc/bashrc && \ echo "hpcx_load" >> /etc/bashrc && \ rm -rf /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-redhat8-cuda12-gdrcopy2-nccl2.18-x86_64.tbz /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-redhat8-cuda12-gdrcopy2-nccl2.18-x86_64''') @x86_64 @ubuntu @docker def test_prefix_multi_thread(self): """Prefix and multi_thread options""" h = hpcx(mlnx_ofed='4.7-1.0.0.1', multi_thread=True, prefix='/opt/hpcx', version='2.5.0') self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.5.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libnuma1 \ openssh-client \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.5/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-ubuntu16.04-x86_64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-ubuntu16.04-x86_64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-ubuntu16.04-x86_64 /opt/hpcx && \ echo "source /opt/hpcx/hpcx-mt-init-ompi.sh" >> /etc/bash.bashrc && \ echo "hpcx_load" >> /etc/bash.bashrc && \ rm -rf /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-ubuntu16.04-x86_64.tbz /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-ubuntu16.04-x86_64''') @aarch64 @ubuntu @docker def test_aarch64_ubuntu(self): """aarch64""" h = hpcx(mlnx_ofed='4.5-1.0.1.0', version='2.5.0') self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.5.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libnuma1 \ openssh-client \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.5/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.5-1.0.1.0-ubuntu16.04-aarch64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.5-1.0.1.0-ubuntu16.04-aarch64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.5-1.0.1.0-ubuntu16.04-aarch64 /usr/local/hpcx && \ echo "source /usr/local/hpcx/hpcx-init-ompi.sh" >> /etc/bash.bashrc && \ echo "hpcx_load" >> /etc/bash.bashrc && \ rm -rf /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.5-1.0.1.0-ubuntu16.04-aarch64.tbz /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.5-1.0.1.0-ubuntu16.04-aarch64''') @ppc64le @centos @docker def test_ppc64le_centos(self): """ppc64le""" h = hpcx(mlnx_ofed='4.7-1.0.0.1', version='2.5.0') self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.5.0 RUN yum install -y \ bzip2 \ numactl-libs \ openssh-clients \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.5/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-redhat7.6-ppc64le.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-redhat7.6-ppc64le.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-redhat7.6-ppc64le /usr/local/hpcx && \ echo "source /usr/local/hpcx/hpcx-init-ompi.sh" >> /etc/bashrc && \ echo "hpcx_load" >> /etc/bashrc && \ rm -rf /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-redhat7.6-ppc64le.tbz /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.7-1.0.0.1-redhat7.6-ppc64le''') @x86_64 @ubuntu18 @docker def test_inbox_hpcxinit(self): """inbox and hpcxinit parameters""" h = hpcx(hpcxinit=False, inbox=True, version='2.5.0') self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.5.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libnuma1 \ openssh-client \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.5/hpcx-v2.5.0-gcc-inbox-ubuntu18.04-x86_64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.5.0-gcc-inbox-ubuntu18.04-x86_64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.5.0-gcc-inbox-ubuntu18.04-x86_64 /usr/local/hpcx && \ rm -rf /var/tmp/hpcx-v2.5.0-gcc-inbox-ubuntu18.04-x86_64.tbz /var/tmp/hpcx-v2.5.0-gcc-inbox-ubuntu18.04-x86_64 ENV CPATH=/usr/local/hpcx/hcoll/include:/usr/local/hpcx/ompi/include:/usr/local/hpcx/sharp/include:/usr/local/hpcx/ucx/include:$CPATH \ HPCX_CLUSTERKIT_DIR=/usr/local/hpcx/clusterkit \ HPCX_DIR=/usr/local/hpcx \ HPCX_HCOLL_DIR=/usr/local/hpcx/hcoll \ HPCX_IPM_DIR=/usr/local/hpcx/ompi/tests/ipm-2.0.6 \ HPCX_IPM_LIB=/usr/local/hpcx/ompi/tests/ipm-2.0.6/lib/libipm.so \ HPCX_MPI_DIR=/usr/local/hpcx/ompi \ HPCX_MPI_TESTS_DIR=/usr/local/hpcx/ompi/tests \ HPCX_NCCL_RDMA_SHARP_PLUGIN_DIR=/usr/local/hpcx/nccl_rdma_sharp_plugin \ HPCX_OSHMEM_DIR=/usr/local/hpcx/ompi \ HPCX_OSU_CUDA_DIR=/usr/local/hpcx/ompi/tests/osu-micro-benchmarks-5.3.2-cuda \ HPCX_OSU_DIR=/usr/local/hpcx/ompi/tests/osu-micro-benchmarks-5.3.2 \ HPCX_SHARP_DIR=/usr/local/hpcx/sharp \ HPCX_UCX_DIR=/usr/local/hpcx/ucx \ LD_LIBRARY_PATH=/usr/local/hpcx/hcoll/lib:/usr/local/hpcx/ompi/lib:/usr/local/hpcx/nccl_rdma_sharp_plugin/lib:/usr/local/hpcx/sharp/lib:/usr/local/hpcx/ucx/lib:/usr/local/hpcx/ucx/lib/ucx:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/hpcx/hcoll/lib:/usr/local/hpcx/ompi/lib:/usr/local/hpcx/nccl_rdma_sharp_plugin/lib:/usr/local/hpcx/sharp/lib:/usr/local/hpcx/ucx/lib:$LIBRARY_PATH \ MPI_HOME=/usr/local/hpcx/ompi \ OMPI_HOME=/usr/local/hpcx/ompi \ OPAL_PREFIX=/usr/local/hpcx/ompi \ OSHMEM_HOME=/usr/local/hpcx/ompi \ PATH=/usr/local/hpcx/clusterkit/bin:/usr/local/hpcx/hcoll/bin:/usr/local/hpcx/ompi/bin:/usr/local/hpcx/ucx/bin:$PATH \ PKG_CONFIG_PATH=/usr/local/hpcx/hcoll/lib/pkgconfig:/usr/local/hpcx/ompi/lib/pkgconfig:/usr/local/hpcx/sharp/lib/pkgconfig:/usr/local/hpcx/ucx/lib/pkgconfig:$PKG_CONFIG_PATH \ SHMEM_HOME=/usr/local/hpcx/ompi''') @x86_64 @centos @docker def test_ldconfig_multi_thread(self): """ldconfig and multi_thread parameters""" h = hpcx(hpcxinit=False, ldconfig=True, mlnx_ofed='4.6-1.0.1.1', multi_thread=True, version='2.5.0') self.assertEqual(str(h), r'''# Mellanox HPC-X version 2.5.0 RUN yum install -y \ bzip2 \ numactl-libs \ openssh-clients \ tar \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.5/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.6-1.0.1.1-redhat7.6-x86_64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.6-1.0.1.1-redhat7.6-x86_64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.6-1.0.1.1-redhat7.6-x86_64 /usr/local/hpcx && \ echo "/usr/local/hpcx/hcoll/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ echo "/usr/local/hpcx/ompi/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ echo "/usr/local/hpcx/nccl_rdma_sharp_plugin/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ echo "/usr/local/hpcx/sharp/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ echo "/usr/local/hpcx/ucx/mt/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ echo "/usr/local/hpcx/ucx/mt/lib/ucx" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.6-1.0.1.1-redhat7.6-x86_64.tbz /var/tmp/hpcx-v2.5.0-gcc-MLNX_OFED_LINUX-4.6-1.0.1.1-redhat7.6-x86_64 ENV CPATH=/usr/local/hpcx/hcoll/include:/usr/local/hpcx/ompi/include:/usr/local/hpcx/sharp/include:/usr/local/hpcx/ucx/mt/include:$CPATH \ HPCX_CLUSTERKIT_DIR=/usr/local/hpcx/clusterkit \ HPCX_DIR=/usr/local/hpcx \ HPCX_HCOLL_DIR=/usr/local/hpcx/hcoll \ HPCX_IPM_DIR=/usr/local/hpcx/ompi/tests/ipm-2.0.6 \ HPCX_IPM_LIB=/usr/local/hpcx/ompi/tests/ipm-2.0.6/lib/libipm.so \ HPCX_MPI_DIR=/usr/local/hpcx/ompi \ HPCX_MPI_TESTS_DIR=/usr/local/hpcx/ompi/tests \ HPCX_NCCL_RDMA_SHARP_PLUGIN_DIR=/usr/local/hpcx/nccl_rdma_sharp_plugin \ HPCX_OSHMEM_DIR=/usr/local/hpcx/ompi \ HPCX_OSU_CUDA_DIR=/usr/local/hpcx/ompi/tests/osu-micro-benchmarks-5.3.2-cuda \ HPCX_OSU_DIR=/usr/local/hpcx/ompi/tests/osu-micro-benchmarks-5.3.2 \ HPCX_SHARP_DIR=/usr/local/hpcx/sharp \ HPCX_UCX_DIR=/usr/local/hpcx/ucx/mt \ LIBRARY_PATH=/usr/local/hpcx/hcoll/lib:/usr/local/hpcx/ompi/lib:/usr/local/hpcx/nccl_rdma_sharp_plugin/lib:/usr/local/hpcx/sharp/lib:/usr/local/hpcx/ucx/mt/lib:$LIBRARY_PATH \ MPI_HOME=/usr/local/hpcx/ompi \ OMPI_HOME=/usr/local/hpcx/ompi \ OPAL_PREFIX=/usr/local/hpcx/ompi \ OSHMEM_HOME=/usr/local/hpcx/ompi \ PATH=/usr/local/hpcx/clusterkit/bin:/usr/local/hpcx/hcoll/bin:/usr/local/hpcx/ompi/bin:/usr/local/hpcx/ucx/mt/bin:$PATH \ PKG_CONFIG_PATH=/usr/local/hpcx/hcoll/lib/pkgconfig:/usr/local/hpcx/ompi/lib/pkgconfig:/usr/local/hpcx/sharp/lib/pkgconfig:/usr/local/hpcx/ucx/mt/lib/pkgconfig:$PKG_CONFIG_PATH \ SHMEM_HOME=/usr/local/hpcx/ompi''') @x86_64 @ubuntu22 @docker def test_runtime(self): """Runtime""" h = hpcx() r = h.runtime() self.assertEqual(r, r'''# Mellanox HPC-X version 2.16 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libnuma1 \ openssh-client \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://content.mellanox.com/hpc/hpc-x/v2.16/hpcx-v2.16-gcc-mlnx_ofed-ubuntu22.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu22.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz -C /var/tmp -j && \ cp -a /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu22.04-cuda12-gdrcopy2-nccl2.18-x86_64 /usr/local/hpcx && \ echo "source /usr/local/hpcx/hpcx-init-ompi.sh" >> /etc/bash.bashrc && \ echo "hpcx_load" >> /etc/bash.bashrc && \ rm -rf /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu22.04-cuda12-gdrcopy2-nccl2.18-x86_64.tbz /var/tmp/hpcx-v2.16-gcc-mlnx_ofed-ubuntu22.04-cuda12-gdrcopy2-nccl2.18-x86_64''')
hpc-container-maker-master
test/test_hpcx.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the generic_build module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.generic_build import generic_build from hpccm.toolchain import toolchain class Test_generic_build(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker 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''') @ubuntu @docker def test_no_url(self): """missing url""" with self.assertRaises(RuntimeError): g = generic_build() @ubuntu @docker def test_both_repository_and_url(self): """both repository and url""" with self.assertRaises(RuntimeError): g = generic_build(repository='foo', url='bar') @ubuntu @docker def test_invalid_package(self): """invalid package url""" with self.assertRaises(RuntimeError): g = generic_build(url='https://foo/bar.sh') @ubuntu @docker def test_prefix_recursive(self): """prefix and recursive 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', recursive=True, 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 --recursive 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''') @centos @docker 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''') @centos @docker 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''') @centos @docker 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''') @ubuntu @docker 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''') @ubuntu @docker def test_runtime_manual(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', runtime=['/usr/local/cuda-stream/bin']) 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''')
hpc-container-maker-master
test/test_generic_build.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the building block base class""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.base import bb_base from hpccm.primitives import shell class Test_bb_base(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults(self): """Default building block base class""" b = bb_base() self.assertEqual(str(b), '') @ubuntu @docker def test_instruction_manipulations(self): """Instruction manipulations""" b = bb_base() # Append instructions b += shell(commands=['echo a']) # Append directly to "private" class variable (not recommended) b._bb_instructions__instructions_bb.append(shell(commands=['echo b'])) self.assertEqual(len(b), 2) self.assertEqual(str(b), 'RUN echo a\nRUN echo b') # Direct element access self.assertEqual(str(b[0]), 'RUN echo a') self.assertEqual(str(b[1]), 'RUN echo b') # Iterators i = iter(b) self.assertEqual(str(next(i)), 'RUN echo a') self.assertEqual(str(next(i)), 'RUN echo b') # Insertion, using "private" class variable (not recommended) b._bb_instructions__instructions_bb.insert(0, shell(commands=['echo c'])) self.assertEqual(len(b), 3) self.assertEqual(str(b), 'RUN echo c\nRUN echo a\nRUN echo b') # Deletion (not allowed) with self.assertRaises(TypeError): del(b[1]) # Deletion via "private" class variable (not recommended) del(b._bb_instructions__instructions_bb[1]) self.assertEqual(len(b), 2) self.assertEqual(str(b), 'RUN echo c\nRUN echo b') @ubuntu @docker def test_runtime_instructions(self): """Instruction manipulations""" b = bb_base() # A non-runtime instruction that should not appear b += shell(commands=['echo a']) b.rt += shell(commands=['echo r1']) b.rt += shell(commands=['echo r2']) self.assertEqual(len(b.rt), 2) self.assertEqual(str(b.rt), 'RUN echo r1\nRUN echo r2')
hpc-container-maker-master
test/test_bb_base.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the sensei module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.sensei import sensei from hpccm.toolchain import toolchain class Test_sensei(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default sensei building block""" s = sensei(libsim='/usr/local/visit', vtk='/usr/local/visit/third-party/vtk/6.1.0/linux-x86_64_gcc-5.4/lib/cmake/vtk-6.1') self.assertEqual(str(s), r'''# SENSEI version v2.1.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ git \ make && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v2.1.1 https://gitlab.kitware.com/sensei/sensei.git sensei && cd - && \ mkdir -p /var/tmp/sensei/build && cd /var/tmp/sensei/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/sensei -DENABLE_SENSEI=ON -DENABLE_LIBSIM=ON -DLIBSIM_DIR=/usr/local/visit -DENABLE_PARALLEL3D=OFF -DENABLE_OSCILLATORS=OFF -DVTK_DIR=/usr/local/visit/third-party/vtk/6.1.0/linux-x86_64_gcc-5.4/lib/cmake/vtk-6.1 /var/tmp/sensei && \ cmake --build /var/tmp/sensei/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/sensei/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/sensei''') @centos @docker def test_defaults_centos(self): """Default sensei building block""" s = sensei(catalyst='/usr/local/catalyst') self.assertEqual(str(s), r'''# SENSEI version v2.1.1 RUN yum install -y \ ca-certificates \ git \ make && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v2.1.1 https://gitlab.kitware.com/sensei/sensei.git sensei && cd - && \ mkdir -p /var/tmp/sensei/build && cd /var/tmp/sensei/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/sensei -DENABLE_SENSEI=ON -DENABLE_CATALYST=ON -DParaView_DIR=/usr/local/catalyst -DENABLE_PARALLEL3D=OFF -DENABLE_OSCILLATORS=OFF /var/tmp/sensei && \ cmake --build /var/tmp/sensei/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/sensei/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/sensei''') @ubuntu @docker def test_runtime(self): """Runtime""" s = sensei() r = s.runtime() self.assertEqual(r, r'''# SENSEI COPY --from=0 /usr/local/sensei /usr/local/sensei''')
hpc-container-maker-master
test/test_sensei.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the nsight_systems module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, centos8, docker, ppc64le, ubuntu, ubuntu18, x86_64 from hpccm.building_blocks.nsight_systems import nsight_systems class Test_nsight_systems(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_basic_ubuntu(self): """Default nsight_systems building block""" n = nsight_systems() self.assertEqual(str(n), r'''# NVIDIA Nsight Systems 2022.5.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/nvidia.gpg && \ wget -qO - https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/nvidia.pub | gpg --dearmor -o /usr/share/keyrings/nvidia.gpg && \ echo "deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/ /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nsight-systems-cli-2022.5.1 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @centos8 @docker def test_basic_centos8(self): """Default nsight_systems building block""" n = nsight_systems() self.assertEqual(str(n), r'''# NVIDIA Nsight Systems 2022.5.1 RUN rpm --import https://developer.download.nvidia.com/devtools/repos/rhel8/x86_64/nvidia.pub && \ yum install -y dnf-utils && \ (yum-config-manager --add-repo https://developer.download.nvidia.com/devtools/repos/rhel8/x86_64 || true) && \ yum install -y \ nsight-systems-cli-2022.5.1 && \ rm -rf /var/cache/yum/*''') @x86_64 @ubuntu @docker def test_version(self): """Version option""" n = nsight_systems(version='2020.1.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Systems 2020.1.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/nvidia.gpg && \ wget -qO - https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/nvidia.pub | gpg --dearmor -o /usr/share/keyrings/nvidia.gpg && \ echo "deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/ /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nsight-systems-cli-2020.1.1 && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu @docker def test_cli(self): """cli option""" n = nsight_systems(cli=False, version='2020.1.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Systems 2020.1.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/nvidia.gpg && \ wget -qO - https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/nvidia.pub | gpg --dearmor -o /usr/share/keyrings/nvidia.gpg && \ echo "deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/devtools/repos/ubuntu1604/amd64/ /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nsight-systems-2020.1.1 && \ rm -rf /var/lib/apt/lists/*''') @ppc64le @ubuntu18 @docker def test_ppc64le_ubuntu18(self): """Power""" n = nsight_systems(version='2020.1.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Systems 2020.1.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/nvidia.gpg && \ wget -qO - https://developer.download.nvidia.com/devtools/repos/ubuntu1804/ppc64el/nvidia.pub | gpg --dearmor -o /usr/share/keyrings/nvidia.gpg && \ echo "deb [signed-by=/usr/share/keyrings/nvidia.gpg] https://developer.download.nvidia.com/devtools/repos/ubuntu1804/ppc64el/ /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nsight-systems-cli-2020.1.1 && \ rm -rf /var/lib/apt/lists/*''') @ppc64le @centos @docker def test_ppc64le_centos(self): """Power""" n = nsight_systems(version='2020.1.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Systems 2020.1.1 RUN rpm --import https://developer.download.nvidia.com/devtools/repos/rhel7/ppc64le/nvidia.pub && \ yum install -y yum-utils && \ (yum-config-manager --add-repo https://developer.download.nvidia.com/devtools/repos/rhel7/ppc64le || true) && \ yum install -y \ nsight-systems-cli-2020.1.1 && \ rm -rf /var/cache/yum/*''') @aarch64 @centos @docker def test_aarch64_centos(self): """Power""" n = nsight_systems(version='2020.2.1') self.assertEqual(str(n), r'''# NVIDIA Nsight Systems 2020.2.1 RUN rpm --import https://developer.download.nvidia.com/devtools/repos/rhel7/arm64/nvidia.pub && \ yum install -y yum-utils && \ (yum-config-manager --add-repo https://developer.download.nvidia.com/devtools/repos/rhel7/arm64 || true) && \ yum install -y \ nsight-systems-cli-2020.2.1 && \ rm -rf /var/cache/yum/*''')
hpc-container-maker-master
test/test_nsight_systems.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the config module""" from __future__ import unicode_literals from __future__ import print_function from distutils.version import StrictVersion import logging # pylint: disable=unused-import import unittest from helpers import bash, broadwell, centos, docker, icelake, singularity, thunderx2, ubuntu, zen2 import hpccm.config class Test_config(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @singularity def test_set_container_format_docker(self): """Set container format to Docker""" hpccm.config.set_container_format('docker') self.assertEqual(hpccm.config.g_ctype, hpccm.container_type.DOCKER) @docker def test_set_container_format_singularity(self): """Set container format to Singularity""" hpccm.config.set_container_format('singularity') self.assertEqual(hpccm.config.g_ctype, hpccm.container_type.SINGULARITY) @docker def test_set_container_format_invalid(self): """Set container format to invalid value""" with self.assertRaises(RuntimeError): hpccm.config.set_container_format('invalid') @docker def test_set_linux_distro_ubuntu(self): """Set Linux distribution to Ubuntu""" hpccm.config.set_linux_distro('ubuntu') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) hpccm.config.set_linux_distro('ubuntu16') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) hpccm.config.set_linux_distro('ubuntu18') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('18.04')) @docker def test_set_linux_distro_centos(self): """Set Linux distribution to CentOS""" hpccm.config.set_linux_distro('centos') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) hpccm.config.set_linux_distro('centos7') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) hpccm.config.set_linux_distro('centos8') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('8.0')) @docker def test_set_linux_distro_rhel(self): """Set Linux distribution to RHEL""" hpccm.config.set_linux_distro('rhel') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.RHEL) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) hpccm.config.set_linux_distro('rhel7') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.RHEL) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) hpccm.config.set_linux_distro('rhel8') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.RHEL) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('8.0')) @docker def test_set_linux_distro_rockylinux(self): """Set Linux distribution to Rocky Linux""" hpccm.config.set_linux_distro('rockylinux8') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.ROCKYLINUX) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('8.0')) @docker def test_set_linux_distro_invalid(self): """Set Linux distribution to an invalid value""" hpccm.config.set_linux_distro('invalid') self.assertEqual(hpccm.config.g_linux_distro, hpccm.linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) @singularity def test_set_singularity_version(self): """Set Singularity version""" hpccm.config.set_singularity_version('10.0') self.assertEqual(hpccm.config.g_singularity_version, StrictVersion('10.0')) @docker def test_set_cpu_architecture_aarch64(self): """Set CPU architecture to ARM""" hpccm.config.set_cpu_architecture('aarch64') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.AARCH64) self.assertEqual(hpccm.config.get_cpu_architecture(), 'aarch64') @docker def test_set_cpu_architecture_arm(self): """Set CPU architecture to ARM""" hpccm.config.set_cpu_architecture('arm') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.AARCH64) @docker def test_set_cpu_architecture_arm64v8(self): """Set CPU architecture to ARM""" hpccm.config.set_cpu_architecture('arm64v8') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.AARCH64) @ubuntu @docker def test_set_cpu_architecture_ppc64le_ubuntu(self): """Set CPU architecture to POWER""" hpccm.config.set_cpu_architecture('ppc64le') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.PPC64LE) self.assertEqual(hpccm.config.get_cpu_architecture(), 'ppc64el') @centos @docker def test_set_cpu_architecture_ppc64le_centos(self): """Set CPU architecture to POWER""" hpccm.config.set_cpu_architecture('ppc64le') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.PPC64LE) self.assertEqual(hpccm.config.get_cpu_architecture(), 'ppc64le') @docker def test_set_cpu_architecture_power(self): """Set CPU architecture to POWER""" hpccm.config.set_cpu_architecture('power') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.PPC64LE) @docker def test_set_cpu_architecture_x86_64(self): """Set CPU architecture to x86_64""" hpccm.config.set_cpu_architecture('x86_64') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.X86_64) self.assertEqual(hpccm.config.get_cpu_architecture(), 'x86_64') @docker def test_set_cpu_architecture_amd64(self): """Set CPU architecture to x86_64""" hpccm.config.set_cpu_architecture('amd64') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.X86_64) @docker def test_set_cpu_architecture_x86(self): """Set CPU architecture to x86_64""" hpccm.config.set_cpu_architecture('x86') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.X86_64) @docker def test_set_cpu_architecture_invalid(self): """Set CPU architecture to invalid value""" hpccm.config.set_cpu_architecture('invalid') self.assertEqual(hpccm.config.g_cpu_arch, hpccm.cpu_arch.X86_64) @bash def test_get_format_bash(self): """Get container format""" self.assertEqual(hpccm.config.get_format(), 'bash') @docker def test_get_format_docker(self): """Get container format""" self.assertEqual(hpccm.config.get_format(), 'docker') @singularity def test_get_format_singularity(self): """Get container format""" self.assertEqual(hpccm.config.get_format(), 'singularity') def test_set_working_directory(self): """Set working directory""" # save default value in order to switch back later default_wd = hpccm.config.g_wd hpccm.config.set_working_directory('/a/b') self.assertEqual(hpccm.config.g_wd, '/a/b') # reset to the default working directory hpccm.config.set_working_directory(default_wd) def test_set_cpu_target(self): """Set CPU optimization target""" # save default value in order to switch back later default_cpu_target = hpccm.config.g_cpu_target hpccm.config.set_cpu_target('broadwell') self.assertEqual(hpccm.config.g_cpu_target, 'broadwell') # reset to the default cpu optimization target hpccm.config.set_cpu_target(default_cpu_target) @thunderx2 def test_get_cpu_optimization_flags(self): """Get CPU optimization flags""" flags = hpccm.config.get_cpu_optimization_flags('gcc') self.assertEqual(flags, '-mcpu=thunderx2t99') @icelake def test_get_cpu_optimization_flags_old_compiler(self): """Get CPU optimization flags""" flags = hpccm.config.get_cpu_optimization_flags('gcc', version='4.8.5') self.assertEqual(flags, None) @zen2 def test_test_feature_flag(self): """Test CPU feature flags""" self.assertTrue(hpccm.config.test_cpu_feature_flag('avx2')) self.assertFalse(hpccm.config.test_cpu_feature_flag('foo'))
hpc-container-maker-master
test/test_config.py
from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest import os from helpers import docker, ubuntu from hpccm.common import container_type from hpccm.recipe import recipe class Test_global_vars(unittest.TestCase): def test_global_vars(self): """Global variables""" path = os.path.dirname(__file__) rf = os.path.join(path, 'global_vars_recipe.py') try: recipe(rf, ctype=container_type.SINGULARITY, raise_exceptions=True) except Exception as e: self.fail(e)
hpc-container-maker-master
test/test_global_vars.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the intel_psxe module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import broadwell, centos, docker, ubuntu from hpccm.building_blocks.intel_psxe import intel_psxe class Test_intel_psxe(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults(self): """Default intel_psxe building block, no eula agreement""" with self.assertRaises(RuntimeError): psxe = intel_psxe() str(psxe) @ubuntu @docker def test_license_file(self): """intel_psxe building license file""" psxe = intel_psxe(eula=True, license='XXXXXXXX.lic', tarball='parallel_studio_xe_2018_update1_professional_edition.tgz') self.assertEqual(str(psxe), r'''# Intel Parallel Studio XE RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ build-essential \ cpio && \ rm -rf /var/lib/apt/lists/* COPY parallel_studio_xe_2018_update1_professional_edition.tgz /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz COPY XXXXXXXX.lic /var/tmp/license.lic RUN mkdir -p /var/tmp && tar -x -f /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz -C /var/tmp -z && \ sed -i -e 's/^#\?\(COMPONENTS\)=.*/\1=DEFAULTS/g' \ -e 's|^#\?\(PSET_INSTALL_DIR\)=.*|\1=/opt/intel|g' \ -e 's/^#\?\(ACCEPT_EULA\)=.*/\1=accept/g' \ -e 's/^#\?\(ACTIVATION_TYPE\)=.*/\1=license_file/g' \ -e 's|^#\?\(ACTIVATION_LICENSE_FILE\)=.*|\1=/var/tmp/license.lic|g' /var/tmp/parallel_studio_xe_2018_update1_professional_edition/silent.cfg && \ cd /var/tmp/parallel_studio_xe_2018_update1_professional_edition && ./install.sh --silent=silent.cfg && \ rm -rf /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz /var/tmp/parallel_studio_xe_2018_update1_professional_edition RUN echo "source /opt/intel/compilers_and_libraries/linux/bin/compilervars.sh intel64" >> /etc/bash.bashrc''') @centos @docker def test_centos(self): """centos""" psxe = intel_psxe(eula=True, tarball='parallel_studio_xe_2018_update1_professional_edition.tgz') self.assertEqual(str(psxe), r'''# Intel Parallel Studio XE RUN yum install -y \ gcc \ gcc-c++ \ make \ which && \ rm -rf /var/cache/yum/* COPY parallel_studio_xe_2018_update1_professional_edition.tgz /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz RUN mkdir -p /var/tmp && tar -x -f /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz -C /var/tmp -z && \ sed -i -e 's/^#\?\(COMPONENTS\)=.*/\1=DEFAULTS/g' \ -e 's|^#\?\(PSET_INSTALL_DIR\)=.*|\1=/opt/intel|g' \ -e 's/^#\?\(ACCEPT_EULA\)=.*/\1=accept/g' /var/tmp/parallel_studio_xe_2018_update1_professional_edition/silent.cfg && \ cd /var/tmp/parallel_studio_xe_2018_update1_professional_edition && ./install.sh --silent=silent.cfg && \ rm -rf /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz /var/tmp/parallel_studio_xe_2018_update1_professional_edition RUN echo "source /opt/intel/compilers_and_libraries/linux/bin/compilervars.sh intel64" >> /etc/bashrc''') @ubuntu @docker def test_license_server(self): """intel_psxe building license server""" psxe = intel_psxe(eula=True, license='12345@server-lic', tarball='parallel_studio_xe_2018_update1_professional_edition.tgz') self.assertEqual(str(psxe), r'''# Intel Parallel Studio XE RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ build-essential \ cpio && \ rm -rf /var/lib/apt/lists/* COPY parallel_studio_xe_2018_update1_professional_edition.tgz /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz RUN mkdir -p /var/tmp && tar -x -f /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz -C /var/tmp -z && \ sed -i -e 's/^#\?\(COMPONENTS\)=.*/\1=DEFAULTS/g' \ -e 's|^#\?\(PSET_INSTALL_DIR\)=.*|\1=/opt/intel|g' \ -e 's/^#\?\(ACCEPT_EULA\)=.*/\1=accept/g' \ -e 's/^#\?\(ACTIVATION_TYPE\)=.*/\1=license_server/g' \ -e 's/^#\?\(ACTIVATION_LICENSE_FILE\)=.*/\1=12345@server-lic/g' /var/tmp/parallel_studio_xe_2018_update1_professional_edition/silent.cfg && \ cd /var/tmp/parallel_studio_xe_2018_update1_professional_edition && ./install.sh --silent=silent.cfg && \ rm -rf /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz /var/tmp/parallel_studio_xe_2018_update1_professional_edition RUN echo "source /opt/intel/compilers_and_libraries/linux/bin/compilervars.sh intel64" >> /etc/bash.bashrc''') @ubuntu @docker def test_psxevars_false(self): """psxevars is false""" psxe = intel_psxe(eula=True, psxevars=False, tarball='parallel_studio_xe_2018_update1_professional_edition.tgz') self.assertEqual(str(psxe), r'''# Intel Parallel Studio XE RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ build-essential \ cpio && \ rm -rf /var/lib/apt/lists/* COPY parallel_studio_xe_2018_update1_professional_edition.tgz /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz RUN mkdir -p /var/tmp && tar -x -f /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz -C /var/tmp -z && \ sed -i -e 's/^#\?\(COMPONENTS\)=.*/\1=DEFAULTS/g' \ -e 's|^#\?\(PSET_INSTALL_DIR\)=.*|\1=/opt/intel|g' \ -e 's/^#\?\(ACCEPT_EULA\)=.*/\1=accept/g' /var/tmp/parallel_studio_xe_2018_update1_professional_edition/silent.cfg && \ cd /var/tmp/parallel_studio_xe_2018_update1_professional_edition && ./install.sh --silent=silent.cfg && \ rm -rf /var/tmp/parallel_studio_xe_2018_update1_professional_edition.tgz /var/tmp/parallel_studio_xe_2018_update1_professional_edition ENV CPATH=/opt/intel/compilers_and_libraries/linux/daal/include:/opt/intel/compilers_and_libraries/linux/pstl/include:/opt/intel/compilers_and_libraries/linux/ipp/include:/opt/intel/compilers_and_libraries/linux/mkl/include:/opt/intel/compilers_and_libraries/linux/mpi/include:/opt/intel/compilers_and_libraries/linux/tbb/include:$CPATH \ DAALROOT=/opt/intel/compilers_and_libraries/linux/daal \ IPPROOT=/opt/intel/compilers_and_libraries/linux/ipp \ I_MPI_ROOT=/opt/intel/compilers_and_libraries/linux/mpi \ LD_LIBRARY_PATH=/opt/intel/compilers_and_libraries/linux/daal/lib/intel64:/opt/intel/compilers_and_libraries/linux/compiler/lib/intel64:/opt/intel/compilers_and_libraries/linux/compiler/lib/intel64:/opt/intel/compilers_and_libraries/linux/ipp/lib/intel64:/opt/intel/compilers_and_libraries/linux/mkl/lib/intel64:/opt/intel/compilers_and_libraries/linux/mpi/intel64/lib:/opt/intel/compilers_and_libraries/linux/tbb/lib/intel64/gcc4.7:$LD_LIBRARY_PATH \ LIBRARY_PATH=/opt/intel/compilers_and_libraries/linux/daal/lib/intel64:/opt/intel/compilers_and_libraries/linux/ipp/lib/intel64:/opt/intel/compilers_and_libraries/linux/mkl/lib/intel64:/opt/intel/compilers_and_libraries/linux/tbb/lib/intel64/gcc4.7:$LIBRARY_PATH \ MKLROOT=/opt/intel/compilers_and_libraries/linux/mkl \ PATH=/opt/intel/compilers_and_libraries/linux/bin/intel64:/opt/intel/compilers_and_libraries/linux/bin/intel64:/opt/intel/compilers_and_libraries/linux/mpi/intel64/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" psxe = intel_psxe(eula=True, tarball='parallel_studio_xe_2018_update1_professional_edition.tgz', runtime_version='2018.4-274') r = psxe.runtime() self.assertEqual(r, r'''# Intel Parallel Studio XE runtime version 2018.4-274 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gcc \ gnupg \ man-db \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://apt.repos.intel.com/2018/GPG-PUB-KEY-INTEL-PSXE-RUNTIME-2018 | apt-key add - && \ echo "deb [trusted=yes] https://apt.repos.intel.com/2018 intel-psxe-runtime main" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends aptitude && \ aptitude install -y --without-recommends -o Aptitude::ProblemResolver::SolutionCost='100*canceled-actions,200*removals' \ intel-psxe-runtime=2018.4-274 && \ rm -rf /var/lib/apt/lists/* RUN echo "source /opt/intel/psxe_runtime/linux/bin/psxevars.sh intel64" >> /etc/bash.bashrc''') def test_toolchain(self): """Toolchain""" psxe = intel_psxe(tarball='foo.tgz') tc = psxe.toolchain self.assertEqual(tc.CC, 'icc') self.assertEqual(tc.CXX, 'icpc') self.assertEqual(tc.FC, 'ifort') self.assertEqual(tc.F77, 'ifort') self.assertEqual(tc.F90, 'ifort') @broadwell def test_toolchain_broadwell(self): """CPU arch optimization flags""" psxe = intel_psxe(tarball='foo.tgz') tc = psxe.toolchain self.assertEqual(tc.CFLAGS, '-march=broadwell -mtune=broadwell') self.assertEqual(tc.CXXFLAGS, '-march=broadwell -mtune=broadwell') self.assertEqual(tc.FFLAGS, '-march=broadwell -mtune=broadwell') self.assertEqual(tc.FCFLAGS, '-march=broadwell -mtune=broadwell')
hpc-container-maker-master
test/test_intel_psxe.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the llvm module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, centos8, docker, ppc64le, ubuntu, ubuntu18, ubuntu20, x86_64, zen2 from hpccm.building_blocks.llvm import llvm class Test_llvm(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default llvm building block""" l = llvm() self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang \ libomp-dev && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @centos @docker def test_defaults_centos(self): """Default llvm building block""" l = llvm() self.assertEqual(str(l), r'''# LLVM compiler RUN yum install -y \ gcc \ gcc-c++ && \ rm -rf /var/cache/yum/* RUN yum install -y \ clang && \ rm -rf /var/cache/yum/* ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include:$CPATH''') @x86_64 @centos8 @docker def test_defaults_centos8(self): """Default llvm building block""" l = llvm(version='8') self.assertEqual(str(l), r'''# LLVM compiler RUN yum install -y \ gcc \ gcc-c++ && \ rm -rf /var/cache/yum/* RUN yum install -y \ clang \ libomp \ llvm-libs && \ rm -rf /var/cache/yum/* ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/8/include:$CPATH''') @x86_64 @ubuntu @docker def test_version_ubuntu(self): """LLVM compiler version""" l = llvm(extra_tools=True, version='6.0') self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang-6.0 \ clang-format-6.0 \ clang-tidy-6.0 \ libomp-dev && \ rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/clang clang $(which clang-6.0) 30 && \ update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-6.0) 30 && \ update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-6.0) 30 && \ update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-6.0) 30''') @x86_64 @centos @docker def test_version_centos(self): """LLVM compiler version""" l = llvm(extra_tools=True, version='7') self.assertEqual(str(l), r'''# LLVM compiler RUN yum install -y \ gcc \ gcc-c++ && \ rm -rf /var/cache/yum/* RUN yum install -y centos-release-scl && \ yum install -y \ llvm-toolset-7-clang \ llvm-toolset-7-clang-tools-extra \ llvm-toolset-7-libomp-devel && \ rm -rf /var/cache/yum/* ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include:$CPATH \ LD_LIBRARY_PATH=/opt/rh/llvm-toolset-7/root/usr/lib64:$LD_LIBRARY_PATH \ PATH=/opt/rh/llvm-toolset-7/root/usr/bin:$PATH''') @aarch64 @centos @docker def test_aarch64_centos(self): """aarch64""" l = llvm() self.assertEqual(str(l), r'''# LLVM compiler RUN yum install -y \ gcc \ gcc-c++ && \ rm -rf /var/cache/yum/* RUN yum install -y \ clang && \ rm -rf /var/cache/yum/* ENV COMPILER_PATH=/usr/lib/gcc/aarch64-redhat-linux/4.8.2:$COMPILER_PATH \ CPATH=/usr/include/c++/4.8.2:/usr/include/c++/4.8.2/aarch64-redhat-linux:/usr/lib/gcc/aarch64-redhat-linux/4.8.2/include:$CPATH \ LIBRARY_PATH=/usr/lib/gcc/aarch64-redhat-linux/4.8.2''') @aarch64 @centos8 @docker def test_aarch64_centos8(self): """aarch64""" l = llvm() self.assertEqual(str(l), r'''# LLVM compiler RUN yum install -y \ gcc \ gcc-c++ && \ rm -rf /var/cache/yum/* RUN yum install -y \ clang && \ rm -rf /var/cache/yum/* ENV COMPILER_PATH=/usr/lib/gcc/aarch64-redhat-linux/8:$COMPILER_PATH \ CPATH=/usr/include/c++/8:/usr/include/c++/8/aarch64-redhat-linux:/usr/lib/gcc/aarch64-redhat-linux/8/include:$CPATH \ LIBRARY_PATH=/usr/lib/gcc/aarch64-redhat-linux/8''') @ppc64le @centos @docker def test_ppc64le_centos(self): """ppc64le""" with self.assertRaises(RuntimeError): llvm() @x86_64 @ubuntu @docker def test_openmp_ubuntu(self): """openmp disabled""" l = llvm(openmp=False) self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu @docker def test_extra_tools_ubuntu(self): """clang-format and clang-tidy""" l = llvm(extra_tools=True) self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang \ clang-format \ clang-tidy \ libomp-dev && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @ubuntu @docker def test_toolset8_ubuntu(self): """full toolset""" l = llvm(toolset=True, version='8') self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang-8 \ clang-format-8 \ clang-tidy-8 \ clang-tools-8 \ libc++-8-dev \ libc++1-8 \ libc++abi1-8 \ libclang-8-dev \ libclang1-8 \ liblldb-8-dev \ libomp-8-dev \ lld-8 \ lldb-8 \ llvm-8 \ llvm-8-dev \ llvm-8-runtime && \ rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/clang clang $(which clang-8) 30 && \ update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-8) 30 && \ update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-8) 30 && \ update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-8) 30 && \ update-alternatives --install /usr/bin/lldb lldb $(which lldb-8) 30 && \ update-alternatives --install /usr/bin/llvm-config llvm-config $(which llvm-config-8) 30 && \ update-alternatives --install /usr/bin/llvm-cov llvm-cov $(which llvm-cov-8) 30''') @x86_64 @ubuntu18 @docker def test_toolset_ubuntu18(self): """full toolset""" l = llvm(toolset=True) self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang \ clang-format \ clang-tidy \ libc++-dev \ libc++1 \ libc++abi1 \ libclang-dev \ libclang1 \ libomp-dev \ lldb \ llvm \ llvm-dev \ llvm-runtime && \ rm -rf /var/lib/apt/lists/*''') @x86_64 @centos @docker def test_toolset_centos7(self): """full toolset""" l = llvm(toolset=True) self.assertEqual(str(l), r'''# LLVM compiler RUN yum install -y \ gcc \ gcc-c++ && \ rm -rf /var/cache/yum/* RUN yum install -y \ clang \ llvm && \ rm -rf /var/cache/yum/* ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/4.8.2/include:$CPATH''') @x86_64 @centos8 @docker def test_toolset_centos8(self): """full toolset""" l = llvm(toolset=True) self.assertEqual(str(l), r'''# LLVM compiler RUN yum install -y \ gcc \ gcc-c++ && \ rm -rf /var/cache/yum/* RUN yum install -y \ clang \ clang-tools-extra \ llvm-toolset && \ rm -rf /var/cache/yum/* ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/8/include:$CPATH''') @x86_64 @centos8 @docker def test_extra_tools_centos8(self): """Default llvm building block""" l = llvm(extra_tools=True, version='8') self.assertEqual(str(l), r'''# LLVM compiler RUN yum install -y \ gcc \ gcc-c++ && \ rm -rf /var/cache/yum/* RUN yum install -y \ clang \ clang-tools-extra \ libomp \ llvm-libs && \ rm -rf /var/cache/yum/* ENV CPATH=/usr/lib/gcc/x86_64-redhat-linux/8/include:$CPATH''') @x86_64 @ubuntu @docker def test_upstream_ubuntu16(self): """Upstream builds""" l = llvm(upstream=True, version='10') self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" >> /etc/apt/sources.list.d/hpccm.list && \ echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang-10 \ libomp-10-dev && \ rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/clang clang $(which clang-10) 30 && \ update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-10) 30''') @x86_64 @ubuntu18 @docker def test_upstream_ubuntu18(self): """Upstream builds""" l = llvm(extra_tools=True, upstream=True) self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/hpccm.list && \ echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang-17 \ clang-format-17 \ clang-tidy-17 \ libomp-17-dev && \ rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/clang clang $(which clang-17) 30 && \ update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-17) 30 && \ update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-17) 30 && \ update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-17) 30''') @x86_64 @ubuntu20 @docker def test_upstream_ubuntu20(self): """Upstream builds""" l = llvm(extra_tools=True, upstream=True) self.assertEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" >> /etc/apt/sources.list.d/hpccm.list && \ echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang-17 \ clang-format-17 \ clang-tidy-17 \ libomp-17-dev && \ rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/clang clang $(which clang-17) 30 && \ update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-17) 30 && \ update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-17) 30 && \ update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-17) 30''') @aarch64 @ubuntu @docker def test_upstream_aarch64(self): """Upstream builds for aarch64""" l = llvm(upstream=True, version='11') self.assertMultiLineEqual(str(l), r'''# LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main" >> /etc/apt/sources.list.d/hpccm.list && \ echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang-11 \ libomp-11-dev && \ rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/clang clang $(which clang-11) 30 && \ update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-11) 30''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" l = llvm() r = l.runtime() self.assertEqual(r, r'''# LLVM compiler runtime RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libclang1 \ libomp5 && \ rm -rf /var/lib/apt/lists/*''') def test_toolchain(self): """Toolchain""" l = llvm() tc = l.toolchain self.assertEqual(tc.CC, 'clang') self.assertEqual(tc.CXX, 'clang++') @zen2 def test_toolchain_zen2(self): """CPU arch optimization flags""" l = llvm() tc = l.toolchain self.assertEqual(tc.CFLAGS, '-march=znver2 -mtune=znver2') self.assertEqual(tc.CXXFLAGS, '-march=znver2 -mtune=znver2')
hpc-container-maker-master
test/test_llvm.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the gdrcopy module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.gdrcopy import gdrcopy from hpccm.toolchain import toolchain class Test_gdrcopy(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu_default(self): """Default gdrcopy building block""" g = gdrcopy() self.assertEqual(str(g), r'''# GDRCOPY version 2.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/gdrcopy/archive/v2.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/gdrcopy-2.2 && \ mkdir -p /usr/local/gdrcopy/include /usr/local/gdrcopy/lib && \ make prefix=/usr/local/gdrcopy lib lib_install && \ rm -rf /var/tmp/gdrcopy-2.2 /var/tmp/v2.2.tar.gz ENV CPATH=/usr/local/gdrcopy/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/gdrcopy/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/gdrcopy/lib:$LIBRARY_PATH''') @centos @docker def test_defaults_centos_default(self): """Default gdrcopy building block""" g = gdrcopy() self.assertEqual(str(g), r'''# GDRCOPY version 2.2 RUN yum install -y \ make \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/gdrcopy/archive/v2.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/gdrcopy-2.2 && \ mkdir -p /usr/local/gdrcopy/include /usr/local/gdrcopy/lib && \ make prefix=/usr/local/gdrcopy lib lib_install && \ rm -rf /var/tmp/gdrcopy-2.2 /var/tmp/v2.2.tar.gz ENV CPATH=/usr/local/gdrcopy/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/gdrcopy/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/gdrcopy/lib:$LIBRARY_PATH''') @ubuntu @docker def test_defaults_ubuntu_21(self): """Default gdrcopy building block""" g = gdrcopy(version="2.1") self.assertEqual(str(g), r'''# GDRCOPY version 2.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/gdrcopy/archive/v2.1.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2.1.tar.gz -C /var/tmp -z && \ cd /var/tmp/gdrcopy-2.1 && \ mkdir -p /usr/local/gdrcopy/include /usr/local/gdrcopy/lib64 && \ make PREFIX=/usr/local/gdrcopy lib lib_install && \ rm -rf /var/tmp/gdrcopy-2.1 /var/tmp/v2.1.tar.gz ENV CPATH=/usr/local/gdrcopy/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/gdrcopy/lib64:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/gdrcopy/lib64:$LIBRARY_PATH''') @centos @docker def test_defaults_centos_21(self): """Default gdrcopy building block""" g = gdrcopy(version="2.1") self.assertEqual(str(g), r'''# GDRCOPY version 2.1 RUN yum install -y \ make \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/gdrcopy/archive/v2.1.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2.1.tar.gz -C /var/tmp -z && \ cd /var/tmp/gdrcopy-2.1 && \ mkdir -p /usr/local/gdrcopy/include /usr/local/gdrcopy/lib64 && \ make PREFIX=/usr/local/gdrcopy lib lib_install && \ rm -rf /var/tmp/gdrcopy-2.1 /var/tmp/v2.1.tar.gz ENV CPATH=/usr/local/gdrcopy/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/gdrcopy/lib64:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/gdrcopy/lib64:$LIBRARY_PATH''') @ubuntu @docker def test_ldconfig(self): """ldconfig option""" g = gdrcopy(ldconfig=True, version='1.3') self.assertEqual(str(g), r'''# GDRCOPY version 1.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/gdrcopy/archive/v1.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v1.3.tar.gz -C /var/tmp -z && \ cd /var/tmp/gdrcopy-1.3 && \ mkdir -p /usr/local/gdrcopy/include /usr/local/gdrcopy/lib64 && \ make PREFIX=/usr/local/gdrcopy lib lib_install && \ echo "/usr/local/gdrcopy/lib64" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/gdrcopy-1.3 /var/tmp/v1.3.tar.gz ENV CPATH=/usr/local/gdrcopy/include:$CPATH \ LIBRARY_PATH=/usr/local/gdrcopy/lib64:$LIBRARY_PATH''') @ubuntu @docker def test_toolchain_21(self): """Toolchain""" tc = toolchain(CC='gcc', CFLAGS='-O2') g = gdrcopy(toolchain=tc, version='2.1') self.assertEqual(str(g), r'''# GDRCOPY version 2.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/gdrcopy/archive/v2.1.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2.1.tar.gz -C /var/tmp -z && \ cd /var/tmp/gdrcopy-2.1 && \ mkdir -p /usr/local/gdrcopy/include /usr/local/gdrcopy/lib64 && \ make CC=gcc COMMONCFLAGS=-O2 PREFIX=/usr/local/gdrcopy lib lib_install && \ rm -rf /var/tmp/gdrcopy-2.1 /var/tmp/v2.1.tar.gz ENV CPATH=/usr/local/gdrcopy/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/gdrcopy/lib64:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/gdrcopy/lib64:$LIBRARY_PATH''') @ubuntu @docker def test_toolchain_default(self): """Toolchain""" tc = toolchain(CC='gcc', CFLAGS='-O2') g = gdrcopy(toolchain=tc) self.assertEqual(str(g), r'''# GDRCOPY version 2.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/NVIDIA/gdrcopy/archive/v2.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/gdrcopy-2.2 && \ mkdir -p /usr/local/gdrcopy/include /usr/local/gdrcopy/lib && \ make CC=gcc COMMONCFLAGS=-O2 prefix=/usr/local/gdrcopy lib lib_install && \ rm -rf /var/tmp/gdrcopy-2.2 /var/tmp/v2.2.tar.gz ENV CPATH=/usr/local/gdrcopy/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/gdrcopy/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/gdrcopy/lib:$LIBRARY_PATH''') @ubuntu @docker def test_runtime_default(self): """Runtime""" g = gdrcopy() r = g.runtime() self.assertEqual(r, r'''# GDRCOPY COPY --from=0 /usr/local/gdrcopy /usr/local/gdrcopy ENV CPATH=/usr/local/gdrcopy/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/gdrcopy/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/gdrcopy/lib:$LIBRARY_PATH''')
hpc-container-maker-master
test/test_gdrcopy.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the AMGX module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.amgx import amgx from hpccm.toolchain import toolchain class Test_sensei(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_branch_ubuntu(self): """Default amgx building block""" m = amgx(branch='v2.1.0') self.assertEqual(str(m), r'''# AMGX branch v2.1.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ git \ make && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v2.1.0 https://github.com/NVIDIA/amgx amgx && cd - && \ mkdir -p /var/tmp/amgx/build && cd /var/tmp/amgx/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/amgx /var/tmp/amgx && \ cmake --build /var/tmp/amgx/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/amgx/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/amgx ENV CPATH=/usr/local/amgx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/amgx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/amgx/lib:$LIBRARY_PATH''') @centos @docker def test_branch_centos(self): """Default amgx building block""" m = amgx(branch='v2.1.0') self.assertEqual(str(m), r'''# AMGX branch v2.1.0 RUN yum install -y \ git \ make && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v2.1.0 https://github.com/NVIDIA/amgx amgx && cd - && \ mkdir -p /var/tmp/amgx/build && cd /var/tmp/amgx/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/amgx /var/tmp/amgx && \ cmake --build /var/tmp/amgx/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/amgx/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/amgx ENV CPATH=/usr/local/amgx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/amgx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/amgx/lib:$LIBRARY_PATH''') @ubuntu @docker def test_defaults_ubuntu(self): """Default amgx building block""" m = amgx() self.assertEqual(str(m), r'''# AMGX branch master RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ git \ make && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch master https://github.com/NVIDIA/amgx amgx && cd - && \ mkdir -p /var/tmp/amgx/build && cd /var/tmp/amgx/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/amgx /var/tmp/amgx && \ cmake --build /var/tmp/amgx/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/amgx/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/amgx ENV CPATH=/usr/local/amgx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/amgx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/amgx/lib:$LIBRARY_PATH''') @centos @docker def test_defaults_centos(self): """Default amgx building block""" m = amgx() self.assertEqual(str(m), r'''# AMGX branch master RUN yum install -y \ git \ make && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch master https://github.com/NVIDIA/amgx amgx && cd - && \ mkdir -p /var/tmp/amgx/build && cd /var/tmp/amgx/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/amgx /var/tmp/amgx && \ cmake --build /var/tmp/amgx/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/amgx/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/amgx ENV CPATH=/usr/local/amgx/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/amgx/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/amgx/lib:$LIBRARY_PATH''')
hpc-container-maker-master
test/test_amgx.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the pnetcdf module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.pnetcdf import pnetcdf class Test_pnetcdf(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults(self): """Default pnetcdf building block""" p = pnetcdf() self.assertEqual(str(p), r'''# PnetCDF version 1.12.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ m4 \ make \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://parallel-netcdf.github.io/Release/pnetcdf-1.12.1.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/pnetcdf-1.12.1.tar.gz -C /var/tmp -z && \ cd /var/tmp/pnetcdf-1.12.1 && CC=mpicc CXX=mpicxx F77=mpif77 F90=mpif90 FC=mpifort ./configure --prefix=/usr/local/pnetcdf --enable-shared && \ cd /var/tmp/pnetcdf-1.12.1 && \ sed -i -e 's#pic_flag=""#pic_flag=" -fpic -DPIC"#' -e 's#wl=""#wl="-Wl,"#' libtool && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/pnetcdf-1.12.1 /var/tmp/pnetcdf-1.12.1.tar.gz ENV CPATH=/usr/local/pnetcdf/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/pnetcdf/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/pnetcdf/lib:$LIBRARY_PATH \ PATH=/usr/local/pnetcdf/bin:$PATH''') @ubuntu @docker def test_ldconfig(self): """ldconfig option""" p = pnetcdf(ldconfig=True, version='1.10.0') self.assertEqual(str(p), r'''# PnetCDF version 1.10.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ m4 \ make \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://parallel-netcdf.github.io/Release/parallel-netcdf-1.10.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/parallel-netcdf-1.10.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/parallel-netcdf-1.10.0 && CC=mpicc CXX=mpicxx F77=mpif77 F90=mpif90 FC=mpifort ./configure --prefix=/usr/local/pnetcdf --enable-shared && \ cd /var/tmp/parallel-netcdf-1.10.0 && \ sed -i -e 's#pic_flag=""#pic_flag=" -fpic -DPIC"#' -e 's#wl=""#wl="-Wl,"#' libtool && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/pnetcdf/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/parallel-netcdf-1.10.0 /var/tmp/parallel-netcdf-1.10.0.tar.gz ENV CPATH=/usr/local/pnetcdf/include:$CPATH \ LIBRARY_PATH=/usr/local/pnetcdf/lib:$LIBRARY_PATH \ PATH=/usr/local/pnetcdf/bin:$PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" p = pnetcdf() r = p.runtime() self.assertEqual(r, r'''# PnetCDF RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libatomic1 && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/pnetcdf /usr/local/pnetcdf ENV CPATH=/usr/local/pnetcdf/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/pnetcdf/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/pnetcdf/lib:$LIBRARY_PATH \ PATH=/usr/local/pnetcdf/bin:$PATH''')
hpc-container-maker-master
test/test_pnetcdf.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the conda module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ppc64le, ubuntu, x86_64 from hpccm.building_blocks.conda import conda class Test_conda(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default conda building block""" c = conda(eula=True, packages=['numpy']) self.assertEqual(str(c), r'''# Anaconda RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://repo.anaconda.com/miniconda/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh && \ bash /var/tmp/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh -b -p /usr/local/anaconda && \ /usr/local/anaconda/bin/conda init && \ ln -s /usr/local/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ . /usr/local/anaconda/etc/profile.d/conda.sh && \ conda activate base && \ conda install -y numpy && \ /usr/local/anaconda/bin/conda clean -afy && \ rm -rf /var/tmp/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh''') @x86_64 @centos @docker def test_defaults_centos(self): """Default conda building block""" c = conda(eula=True, packages=['numpy']) self.assertEqual(str(c), r'''# Anaconda RUN yum install -y \ ca-certificates \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://repo.anaconda.com/miniconda/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh && \ bash /var/tmp/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh -b -p /usr/local/anaconda && \ /usr/local/anaconda/bin/conda init && \ ln -s /usr/local/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ . /usr/local/anaconda/etc/profile.d/conda.sh && \ conda activate base && \ conda install -y numpy && \ /usr/local/anaconda/bin/conda clean -afy && \ rm -rf /var/tmp/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh''') @ppc64le @ubuntu @docker def test_ppc64le(self): """ppc64le""" c = conda(eula=True, version='4.7.12') self.assertEqual(str(c), r'''# Anaconda RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://repo.anaconda.com/miniconda/Miniconda3-4.7.12-Linux-ppc64le.sh && \ bash /var/tmp/Miniconda3-4.7.12-Linux-ppc64le.sh -b -p /usr/local/anaconda && \ /usr/local/anaconda/bin/conda init && \ ln -s /usr/local/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ /usr/local/anaconda/bin/conda clean -afy && \ rm -rf /var/tmp/Miniconda3-4.7.12-Linux-ppc64le.sh''') @x86_64 @ubuntu @docker def test_channels(self): """channels""" c = conda(channels=['conda-forge', 'nvidia'], eula=True, version='4.7.12') self.assertEqual(str(c), r'''# Anaconda RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://repo.anaconda.com/miniconda/Miniconda3-4.7.12-Linux-x86_64.sh && \ bash /var/tmp/Miniconda3-4.7.12-Linux-x86_64.sh -b -p /usr/local/anaconda && \ /usr/local/anaconda/bin/conda init && \ ln -s /usr/local/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ . /usr/local/anaconda/etc/profile.d/conda.sh && \ conda activate base && \ conda config --add channels conda-forge --add channels nvidia && \ /usr/local/anaconda/bin/conda clean -afy && \ rm -rf /var/tmp/Miniconda3-4.7.12-Linux-x86_64.sh''') @x86_64 @ubuntu @docker def test_environment(self): """environment""" c = conda(eula=True, environment='foo/environment.yml', version='4.7.12') self.assertEqual(str(c), r'''# Anaconda RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ wget && \ rm -rf /var/lib/apt/lists/* COPY foo/environment.yml /var/tmp/environment.yml RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://repo.anaconda.com/miniconda/Miniconda3-4.7.12-Linux-x86_64.sh && \ bash /var/tmp/Miniconda3-4.7.12-Linux-x86_64.sh -b -p /usr/local/anaconda && \ /usr/local/anaconda/bin/conda init && \ ln -s /usr/local/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ . /usr/local/anaconda/etc/profile.d/conda.sh && \ conda activate base && \ conda env update -f /var/tmp/environment.yml && \ rm -rf /var/tmp/environment.yml && \ /usr/local/anaconda/bin/conda clean -afy && \ rm -rf /var/tmp/Miniconda3-4.7.12-Linux-x86_64.sh''') @x86_64 @ubuntu @docker def test_python2(self): """python 2""" c = conda(eula=True, python2=True, version='4.7.12') self.assertEqual(str(c), r'''# Anaconda RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://repo.anaconda.com/miniconda/Miniconda2-4.7.12-Linux-x86_64.sh && \ bash /var/tmp/Miniconda2-4.7.12-Linux-x86_64.sh -b -p /usr/local/anaconda && \ /usr/local/anaconda/bin/conda init && \ ln -s /usr/local/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ /usr/local/anaconda/bin/conda clean -afy && \ rm -rf /var/tmp/Miniconda2-4.7.12-Linux-x86_64.sh''') @x86_64 @ubuntu @docker def test_python_subversion(self): """python subversion""" c = conda(eula=True, python_subversion='py37', version='4.8.3') self.assertEqual(str(c), r'''# Anaconda RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Linux-x86_64.sh && \ bash /var/tmp/Miniconda3-py37_4.8.3-Linux-x86_64.sh -b -p /usr/local/anaconda && \ /usr/local/anaconda/bin/conda init && \ ln -s /usr/local/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ /usr/local/anaconda/bin/conda clean -afy && \ rm -rf /var/tmp/Miniconda3-py37_4.8.3-Linux-x86_64.sh''') @x86_64 @ubuntu @docker def test_runtime(self): """runtime""" c = conda(eula=True) r = c.runtime() self.assertEqual(r, r'''# Anaconda COPY --from=0 /usr/local/anaconda /usr/local/anaconda RUN /usr/local/anaconda/bin/conda init && \ ln -s /usr/local/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh''')
hpc-container-maker-master
test/test_conda.py
Stage0 += baseimage(image='ubuntu:16.04')
hpc-container-maker-master
test/include1.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the nvshmem module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.nvshmem import nvshmem class Test_nvshmem(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """nvshmem defaults""" n = nvshmem() self.assertEqual(str(n), r'''# NVSHMEM 2.2.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://developer.download.nvidia.com/compute/redist/nvshmem/2.2.1/source/nvshmem_src_2.2.1-0.txz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/nvshmem_src_2.2.1-0.txz -C /var/tmp -J && \ cd /var/tmp/nvshmem_src_2.2.1-0 && \ CUDA_HOME=/usr/local/cuda NVSHMEM_MPI_SUPPORT=0 NVSHMEM_PREFIX=/usr/local/nvshmem make -j$(nproc) install && \ rm -rf /var/tmp/nvshmem_src_2.2.1-0 /var/tmp/nvshmem_src_2.2.1-0.txz ENV CPATH=/usr/local/nvshmem/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nvshmem/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nvshmem/lib:$LIBRARY_PATH \ PATH=/usr/local/nvshmem/bin:$PATH''') @ubuntu @docker def test_binary_tarball_ubuntu(self): """nvshmem binary tarball""" n = nvshmem(binary_tarball='nvshmem_0.4.1-0+cuda10_x86_64.txz') self.assertEqual(str(n), r'''# NVSHMEM RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* COPY nvshmem_0.4.1-0+cuda10_x86_64.txz /var/tmp/nvshmem_0.4.1-0+cuda10_x86_64.txz RUN mkdir -p /usr/local/nvshmem && tar -x -f /var/tmp/nvshmem_0.4.1-0+cuda10_x86_64.txz -C /usr/local/nvshmem -J --strip-components=1 && \ rm -rf /var/tmp/nvshmem_0.4.1-0+cuda10_x86_64.txz ENV CPATH=/usr/local/nvshmem/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nvshmem/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nvshmem/lib:$LIBRARY_PATH \ PATH=/usr/local/nvshmem/bin:$PATH''') @centos @docker def test_binary_tarball_centos(self): """nvshmem binary tarball""" n = nvshmem(binary_tarball='nvshmem_0.4.1-0+cuda10_x86_64.txz') self.assertEqual(str(n), r'''# NVSHMEM RUN yum install -y \ make \ wget && \ rm -rf /var/cache/yum/* COPY nvshmem_0.4.1-0+cuda10_x86_64.txz /var/tmp/nvshmem_0.4.1-0+cuda10_x86_64.txz RUN mkdir -p /usr/local/nvshmem && tar -x -f /var/tmp/nvshmem_0.4.1-0+cuda10_x86_64.txz -C /usr/local/nvshmem -J --strip-components=1 && \ rm -rf /var/tmp/nvshmem_0.4.1-0+cuda10_x86_64.txz ENV CPATH=/usr/local/nvshmem/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nvshmem/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nvshmem/lib:$LIBRARY_PATH \ PATH=/usr/local/nvshmem/bin:$PATH''') @ubuntu @docker def test_package_ubuntu(self): """nvshmem source package""" n = nvshmem(package='nvshmem_src_2.1.2-0.txz') self.assertEqual(str(n), r'''# NVSHMEM RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* COPY nvshmem_src_2.1.2-0.txz /var/tmp/nvshmem_src_2.1.2-0.txz RUN mkdir -p /var/tmp && tar -x -f /var/tmp/nvshmem_src_2.1.2-0.txz -C /var/tmp -J && \ cd /var/tmp/nvshmem_src_2.1.2-0 && \ CUDA_HOME=/usr/local/cuda NVSHMEM_MPI_SUPPORT=0 NVSHMEM_PREFIX=/usr/local/nvshmem make -j$(nproc) install && \ rm -rf /var/tmp/nvshmem_src_2.1.2-0 /var/tmp/nvshmem_src_2.1.2-0.txz ENV CPATH=/usr/local/nvshmem/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nvshmem/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nvshmem/lib:$LIBRARY_PATH \ PATH=/usr/local/nvshmem/bin:$PATH''') @centos @docker def test_package_options_centos(self): """nvshmem source package with all options""" n = nvshmem(gdrcopy='/usr/local/gdrcopy', hydra=True, make_variables={ 'NVCC_GENCODE': '-gencode=arch=compute_70,code=sm_70', 'NVSHMEM_VERBOSE': 1}, mpi='/usr/local/openmpi', package='nvshmem_src_2.1.2-0.txz', shmem='/usr/local/openmpi') self.assertEqual(str(n), r'''# NVSHMEM RUN yum install -y \ automake \ make \ wget && \ rm -rf /var/cache/yum/* COPY nvshmem_src_2.1.2-0.txz /var/tmp/nvshmem_src_2.1.2-0.txz RUN mkdir -p /var/tmp && tar -x -f /var/tmp/nvshmem_src_2.1.2-0.txz -C /var/tmp -J && \ cd /var/tmp/nvshmem_src_2.1.2-0 && \ CUDA_HOME=/usr/local/cuda GDRCOPY_HOME=/usr/local/gdrcopy MPI_HOME=/usr/local/openmpi NVCC_GENCODE=-gencode=arch=compute_70,code=sm_70 NVSHMEM_MPI_SUPPORT=1 NVSHMEM_PREFIX=/usr/local/nvshmem NVSHMEM_SHMEM_SUPPORT=1 NVSHMEM_VERBOSE=1 SHMEM_HOME=/usr/local/openmpi make -j$(nproc) install && \ ./scripts/install_hydra.sh /var/tmp /usr/local/nvshmem && \ rm -rf /var/tmp/nvshmem_src_2.1.2-0 /var/tmp/nvshmem_src_2.1.2-0.txz ENV CPATH=/usr/local/nvshmem/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nvshmem/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nvshmem/lib:$LIBRARY_PATH \ PATH=/usr/local/nvshmem/bin:$PATH''') @ubuntu @docker def test_binary_runtime(self): """Runtime""" n = nvshmem(binary_tarball='nvshmem_0.4.1-0+cuda10_x86_64.txz') r = n.runtime() self.assertEqual(r, r'''# NVSHMEM COPY --from=0 /usr/local/nvshmem /usr/local/nvshmem ENV CPATH=/usr/local/nvshmem/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nvshmem/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nvshmem/lib:$LIBRARY_PATH \ PATH=/usr/local/nvshmem/bin:$PATH''') @ubuntu @docker def test_source_runtime(self): """Runtime""" n = nvshmem(package='nvshmem_src_2.1.2-0.txz') r = n.runtime() self.assertEqual(r, r'''# NVSHMEM COPY --from=0 /usr/local/nvshmem /usr/local/nvshmem ENV CPATH=/usr/local/nvshmem/include:$CPATH \ LD_LIBRARY_PATH=/usr/local/nvshmem/lib:$LD_LIBRARY_PATH \ LIBRARY_PATH=/usr/local/nvshmem/lib:$LIBRARY_PATH \ PATH=/usr/local/nvshmem/bin:$PATH''')
hpc-container-maker-master
test/test_nvshmem.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the wget module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from hpccm.templates.wget import wget class Test_wget(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_missing_url(self): """Missing url option""" w = wget() self.assertEqual(w.download_step(), '') def test_basic(self): """Basic wget""" w = wget() self.assertEqual(w.download_step(url='http://mysite.com/foo.tgz'), 'mkdir -p /tmp && wget -q -nc --no-check-certificate -P /tmp http://mysite.com/foo.tgz') def test_referer(self): """wget with referer""" w = wget() self.assertEqual(w.download_step(url='http://mysite.com/foo.tgz', referer='http://mysite.com/foo.html'), 'mkdir -p /tmp && wget -q -nc --no-check-certificate --referer http://mysite.com/foo.html -P /tmp http://mysite.com/foo.tgz') def test_directory(self): """wget with non-default output directory""" w = wget() self.assertEqual(w.download_step(url='http://mysite.com/foo.tgz', directory='/scratch'), 'mkdir -p /scratch && wget -q -nc --no-check-certificate -P /scratch http://mysite.com/foo.tgz') def test_outfile(self): """wget with non-default output file""" w = wget() self.assertEqual(w.download_step(url='http://mysite.com/foo.tgz', outfile='bar.tgz'), 'mkdir -p /tmp && wget -q -nc --no-check-certificate -O bar.tgz -P /tmp http://mysite.com/foo.tgz') def test_opts(self): """wget with non-default command line options""" w = wget(opts=['-fast']) self.assertEqual(w.download_step(url='http://mysite.com/foo.tgz'), 'mkdir -p /tmp && wget -fast -P /tmp http://mysite.com/foo.tgz')
hpc-container-maker-master
test/test_wget.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the cmake module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, docker, ubuntu, x86_64 from hpccm.building_blocks.cmake import cmake class Test_cmake(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default cmake building block""" c = cmake() self.assertEqual(str(c), r'''# CMake version 3.25.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-x86_64.sh && \ mkdir -p /usr/local && \ /bin/sh /var/tmp/cmake-3.25.1-linux-x86_64.sh --prefix=/usr/local && \ rm -rf /var/tmp/cmake-3.25.1-linux-x86_64.sh ENV PATH=/usr/local/bin:$PATH''') @x86_64 @centos @docker def test_defaults_centos(self): """Default cmake building block""" c = cmake() self.assertEqual(str(c), r'''# CMake version 3.25.1 RUN yum install -y \ make \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-x86_64.sh && \ mkdir -p /usr/local && \ /bin/sh /var/tmp/cmake-3.25.1-linux-x86_64.sh --prefix=/usr/local && \ rm -rf /var/tmp/cmake-3.25.1-linux-x86_64.sh ENV PATH=/usr/local/bin:$PATH''') @x86_64 @ubuntu @docker def test_runfile_name(self): """3.20 runfile naming""" c = cmake(version='3.20.0') self.assertEqual(str(c), r'''# CMake version 3.20.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-x86_64.sh && \ mkdir -p /usr/local && \ /bin/sh /var/tmp/cmake-3.20.0-linux-x86_64.sh --prefix=/usr/local && \ rm -rf /var/tmp/cmake-3.20.0-linux-x86_64.sh ENV PATH=/usr/local/bin:$PATH''') @x86_64 @ubuntu @docker def test_eula(self): """Accept EULA""" c = cmake(eula=True, version='3.16.3') self.assertEqual(str(c), r'''# CMake version 3.16.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.16.3/cmake-3.16.3-Linux-x86_64.sh && \ mkdir -p /usr/local && \ /bin/sh /var/tmp/cmake-3.16.3-Linux-x86_64.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.16.3-Linux-x86_64.sh ENV PATH=/usr/local/bin:$PATH''') @x86_64 @ubuntu @docker def test_version(self): """Version option""" c = cmake(eula=True, version='3.10.3') self.assertEqual(str(c), r'''# CMake version 3.10.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.10.3/cmake-3.10.3-Linux-x86_64.sh && \ mkdir -p /usr/local && \ /bin/sh /var/tmp/cmake-3.10.3-Linux-x86_64.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.10.3-Linux-x86_64.sh ENV PATH=/usr/local/bin:$PATH''') @x86_64 @ubuntu @docker def test_32bit_ubuntu(self): """Cmake building block for old 32-bit versions""" c = cmake(eula=True, version='3.0.0') self.assertEqual(str(c), r'''# CMake version 3.0.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libc6-i386 \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.0.0/cmake-3.0.0-Linux-i386.sh && \ mkdir -p /usr/local && \ /bin/sh /var/tmp/cmake-3.0.0-Linux-i386.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.0.0-Linux-i386.sh ENV PATH=/usr/local/bin:$PATH''') @x86_64 @centos @docker def test_32bit_centos(self): """Cmake building block for old 32-bit versions""" c = cmake(eula=True, version='3.0.0') self.assertEqual(str(c), r'''# CMake version 3.0.0 RUN yum install -y \ glibc.i686 \ make \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.0.0/cmake-3.0.0-Linux-i386.sh && \ mkdir -p /usr/local && \ /bin/sh /var/tmp/cmake-3.0.0-Linux-i386.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.0.0-Linux-i386.sh ENV PATH=/usr/local/bin:$PATH''') @x86_64 @centos @docker def test_source(self): """Source option""" c = cmake(eula=True, source=True, version='3.14.5') self.assertEqual(str(c), r'''# CMake version 3.14.5 RUN yum install -y \ make \ openssl-devel \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.14.5/cmake-3.14.5.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/cmake-3.14.5.tar.gz -C /var/tmp -z && \ cd /var/tmp/cmake-3.14.5 && ./bootstrap --prefix=/usr/local --parallel=$(nproc) && \ make -j$(nproc) && \ make install && \ rm -rf /var/tmp/cmake-3.14.5.tar.gz /var/tmp/cmake-3.14.5 ENV PATH=/usr/local/bin:$PATH''') @aarch64 @centos @docker def test_aarch64(self): """Source option""" c = cmake(eula=True, version='3.14.5') self.assertEqual(str(c), r'''# CMake version 3.14.5 RUN yum install -y \ make \ openssl-devel \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.14.5/cmake-3.14.5.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/cmake-3.14.5.tar.gz -C /var/tmp -z && \ cd /var/tmp/cmake-3.14.5 && ./bootstrap --prefix=/usr/local --parallel=$(nproc) && \ make -j$(nproc) && \ make install && \ rm -rf /var/tmp/cmake-3.14.5.tar.gz /var/tmp/cmake-3.14.5 ENV PATH=/usr/local/bin:$PATH''') @aarch64 @centos @docker def test_aarch64_binary(self): """Arm binary package""" c = cmake(eula=True, version='3.25.1') self.assertEqual(str(c), r'''# CMake version 3.25.1 RUN yum install -y \ make \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-aarch64.sh && \ mkdir -p /usr/local && \ /bin/sh /var/tmp/cmake-3.25.1-linux-aarch64.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.25.1-linux-aarch64.sh ENV PATH=/usr/local/bin:$PATH''')
hpc-container-maker-master
test/test_cmake.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the baseimage module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import bash, docker, invalid_ctype, singularity, singularity26, singularity32 from distutils.version import StrictVersion import hpccm.config from hpccm.primitives.baseimage import baseimage from hpccm.common import cpu_arch, linux_distro class Test_baseimage(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @docker def test_empty_docker(self): """Default base image""" b = baseimage() self.assertNotEqual(str(b), '') @singularity def test_empty_singularity(self): """Default base image""" b = baseimage() self.assertNotEqual(str(b), '') @invalid_ctype def test_invalid_ctype(self): """Invalid container type specified""" b = baseimage() with self.assertRaises(RuntimeError): str(b) @docker def test_value_docker(self): """Image name is specified""" b = baseimage(image='foo') self.assertEqual(str(b), 'FROM foo') @singularity def test_value_singularity(self): """Image name is specified""" b = baseimage(image='foo') self.assertEqual(str(b), r'''BootStrap: docker From: foo %post . /.singularity.d/env/10-docker*.sh''') @bash def test_value_bash(self): """Image name is specified""" b = baseimage(image='foo') self.assertEqual(str(b), '#!/bin/bash -ex') @singularity def test_false_docker_env_singularity(self): """Docker env is False""" b = baseimage(image='foo', _docker_env=False) self.assertEqual(str(b), r'''BootStrap: docker From: foo''') @docker def test_as_deprecated_docker(self): """Docker specified image naming""" b = baseimage(image='foo', AS='dev') self.assertEqual(str(b), 'FROM foo AS dev') @singularity26 def test_as_deprecated_singularity(self): """Docker specified image naming""" b = baseimage(image='foo', AS='dev') self.assertEqual(str(b), r'''BootStrap: docker From: foo %post . /.singularity.d/env/10-docker*.sh''') @docker def test_as_docker(self): """Docker specified image naming""" b = baseimage(image='foo', _as='dev') self.assertEqual(str(b), 'FROM foo AS dev') @singularity26 def test_as_singularity26(self): """Docker specified image naming""" b = baseimage(image='foo', _as='dev') self.assertEqual(str(b), r'''BootStrap: docker From: foo %post . /.singularity.d/env/10-docker*.sh''') @singularity32 def test_as_singularity32(self): """Docker specified image naming""" b = baseimage(image='foo', _as='dev') self.assertEqual(str(b), r'''# NOTE: this definition file depends on features only available in # Singularity 3.2 and later. BootStrap: docker From: foo Stage: dev %post . /.singularity.d/env/10-docker*.sh''') @singularity def test_bootstrap(self): """Singularity bootstrap option""" b = baseimage(image='foo.sif', _bootstrap='localimage') self.assertEqual(str(b), r'''BootStrap: localimage From: foo.sif %post . /.singularity.d/env/10-docker*.sh''') @docker def test_detect_ubuntu(self): """Base image Linux distribution detection""" b = baseimage(image='ubuntu:sixteen') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) @docker def test_detect_ubuntu16(self): """Base image Linux distribution detection""" b = baseimage(image='nvidia/cuda:9.0-devel-ubuntu16.04') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) @docker def test_detect_ubuntu18(self): """Base image Linux distribution detection""" b = baseimage(image='nvidia/cuda:9.2-devel-ubuntu18.04') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('18.04')) @docker def test_detect_ubuntu20(self): """Base image Linux distribution detection""" b = baseimage(image='nvidia/cuda:11.0-devel-ubuntu20.04') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('20.04')) @docker def test_detect_ubuntu_16(self): """Base image Linux distribution detection""" b = baseimage(image='ubuntu:16.04') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) @docker def test_detect_ubuntu_18(self): """Base image Linux distribution detection""" b = baseimage(image='ubuntu:18.04') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('18.04')) @docker def test_detect_ubuntu_20(self): """Base image Linux distribution detection""" b = baseimage(image='ubuntu:20.04') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('20.04')) @docker def test_detect_centos(self): """Base image Linux distribution detection""" b = baseimage(image='nvidia/cuda:9.0-devel-centos7') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) @docker def test_detect_centos_7(self): """Base image Linux distribution detection""" b = baseimage(image='centos:7') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) @docker def test_detect_centos_8(self): """Base image Linux distribution detection""" b = baseimage(image='centos:8') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('8.0')) @docker def test_detect_rockylinux_8(self): """Base image Linux distribution detection""" b = baseimage(image='rockylinux/rockylinux:8') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.ROCKYLINUX) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('8.0')) @docker def test_detect_ubi7(self): """Base image Linux distribution detection""" b = baseimage(image='nvidia/cuda:10.1-devel-ubi7') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.RHEL) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) @docker def test_detect_ubi8(self): """Base image Linux distribution detection""" b = baseimage(image='nvidia/cuda:10.1-devel-ubi8') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.RHEL) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('8.0')) @docker def test_detect_nonexistent(self): """Base image Linux distribution detection""" arch = hpccm.config.get_cpu_architecture() if arch == 'aarch64': gold = cpu_arch.AARCH64 elif arch == 'ppc64le': gold = cpu_arch.PPC64LE elif arch == 'x86_64': gold = cpu_arch.X86_64 b = baseimage(image='nonexistent') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) self.assertEqual(hpccm.config.g_cpu_arch, gold) @docker def test_distro_ubuntu(self): """Base image Linux distribution specification""" b = baseimage(image='foo', _distro='ubuntu') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) @docker def test_distro_ubuntu16(self): """Base image Linux distribution specification""" b = baseimage(image='foo', _distro='ubuntu16') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) @docker def test_distro_ubuntu18(self): """Base image Linux distribution specification""" b = baseimage(image='foo', _distro='ubuntu18') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('18.04')) @docker def test_distro_ubuntu20(self): """Base image Linux distribution specification""" b = baseimage(image='foo', _distro='ubuntu20') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('20.04')) @docker def test_distro_centos(self): """Base image Linux distribution specification""" b = baseimage(image='foo', _distro='centos') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) @docker def test_distro_centos7(self): """Base image Linux distribution specification""" b = baseimage(image='foo', _distro='centos7') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('7.0')) @docker def test_distro_centos8(self): """Base image Linux distribution specification""" b = baseimage(image='foo', _distro='centos8') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.CENTOS) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('8.0')) @docker def test_distro_nonexistent(self): """Base image Linux distribution specification""" b = baseimage(image='foo', _distro='nonexistent') self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU) self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04')) @docker def test_detect_aarch64(self): """Base image CPU architecture detection""" b = baseimage(image='arm64v8/centos:7') self.assertEqual(hpccm.config.g_cpu_arch, cpu_arch.AARCH64) @docker def test_detect_ppc64le(self): """Base image CPU architecture detection""" b = baseimage(image='ppc64le/centos:7') self.assertEqual(hpccm.config.g_cpu_arch, cpu_arch.PPC64LE) @docker def test_arch_aarch64(self): """Base image CPU architecture specification""" b = baseimage(image='foo', _arch='aarch64') self.assertEqual(hpccm.config.g_cpu_arch, cpu_arch.AARCH64) @docker def test_arch_ppc64le(self): """Base image CPU architecture specification""" b = baseimage(image='foo', _arch='ppc64le') self.assertEqual(hpccm.config.g_cpu_arch, cpu_arch.PPC64LE) @docker def test_arch_x86_64(self): """Base image CPU architecture specification""" b = baseimage(image='foo', _arch='x86_64') self.assertEqual(hpccm.config.g_cpu_arch, cpu_arch.X86_64) @docker def test_arch_nonexistent(self): """Base image CPU architecture specification""" arch = hpccm.config.get_cpu_architecture() if arch == 'aarch64': gold = cpu_arch.AARCH64 elif arch == 'ppc64le': gold = cpu_arch.PPC64LE elif arch == 'x86_64': gold = cpu_arch.X86_64 b = baseimage(image='foo', _arch='nonexistent') self.assertEqual(hpccm.config.g_cpu_arch, gold)
hpc-container-maker-master
test/test_baseimage.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the CMakeBuild module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from hpccm.templates.CMakeBuild import CMakeBuild from hpccm.toolchain import toolchain class Test_CMakeBuild(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_defaults(self): """Default values""" cm = CMakeBuild() # configure step configure = cm.configure_step(directory='/tmp/src') self.assertEqual(configure, 'mkdir -p /tmp/src/build && cd /tmp/src/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local /tmp/src') # build step build = cm.build_step() self.assertEqual(build, 'cmake --build /tmp/src/build --target all -- -j$(nproc)') # build some target install = cm.build_step(target='foo') self.assertEqual(install, 'cmake --build /tmp/src/build --target foo -- -j$(nproc)') def test_toolchain(self): """Toolchain specified""" cm = CMakeBuild() tc = toolchain(CC='mycc', CXX='mycxx', FC='myfc', F77='myf77', F90='myf90', CFLAGS='-g -O3', CPPFLAGS='-DFOO -DBAR', CXXFLAGS='-g -O3', FCFLAGS='-g -O3', FFLAGS='-g -O3', FLIBS='-ldl', LD_LIBRARY_PATH='/opt/mysw/lib:/opt/yoursw/lib', LDFLAGS='-Wl,--start-group foo.o bar.o -Wl,--endgroup', LIBS='-ldl -lpthread') configure = cm.configure_step(directory='/tmp/src', toolchain=tc) self.assertEqual(configure, '''mkdir -p /tmp/src/build && cd /tmp/src/build && CC=mycc CFLAGS='-g -O3' CPPFLAGS='-DFOO -DBAR' CXX=mycxx CXXFLAGS='-g -O3' F77=myf77 F90=myf90 FC=myfc FCFLAGS='-g -O3' FFLAGS='-g -O3' FLIBS=-ldl LD_LIBRARY_PATH=/opt/mysw/lib:/opt/yoursw/lib LDFLAGS='-Wl,--start-group foo.o bar.o -Wl,--endgroup' LIBS='-ldl -lpthread' cmake -DCMAKE_INSTALL_PREFIX=/usr/local /tmp/src''') def test_directory(self): """Build directory specified""" cm = CMakeBuild() # Relative build dir configure = cm.configure_step(directory='/tmp/src', build_directory='../build') self.assertEqual(configure, 'mkdir -p /tmp/src/../build && cd /tmp/src/../build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local /tmp/src') # Absolute build dir configure = cm.configure_step(directory='/tmp/src', build_directory='/tmp/build') self.assertEqual(configure, 'mkdir -p /tmp/build && cd /tmp/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local /tmp/src') # No build directory configure = cm.configure_step() self.assertEqual(configure, 'cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..') def test_parallel(self): """Parallel count specified""" cm = CMakeBuild(parallel=4) cm.configure_step(directory='/tmp/src') # Function arguments override constructor build = cm.build_step(parallel=7) self.assertEqual(build, 'cmake --build /tmp/src/build --target all -- -j7') # Use constructor arguments build = cm.build_step() self.assertEqual(build, 'cmake --build /tmp/src/build --target all -- -j4') def test_configure_opts(self): """Configure options specified""" cm = CMakeBuild(opts=['-DWITH_BAR=ON'], prefix='') # Function arguments override constructor configure = cm.configure_step( directory='/tmp/src', opts=['-DCMAKE_BUILD_TYPE=Debug', '-DWITH_FOO=ON'] ) self.assertEqual(configure, 'mkdir -p /tmp/src/build && cd /tmp/src/build && cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_FOO=ON /tmp/src') # Use constructor arguments configure = cm.configure_step(directory='/tmp/src') self.assertEqual(configure, 'mkdir -p /tmp/src/build && cd /tmp/src/build && cmake -DWITH_BAR=ON /tmp/src')
hpc-container-maker-master
test/test_CMakeBuild.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the multi_ofed module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, centos8, docker, ubuntu, ubuntu18, x86_64 from hpccm.building_blocks.multi_ofed import multi_ofed class Test_multi_ofed(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu18 @docker def test_versions_ubuntu18(self): """mlnx_version parameter""" # Reduced set of versions to limit gold output ofed = multi_ofed(mlnx_versions=['4.5-1.0.1.0', '4.6-1.0.1.1']) self.assertEqual(str(ofed), r'''# Mellanox OFED version 4.5-1.0.1.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ libnl-3-200 \ libnl-route-3-200 \ libnuma1 \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox | apt-key add - && \ mkdir -p /etc/apt/sources.list.d && wget -q -nc --no-check-certificate -P /etc/apt/sources.list.d https://linux.mellanox.com/public/repo/mlnx_ofed/4.5-1.0.1.0/ubuntu18.04/mellanox_mlnx_ofed.list && \ apt-get update -y && \ mkdir -m 777 -p /var/tmp/packages_download && cd /var/tmp/packages_download && \ DEBIAN_FRONTEND=noninteractive apt-get download -y --no-install-recommends \ ibverbs-utils \ libibmad \ libibmad-devel \ libibumad \ libibumad-devel \ libibverbs-dev \ libibverbs1 \ libmlx4-1 \ libmlx4-dev \ libmlx5-1 \ libmlx5-dev \ librdmacm-dev \ librdmacm1 && \ mkdir -p /usr/local/ofed/4.5-1.0.1.0 && \ find /var/tmp/packages_download -regextype posix-extended -type f -regex "/var/tmp/packages_download/(ibverbs-utils|libibmad|libibmad-devel|libibumad|libibumad-devel|libibverbs-dev|libibverbs1|libmlx4-1|libmlx4-dev|libmlx5-1|libmlx5-dev|librdmacm-dev|librdmacm1).*deb" -exec dpkg --extract {} /usr/local/ofed/4.5-1.0.1.0 \; && \ rm -rf /var/tmp/packages_download && \ rm -f /etc/apt/sources.list.d/mellanox_mlnx_ofed.list && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /etc/libibverbs.d # Mellanox OFED version 4.6-1.0.1.1 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ libnl-3-200 \ libnl-route-3-200 \ libnuma1 \ wget && \ rm -rf /var/lib/apt/lists/* RUN wget -qO - https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox | apt-key add - && \ mkdir -p /etc/apt/sources.list.d && wget -q -nc --no-check-certificate -P /etc/apt/sources.list.d https://linux.mellanox.com/public/repo/mlnx_ofed/4.6-1.0.1.1/ubuntu18.04/mellanox_mlnx_ofed.list && \ apt-get update -y && \ mkdir -m 777 -p /var/tmp/packages_download && cd /var/tmp/packages_download && \ DEBIAN_FRONTEND=noninteractive apt-get download -y --no-install-recommends \ ibverbs-utils \ libibmad \ libibmad-devel \ libibumad \ libibumad-devel \ libibverbs-dev \ libibverbs1 \ libmlx4-1 \ libmlx4-dev \ libmlx5-1 \ libmlx5-dev \ librdmacm-dev \ librdmacm1 && \ mkdir -p /usr/local/ofed/4.6-1.0.1.1 && \ find /var/tmp/packages_download -regextype posix-extended -type f -regex "/var/tmp/packages_download/(ibverbs-utils|libibmad|libibmad-devel|libibumad|libibumad-devel|libibverbs-dev|libibverbs1|libmlx4-1|libmlx4-dev|libmlx5-1|libmlx5-dev|librdmacm-dev|librdmacm1).*deb" -exec dpkg --extract {} /usr/local/ofed/4.6-1.0.1.1 \; && \ rm -rf /var/tmp/packages_download && \ rm -f /etc/apt/sources.list.d/mellanox_mlnx_ofed.list && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /etc/libibverbs.d # OFED RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnl-3-200 \ libnl-route-3-200 \ libnuma1 && \ rm -rf /var/lib/apt/lists/* RUN apt-get update -y && \ mkdir -m 777 -p /var/tmp/packages_download && cd /var/tmp/packages_download && \ DEBIAN_FRONTEND=noninteractive apt-get download -y --no-install-recommends -t bionic \ dapl2-utils \ ibutils \ ibverbs-providers \ ibverbs-utils \ infiniband-diags \ libdapl-dev \ libdapl2 \ libibmad-dev \ libibmad5 \ libibverbs-dev \ libibverbs1 \ librdmacm-dev \ librdmacm1 \ rdmacm-utils && \ mkdir -p /usr/local/ofed/inbox && \ find /var/tmp/packages_download -regextype posix-extended -type f -regex "/var/tmp/packages_download/(dapl2-utils|ibutils|ibverbs-providers|ibverbs-utils|infiniband-diags|libdapl-dev|libdapl2|libibmad-dev|libibmad5|libibverbs-dev|libibverbs1|librdmacm-dev|librdmacm1|rdmacm-utils).*deb" -exec dpkg --extract {} /usr/local/ofed/inbox \; && \ rm -rf /var/tmp/packages_download && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /etc/libibverbs.d RUN ln -s /usr/local/ofed/inbox /usr/local/ofed/5.0-0''') @x86_64 @centos8 @docker def test_versions_centos8(self): """mlnx_version parameter""" # Reduced set of versions to limit gold output ofed = multi_ofed(mlnx_versions=['4.5-1.0.1.0', '4.6-1.0.1.1']) self.assertEqual(str(ofed), r'''# Mellanox OFED version 4.5-1.0.1.0 RUN yum install -y \ ca-certificates \ gnupg \ libnl3 \ numactl-libs \ wget && \ rm -rf /var/cache/yum/* RUN rpm --import https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox && \ yum install -y dnf-utils && \ yum-config-manager --add-repo https://linux.mellanox.com/public/repo/mlnx_ofed/4.5-1.0.1.0/rhel8.0/mellanox_mlnx_ofed.repo && \ yum install -y yum-utils && \ mkdir -p /var/tmp/packages_download && \ yumdownloader --destdir=/var/tmp/packages_download -x \*i?86 --archlist=x86_64 \ libibmad \ libibmad-devel \ libibumad \ libibumad-devel \ libibverbs \ libibverbs-devel \ libibverbs-utils \ libmlx4 \ libmlx4-devel \ libmlx5 \ libmlx5-devel \ librdmacm \ librdmacm-devel && \ mkdir -p /usr/local/ofed/4.5-1.0.1.0 && cd /usr/local/ofed/4.5-1.0.1.0 && \ find /var/tmp/packages_download -regextype posix-extended -type f -regex "/var/tmp/packages_download/(libibmad|libibmad-devel|libibumad|libibumad-devel|libibverbs|libibverbs-devel|libibverbs-utils|libmlx4|libmlx4-devel|libmlx5|libmlx5-devel|librdmacm|librdmacm-devel).*rpm" -exec sh -c "rpm2cpio {} | cpio -idm" \; && \ rm -rf /var/tmp/packages_download && \ rm -rf /var/cache/yum/* RUN mkdir -p /etc/libibverbs.d # Mellanox OFED version 4.6-1.0.1.1 RUN yum install -y \ ca-certificates \ gnupg \ libnl3 \ numactl-libs \ wget && \ rm -rf /var/cache/yum/* RUN rpm --import https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox && \ yum install -y dnf-utils && \ yum-config-manager --add-repo https://linux.mellanox.com/public/repo/mlnx_ofed/4.6-1.0.1.1/rhel8.0/mellanox_mlnx_ofed.repo && \ yum install -y yum-utils && \ mkdir -p /var/tmp/packages_download && \ yumdownloader --destdir=/var/tmp/packages_download -x \*i?86 --archlist=x86_64 \ libibmad \ libibmad-devel \ libibumad \ libibumad-devel \ libibverbs \ libibverbs-devel \ libibverbs-utils \ libmlx4 \ libmlx4-devel \ libmlx5 \ libmlx5-devel \ librdmacm \ librdmacm-devel && \ mkdir -p /usr/local/ofed/4.6-1.0.1.1 && cd /usr/local/ofed/4.6-1.0.1.1 && \ find /var/tmp/packages_download -regextype posix-extended -type f -regex "/var/tmp/packages_download/(libibmad|libibmad-devel|libibumad|libibumad-devel|libibverbs|libibverbs-devel|libibverbs-utils|libmlx4|libmlx4-devel|libmlx5|libmlx5-devel|librdmacm|librdmacm-devel).*rpm" -exec sh -c "rpm2cpio {} | cpio -idm" \; && \ rm -rf /var/tmp/packages_download && \ rm -rf /var/cache/yum/* RUN mkdir -p /etc/libibverbs.d # OFED RUN yum install -y \ libnl3 \ numactl-libs && \ rm -rf /var/cache/yum/* RUN yum install -y dnf-utils && \ yum-config-manager --set-enabled powertools && \ yum install -y yum-utils && \ mkdir -p /var/tmp/packages_download && \ yumdownloader --destdir=/var/tmp/packages_download -x \*i?86 --archlist=x86_64 --disablerepo=mlnx\* \ libibmad \ libibmad-devel \ libibumad \ libibverbs \ libibverbs-utils \ libmlx5 \ librdmacm \ rdma-core \ rdma-core-devel && \ mkdir -p /usr/local/ofed/inbox && cd /usr/local/ofed/inbox && \ find /var/tmp/packages_download -regextype posix-extended -type f -regex "/var/tmp/packages_download/(libibmad|libibmad-devel|libibumad|libibverbs|libibverbs-utils|libmlx5|librdmacm|rdma-core|rdma-core-devel).*rpm" -exec sh -c "rpm2cpio {} | cpio -idm" \; && \ rm -rf /var/tmp/packages_download && \ rm -rf /var/cache/yum/* RUN mkdir -p /etc/libibverbs.d RUN ln -s /usr/local/ofed/inbox /usr/local/ofed/5.0-0''') @x86_64 @centos @docker def test_runtime_centos(self): """Runtime""" ofed = multi_ofed() r = ofed.runtime() self.assertEqual(r, r'''# OFED RUN yum install -y \ libnl \ libnl3 \ numactl-libs && \ rm -rf /var/cache/yum/* RUN mkdir -p /etc/libibverbs.d COPY --from=0 /usr/local/ofed /usr/local/ofed''') @x86_64 @ubuntu18 @docker def test_runtime_ubuntu18(self): """Runtime""" ofed = multi_ofed() r = ofed.runtime() self.assertEqual(r, r'''# OFED RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libnl-3-200 \ libnl-route-3-200 \ libnuma1 && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /etc/libibverbs.d COPY --from=0 /usr/local/ofed /usr/local/ofed''')
hpc-container-maker-master
test/test_multi_ofed.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the yum module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, centos8, docker, x86_64 from hpccm.building_blocks.yum import yum class Test_yum(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @centos @docker def test_basic(self): """Basic yum""" y = yum(ospackages=['gcc', 'gcc-c++', 'gcc-fortran']) self.assertEqual(str(y), r'''RUN yum install -y \ gcc \ gcc-c++ \ gcc-fortran && \ rm -rf /var/cache/yum/*''') @x86_64 @centos @docker def test_add_repo(self): """Add repo and key""" y = yum(keys=['https://www.example.com/key.pub'], ospackages=['example'], repositories=['http://www.example.com/example.repo']) self.assertEqual(str(y), r'''RUN rpm --import https://www.example.com/key.pub && \ yum install -y yum-utils && \ yum-config-manager --add-repo http://www.example.com/example.repo && \ yum install -y \ example && \ rm -rf /var/cache/yum/*''') @x86_64 @centos8 @docker def test_add_repo_centos8(self): """Add repo and key""" y = yum(keys=['https://www.example.com/key.pub'], ospackages=['example'], repositories=['http://www.example.com/example.repo']) self.assertEqual(str(y), r'''RUN rpm --import https://www.example.com/key.pub && \ yum install -y dnf-utils && \ yum-config-manager --add-repo http://www.example.com/example.repo && \ yum install -y \ example && \ rm -rf /var/cache/yum/*''') @x86_64 @centos8 @docker def test_add_repo_powertools_centos8(self): """Add repo and key and enable PowerTools""" y = yum(keys=['https://www.example.com/key.pub'], ospackages=['example'], repositories=['http://www.example.com/example.repo'], powertools=True) self.assertEqual(str(y), r'''RUN rpm --import https://www.example.com/key.pub && \ yum install -y dnf-utils && \ yum-config-manager --add-repo http://www.example.com/example.repo && \ yum-config-manager --set-enabled powertools && \ yum install -y \ example && \ rm -rf /var/cache/yum/*''') @x86_64 @centos @docker def test_download(self): """Download parameter""" y = yum(download=True, download_directory='/tmp/download', ospackages=['rdma-core']) self.assertEqual(str(y), r'''RUN yum install -y yum-utils && \ mkdir -p /tmp/download && \ yumdownloader --destdir=/tmp/download -x \*i?86 --archlist=x86_64 \ rdma-core && \ rm -rf /var/cache/yum/*''') @aarch64 @centos @docker def test_download_aarch64(self): """Download parameter""" y = yum(download=True, download_directory='/tmp/download', ospackages=['rdma-core']) self.assertEqual(str(y), r'''RUN yum install -y yum-utils && \ mkdir -p /tmp/download && \ yumdownloader --destdir=/tmp/download \ rdma-core && \ rm -rf /var/cache/yum/*''') @x86_64 @centos @docker def test_extract(self): """Extract parameter""" y = yum(download=True, extract='/usr/local/ofed', ospackages=['rdma-core']) self.assertEqual(str(y), r'''RUN yum install -y yum-utils && \ mkdir -p /var/tmp/yum_download && \ yumdownloader --destdir=/var/tmp/yum_download -x \*i?86 --archlist=x86_64 \ rdma-core && \ mkdir -p /usr/local/ofed && cd /usr/local/ofed && \ find /var/tmp/yum_download -regextype posix-extended -type f -regex "/var/tmp/yum_download/(rdma-core).*rpm" -exec sh -c "rpm2cpio {} | cpio -idm" \; && \ rm -rf /var/tmp/yum_download && \ rm -rf /var/cache/yum/*''') @x86_64 @centos @docker def test_powertools_centos7(self): """Powertools repo""" y = yum(ospackages=['hwloc-devel'], powertools=True) self.assertEqual(str(y), r'''RUN yum install -y \ hwloc-devel && \ rm -rf /var/cache/yum/*''') @x86_64 @centos8 @docker def test_powertools_centos8(self): """Powertools repo""" y = yum(ospackages=['hwloc-devel'], powertools=True) self.assertEqual(str(y), r'''RUN yum install -y dnf-utils && \ yum-config-manager --set-enabled powertools && \ yum install -y \ hwloc-devel && \ rm -rf /var/cache/yum/*''')
hpc-container-maker-master
test/test_yum.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the nvhpc module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, docker, ppc64le, ubuntu, x86_64 from hpccm.building_blocks.nvhpc import nvhpc from hpccm.toolchain import toolchain class Test_nvhpc(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default HPC SDK building block""" n = nvhpc(eula=True) self.assertMultiLineEqual(str(n), r'''# NVIDIA HPC SDK version 23.5 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/DEB-GPG-KEY-NVIDIA-HPC-SDK.gpg && \ wget -qO - https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | gpg --dearmor -o /usr/share/keyrings/DEB-GPG-KEY-NVIDIA-HPC-SDK.gpg && \ echo "deb [signed-by=/usr/share/keyrings/DEB-GPG-KEY-NVIDIA-HPC-SDK.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nvhpc-23-5-cuda-multi && \ rm -rf /var/lib/apt/lists/* ENV CPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nvshmem/include:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nccl/include:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/extras/qd/include/qd:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/math_libs/include:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi/include:$CPATH \ LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nvshmem/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nccl/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/math_libs/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/cuda/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi/lib:$LD_LIBRARY_PATH \ MANPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/man:$MANPATH \ PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nvshmem/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nccl/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/profilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/cuda/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi/bin:$PATH''') @x86_64 @centos @docker def test_defaults_centos(self): """Default HPC SDK building block""" n = nvhpc(eula=True) self.assertMultiLineEqual(str(n), r'''# NVIDIA HPC SDK version 23.5 RUN yum install -y \ ca-certificates && \ rm -rf /var/cache/yum/* RUN yum install -y yum-utils && \ yum-config-manager --add-repo https://developer.download.nvidia.com/hpc-sdk/rhel/nvhpc.repo && \ yum install -y \ nvhpc-cuda-multi-23.5 && \ rm -rf /var/cache/yum/* ENV CPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nvshmem/include:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nccl/include:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/extras/qd/include/qd:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/math_libs/include:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi/include:$CPATH \ LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nvshmem/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nccl/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/math_libs/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/cuda/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi/lib:$LD_LIBRARY_PATH \ MANPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/man:$MANPATH \ PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nvshmem/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/nccl/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/profilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/cuda/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi/bin:$PATH''') @x86_64 @centos @docker def test_package_centos(self): """Local package""" n = nvhpc(eula=True, package='nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz') self.assertMultiLineEqual(str(n), r'''# NVIDIA HPC SDK version 20.7 COPY nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz RUN yum install -y \ bc \ gcc \ gcc-c++ \ gcc-gfortran \ libatomic \ numactl-libs \ openssh-clients \ wget \ which && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && tar -x -f /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz -C /var/tmp -z && \ cd /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi && NVHPC_ACCEPT_EULA=accept NVHPC_INSTALL_DIR=/opt/nvidia/hpc_sdk NVHPC_SILENT=true ./install && \ rm -rf /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz ENV CPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nvshmem/include:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nccl/include:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/extras/qd/include/qd:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/math_libs/include:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/mpi/include:$CPATH \ LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nvshmem/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nccl/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/math_libs/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/cuda/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/mpi/lib:$LD_LIBRARY_PATH \ MANPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/man:$MANPATH \ PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nvshmem/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nccl/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/profilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/cuda/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/mpi/bin:$PATH''') @x86_64 @centos @docker def test_extended_environment(self): """Extended environment""" n = nvhpc(eula=True, extended_environment=True, package='nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz') self.assertMultiLineEqual(str(n), r'''# NVIDIA HPC SDK version 20.7 COPY nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz RUN yum install -y \ bc \ gcc \ gcc-c++ \ gcc-gfortran \ libatomic \ numactl-libs \ openssh-clients \ wget \ which && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && tar -x -f /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz -C /var/tmp -z && \ cd /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi && NVHPC_ACCEPT_EULA=accept NVHPC_INSTALL_DIR=/opt/nvidia/hpc_sdk NVHPC_SILENT=true ./install && \ rm -rf /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi /var/tmp/nvhpc_2020_207_Linux_x86_64_cuda_multi.tar.gz ENV CC=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin/nvc \ CPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nvshmem/include:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nccl/include:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/extras/qd/include/qd:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/math_libs/include:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/mpi/include:$CPATH \ CPP=cpp \ CXX=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin/nvc++ \ F77=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin/nvfortran \ F90=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin/nvfortran \ FC=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin/nvfortran \ LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nvshmem/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nccl/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/math_libs/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/cuda/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/mpi/lib:$LD_LIBRARY_PATH \ MANPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/man:$MANPATH \ PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nvshmem/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/nccl/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/profilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/cuda/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/comm_libs/mpi/bin:$PATH''') @aarch64 @ubuntu @docker def test_aarch64(self): """Default HPC SDK building block on aarch64""" n = nvhpc(cuda_multi=False, eula=True, version='21.2', tarball=True) self.assertMultiLineEqual(str(n), r'''# NVIDIA HPC SDK version 21.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bc \ debianutils \ g++ \ gcc \ gfortran \ libatomic1 \ libnuma1 \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://developer.download.nvidia.com/hpc-sdk/21.2/nvhpc_2021_212_Linux_aarch64_cuda_11.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/nvhpc_2021_212_Linux_aarch64_cuda_11.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/nvhpc_2021_212_Linux_aarch64_cuda_11.2 && NVHPC_ACCEPT_EULA=accept NVHPC_INSTALL_DIR=/opt/nvidia/hpc_sdk NVHPC_SILENT=true ./install && \ rm -rf /var/tmp/nvhpc_2021_212_Linux_aarch64_cuda_11.2 /var/tmp/nvhpc_2021_212_Linux_aarch64_cuda_11.2.tar.gz ENV CPATH=/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/nvshmem/include:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/nccl/include:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/compilers/extras/qd/include/qd:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/math_libs/include:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/mpi/include:$CPATH \ LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/nvshmem/lib:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/nccl/lib:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/math_libs/lib64:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/compilers/lib:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/cuda/lib64:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/mpi/lib:$LD_LIBRARY_PATH \ MANPATH=/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/compilers/man:$MANPATH \ PATH=/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/nvshmem/bin:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/nccl/bin:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/profilers/bin:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/compilers/bin:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/cuda/bin:/opt/nvidia/hpc_sdk/Linux_aarch64/21.2/comm_libs/mpi/bin:$PATH''') @ppc64le @ubuntu @docker def test_ppc64le(self): """Default HPC SDK building block on ppc64le""" n = nvhpc(eula=True, cuda_multi=False, cuda='11.0', version='20.7', tarball=True) self.assertMultiLineEqual(str(n), r'''# NVIDIA HPC SDK version 20.7 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bc \ debianutils \ g++ \ gcc \ gfortran \ libatomic1 \ libnuma1 \ openssh-client \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://developer.download.nvidia.com/hpc-sdk/20.7/nvhpc_2020_207_Linux_ppc64le_cuda_11.0.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/nvhpc_2020_207_Linux_ppc64le_cuda_11.0.tar.gz -C /var/tmp -z && \ cd /var/tmp/nvhpc_2020_207_Linux_ppc64le_cuda_11.0 && NVHPC_ACCEPT_EULA=accept NVHPC_DEFAULT_CUDA=11.0 NVHPC_INSTALL_DIR=/opt/nvidia/hpc_sdk NVHPC_SILENT=true ./install && \ rm -rf /var/tmp/nvhpc_2020_207_Linux_ppc64le_cuda_11.0 /var/tmp/nvhpc_2020_207_Linux_ppc64le_cuda_11.0.tar.gz ENV CPATH=/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/nvshmem/include:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/nccl/include:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/compilers/extras/qd/include/qd:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/math_libs/include:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/mpi/include:$CPATH \ LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/nvshmem/lib:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/nccl/lib:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/math_libs/lib64:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/compilers/lib:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/cuda/lib64:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/mpi/lib:$LD_LIBRARY_PATH \ MANPATH=/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/compilers/man:$MANPATH \ PATH=/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/nvshmem/bin:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/nccl/bin:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/profilers/bin:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/compilers/bin:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/cuda/bin:/opt/nvidia/hpc_sdk/Linux_ppc64le/20.7/comm_libs/mpi/bin:$PATH''') @x86_64 @ubuntu @docker def test_runtime_ubuntu(self): """Runtime""" n = nvhpc(eula=True, redist=['compilers/lib/*']) r = n.runtime() self.assertMultiLineEqual(r, r'''# NVIDIA HPC SDK RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libatomic1 \ libnuma1 \ openssh-client && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/REDIST/compilers/lib/* /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/lib/ COPY --from=0 /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi ENV LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/lib:$LD_LIBRARY_PATH \ PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/mpi/bin:$PATH''') @x86_64 @centos @docker def test_runtime_centos(self): """Runtime""" n = nvhpc(eula=True, mpi=False, redist=['comm_libs/11.0/nccl/lib/libnccl.so', 'compilers/lib/*', 'math_libs/11.0/lib64/libcufft.so.10', 'math_libs/11.0/lib64/libcublas.so.11']) r = n.runtime() self.assertMultiLineEqual(r, r'''# NVIDIA HPC SDK RUN yum install -y \ libatomic \ numactl-libs \ openssh-clients && \ rm -rf /var/cache/yum/* COPY --from=0 /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/REDIST/comm_libs/11.0/nccl/lib/libnccl.so /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/11.0/nccl/lib/libnccl.so COPY --from=0 /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/REDIST/compilers/lib/* /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/lib/ COPY --from=0 /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/REDIST/math_libs/11.0/lib64/libcufft.so.10 /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/math_libs/11.0/lib64/libcufft.so.10 COPY --from=0 /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/REDIST/math_libs/11.0/lib64/libcublas.so.11 /opt/nvidia/hpc_sdk/Linux_x86_64/23.5/math_libs/11.0/lib64/libcublas.so.11 ENV LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/comm_libs/11.0/nccl/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/compilers/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/23.5/math_libs/11.0/lib64:$LD_LIBRARY_PATH''') @x86_64 @ubuntu @docker def test_makelocalrc(self): """makelocalrc""" tc = toolchain(CC='gcc-10', CXX='g++-10', F77='gfortran-10') n = nvhpc(eula=True, mpi=False, toolchain=tc, version='22.3') self.assertMultiLineEqual(str(n), r'''# NVIDIA HPC SDK version 22.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ gnupg \ wget && \ rm -rf /var/lib/apt/lists/* RUN echo "deb [trusted=yes] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nvhpc-22-3-cuda-multi && \ rm -rf /var/lib/apt/lists/* RUN /opt/nvidia/hpc_sdk/Linux_x86_64/22.3/compilers/bin/makelocalrc /opt/nvidia/hpc_sdk/Linux_x86_64/22.3/compilers/bin -x -gcc gcc-10 -gpp g++-10 -g77 gfortran-10 ENV CPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/comm_libs/nvshmem/include:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/comm_libs/nccl/include:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/compilers/extras/qd/include/qd:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/math_libs/include:$CPATH \ LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/comm_libs/nvshmem/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/comm_libs/nccl/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/math_libs/lib64:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/compilers/lib:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/cuda/lib64:$LD_LIBRARY_PATH \ MANPATH=/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/compilers/man:$MANPATH \ PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/comm_libs/nvshmem/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/comm_libs/nccl/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/profilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/compilers/bin:/opt/nvidia/hpc_sdk/Linux_x86_64/22.3/cuda/bin:$PATH''') def test_toolchain(self): """Toolchain""" n = nvhpc() tc = n.toolchain self.assertEqual(tc.CC, 'nvc') self.assertEqual(tc.CXX, 'nvc++') self.assertEqual(tc.FC, 'nvfortran') self.assertEqual(tc.F77, 'nvfortran') self.assertEqual(tc.F90, 'nvfortran')
hpc-container-maker-master
test/test_nvhpc.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the shell module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import bash, docker, invalid_ctype, singularity from hpccm.primitives.shell import shell class Test_shell(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @docker def test_empty(self): """No commands specified""" s = shell() self.assertEqual(str(s), '') @invalid_ctype def test_invalid_ctype(self): """Invalid container type specified""" s = shell(commands=['a']) with self.assertRaises(RuntimeError): str(s) @docker def test_single_docker(self): """Single command specified""" cmd = ['z'] s = shell(commands=cmd) self.assertEqual(str(s), 'RUN z') @singularity def test_single_singularity(self): """Single command specified""" cmd = ['z'] s = shell(commands=cmd) self.assertEqual(str(s), '%post\n cd /\n z') @bash def test_single_bash(self): """Single command specified""" cmd = ['z'] s = shell(commands=cmd) self.assertEqual(str(s), 'cd /\nz') @docker def test_nochdir_docker(self): """chdir disable""" cmd = ['z'] s = shell(chdir=False, commands=cmd) self.assertEqual(str(s), 'RUN z') @singularity def test_nochdir_singularity(self): """chdir disable""" cmd = ['z'] s = shell(chdir=False, commands=cmd) self.assertEqual(str(s), '%post\n z') @bash def test_nochdir_bash(self): """chdir disable""" cmd = ['z'] s = shell(chdir=False, commands=cmd) self.assertEqual(str(s), 'z') @docker def test_multiple_docker(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds) self.assertEqual(str(s), 'RUN a && \\\n b && \\\n c') @singularity def test_multiple_singularity(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds) self.assertEqual(str(s), '%post\n cd /\n a\n b\n c') @bash def test_multiple_bash(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds) self.assertEqual(str(s), 'cd /\na\nb\nc') @singularity def test_appinstall_multiple_singularity(self): """Multiple app-specific install commands""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds, _app='foo') self.assertEqual(str(s), '%appinstall foo\n a\n b\n c') @docker def test_appinstall_docker(self): """appinstall not implemented in Docker""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds, _app='foo') self.assertEqual(str(s), 'RUN a && \\\n b && \\\n c') @singularity def test_appinstall_env_multiple_singularity(self): """Multiple app-specific install commands""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds, _app='foo', _appenv=True) self.assertEqual(str(s), '%appinstall foo\n' ' for f in /.singularity.d/env/*; do . $f; done\n' ' a\n b\n c') @singularity def test_test_singularity(self): """test option""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds, chdir=False, _test=True) self.assertEqual(str(s), '%test\n a\n b\n c') @singularity def test_apptest_singularity(self): """test option""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds, _app='foo', chdir=False, _test=True) self.assertEqual(str(s), '%apptest foo\n a\n b\n c') @docker def test_merge_docker(self): s = [] s.append(shell(commands=['a', 'b'])) s.append(shell(commands=['c'])) merged = s[0].merge(s) self.assertEqual(str(merged), 'RUN a && \\\n b && \\\n c') @singularity def test_merge_singularity(self): s = [] s.append(shell(commands=['a', 'b'])) s.append(shell(commands=['c'])) merged = s[0].merge(s) self.assertEqual(str(merged), '%post\n cd /\n a\n b\n c') @docker def test_arguments_docker(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = shell(commands=cmds, _arguments='--mount=type=bind,target=/usr/local/mysrc') self.assertEqual(str(s), 'RUN --mount=type=bind,target=/usr/local/mysrc a && \\\n b && \\\n c')
hpc-container-maker-master
test/test_shell.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the ldconfig module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from hpccm.templates.ldconfig import ldconfig class Test_ldconfig(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_no_directory(self): """No directory specified""" l = ldconfig() self.assertEqual(l.ldcache_step(directory=None), '') def test_basic(self): """Basic ldconfig""" l = ldconfig() self.assertEqual(l.ldcache_step(directory='/usr/local/lib'), 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig')
hpc-container-maker-master
test/test_ldconfig.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the generic_cmake module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.generic_cmake import generic_cmake from hpccm.toolchain import toolchain class Test_generic_cmake(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default generic_cmake building block""" g = generic_cmake( cmake_opts=['-D CMAKE_BUILD_TYPE=Release', '-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda', '-D GMX_BUILD_OWN_FFTW=ON', '-D GMX_GPU=ON', '-D GMX_MPI=OFF', '-D GMX_OPENMP=ON', '-D GMX_PREFER_STATIC_LIBS=ON', '-D MPIEXEC_PREFLAGS=--allow-run-as-root'], directory='gromacs-2018.2', prefix='/usr/local/gromacs', url='https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz') self.assertEqual(str(g), r'''# https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2018.2.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/gromacs-2018.2/build && cd /var/tmp/gromacs-2018.2/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/gromacs -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda -D GMX_BUILD_OWN_FFTW=ON -D GMX_GPU=ON -D GMX_MPI=OFF -D GMX_OPENMP=ON -D GMX_PREFER_STATIC_LIBS=ON -D MPIEXEC_PREFLAGS=--allow-run-as-root /var/tmp/gromacs-2018.2 && \ cmake --build /var/tmp/gromacs-2018.2/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/gromacs-2018.2/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/gromacs-2018.2 /var/tmp/v2018.2.tar.gz''') @ubuntu @docker def test_no_url(self): """missing url""" with self.assertRaises(RuntimeError): g = generic_cmake() @ubuntu @docker def test_both_repository_and_url(self): """both repository and url""" with self.assertRaises(RuntimeError): g = generic_cmake(repository='foo', url='bar') @ubuntu @docker def test_invalid_package(self): """invalid package url""" with self.assertRaises(RuntimeError): g = generic_cmake(url='https://foo/bar.sh') @ubuntu @docker def test_package(self): """local package""" g = generic_cmake( cmake_opts=['-D CMAKE_BUILD_TYPE=Release', '-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda', '-D GMX_BUILD_OWN_FFTW=ON', '-D GMX_GPU=ON', '-D GMX_MPI=OFF', '-D GMX_OPENMP=ON', '-D GMX_PREFER_STATIC_LIBS=ON', '-D MPIEXEC_PREFLAGS=--allow-run-as-root', '-D REGRESSIONTEST_DOWNLOAD=ON'], directory='gromacs-2018.2', package='gromacs/v2018.2.tar.gz', prefix='/usr/local/gromacs') self.assertEqual(str(g), r'''# gromacs/v2018.2.tar.gz COPY gromacs/v2018.2.tar.gz /var/tmp/v2018.2.tar.gz RUN mkdir -p /var/tmp && tar -x -f /var/tmp/v2018.2.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/gromacs-2018.2/build && cd /var/tmp/gromacs-2018.2/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/gromacs -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda -D GMX_BUILD_OWN_FFTW=ON -D GMX_GPU=ON -D GMX_MPI=OFF -D GMX_OPENMP=ON -D GMX_PREFER_STATIC_LIBS=ON -D MPIEXEC_PREFLAGS=--allow-run-as-root -D REGRESSIONTEST_DOWNLOAD=ON /var/tmp/gromacs-2018.2 && \ cmake --build /var/tmp/gromacs-2018.2/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/gromacs-2018.2/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/gromacs-2018.2 /var/tmp/v2018.2.tar.gz''') @ubuntu @docker def test_build_directory(self): """build directory option""" g = generic_cmake( build_directory='/tmp/build', directory='spdlog-1.4.2', url='https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz') self.assertEqual(str(g), r'''# https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v1.4.2.tar.gz -C /var/tmp -z && \ mkdir -p /tmp/build && cd /tmp/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local /var/tmp/spdlog-1.4.2 && \ cmake --build /tmp/build --target all -- -j$(nproc) && \ cmake --build /tmp/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/spdlog-1.4.2 /var/tmp/v1.4.2.tar.gz /tmp/build''') @ubuntu @docker def test_pre_and_post(self): """Preconfigure and postinstall options""" g = generic_cmake( directory='/var/tmp/spdlog-1.4.2', postinstall=['echo "post"'], preconfigure=['echo "pre"'], prefix='/usr/local/spdlog', url='https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz') self.assertEqual(str(g), r'''# https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v1.4.2.tar.gz -C /var/tmp -z && \ cd /var/tmp/spdlog-1.4.2 && \ echo "pre" && \ mkdir -p /var/tmp/spdlog-1.4.2/build && cd /var/tmp/spdlog-1.4.2/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/spdlog /var/tmp/spdlog-1.4.2 && \ cmake --build /var/tmp/spdlog-1.4.2/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/spdlog-1.4.2/build --target install -- -j$(nproc) && \ cd /usr/local/spdlog && \ echo "post" && \ rm -rf /var/tmp/spdlog-1.4.2 /var/tmp/v1.4.2.tar.gz''') @ubuntu @docker def test_build_environment_and_toolchain(self): """build environment and toolchain""" tc = toolchain(CC='gcc', CXX='g++', FC='gfortran') g = generic_cmake( build_environment={'FOO': 'BAR'}, check=True, cmake_opts=['-D CMAKE_BUILD_TYPE=Release', '-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda', '-D GMX_BUILD_OWN_FFTW=ON', '-D GMX_GPU=ON', '-D GMX_MPI=OFF', '-D GMX_OPENMP=ON', '-D GMX_PREFER_STATIC_LIBS=ON', '-D MPIEXEC_PREFLAGS=--allow-run-as-root', '-D REGRESSIONTEST_DOWNLOAD=ON'], directory='gromacs-2018.2', prefix='/usr/local/gromacs', toolchain=tc, url='https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz') self.assertEqual(str(g), r'''# https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v2018.2.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/gromacs-2018.2/build && cd /var/tmp/gromacs-2018.2/build && FOO=BAR CC=gcc CXX=g++ FC=gfortran cmake -DCMAKE_INSTALL_PREFIX=/usr/local/gromacs -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda -D GMX_BUILD_OWN_FFTW=ON -D GMX_GPU=ON -D GMX_MPI=OFF -D GMX_OPENMP=ON -D GMX_PREFER_STATIC_LIBS=ON -D MPIEXEC_PREFLAGS=--allow-run-as-root -D REGRESSIONTEST_DOWNLOAD=ON /var/tmp/gromacs-2018.2 && \ cmake --build /var/tmp/gromacs-2018.2/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/gromacs-2018.2/build --target check -- -j$(nproc) && \ cmake --build /var/tmp/gromacs-2018.2/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/gromacs-2018.2 /var/tmp/v2018.2.tar.gz''') @ubuntu @docker def test_ldconfig_and_environment(self): """ldconfig and environment""" g = generic_cmake( devel_environment={'CPATH': '/usr/local/spdlog/include:$CPATH'}, directory='spdlog-1.4.2', ldconfig=True, prefix='/usr/local/spdlog', runtime_environment={'CPATH': '/usr/local/spdlog/include:$CPATH'}, url='https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz') self.assertEqual(str(g), r'''# https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v1.4.2.tar.gz -C /var/tmp -z && \ mkdir -p /var/tmp/spdlog-1.4.2/build && cd /var/tmp/spdlog-1.4.2/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/spdlog /var/tmp/spdlog-1.4.2 && \ cmake --build /var/tmp/spdlog-1.4.2/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/spdlog-1.4.2/build --target install -- -j$(nproc) && \ echo "/usr/local/spdlog/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/spdlog-1.4.2 /var/tmp/v1.4.2.tar.gz ENV CPATH=/usr/local/spdlog/include:$CPATH''') r = g.runtime() self.assertEqual(r, r'''# https://github.com/gabime/spdlog/archive/v1.4.2.tar.gz COPY --from=0 /usr/local/spdlog /usr/local/spdlog RUN echo "/usr/local/spdlog/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig ENV CPATH=/usr/local/spdlog/include:$CPATH''') @ubuntu @docker def test_repository(self): """test repository option""" g = generic_cmake(branch='v0.8.0', cmake_opts=['-D CMAKE_BUILD_TYPE=RELEASE', '-D QUDA_DIRAC_CLOVER=ON', '-D QUDA_DIRAC_DOMAIN_WALL=ON', '-D QUDA_DIRAC_STAGGERED=ON', '-D QUDA_DIRAC_TWISTED_CLOVER=ON', '-D QUDA_DIRAC_TWISTED_MASS=ON', '-D QUDA_DIRAC_WILSON=ON', '-D QUDA_FORCE_GAUGE=ON', '-D QUDA_FORCE_HISQ=ON', '-D QUDA_GPU_ARCH=sm_70', '-D QUDA_INTERFACE_MILC=ON', '-D QUDA_INTERFACE_QDP=ON', '-D QUDA_LINK_HISQ=ON', '-D QUDA_MPI=ON'], prefix='/usr/local/quda', recursive=True, repository='https://github.com/lattice/quda.git') self.assertEqual(str(g), r'''# https://github.com/lattice/quda.git RUN mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch v0.8.0 --recursive https://github.com/lattice/quda.git quda && cd - && \ mkdir -p /var/tmp/quda/build && cd /var/tmp/quda/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/quda -D CMAKE_BUILD_TYPE=RELEASE -D QUDA_DIRAC_CLOVER=ON -D QUDA_DIRAC_DOMAIN_WALL=ON -D QUDA_DIRAC_STAGGERED=ON -D QUDA_DIRAC_TWISTED_CLOVER=ON -D QUDA_DIRAC_TWISTED_MASS=ON -D QUDA_DIRAC_WILSON=ON -D QUDA_FORCE_GAUGE=ON -D QUDA_FORCE_HISQ=ON -D QUDA_GPU_ARCH=sm_70 -D QUDA_INTERFACE_MILC=ON -D QUDA_INTERFACE_QDP=ON -D QUDA_LINK_HISQ=ON -D QUDA_MPI=ON /var/tmp/quda && \ cmake --build /var/tmp/quda/build --target all -- -j$(nproc) && \ cmake --build /var/tmp/quda/build --target install -- -j$(nproc) && \ rm -rf /var/tmp/quda''') @ubuntu @docker def test_runtime(self): """Runtime""" g = generic_cmake( cmake_opts=['-D CMAKE_BUILD_TYPE=Release', '-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda', '-D GMX_BUILD_OWN_FFTW=ON', '-D GMX_GPU=ON', '-D GMX_MPI=OFF', '-D GMX_OPENMP=ON', '-D GMX_PREFER_STATIC_LIBS=ON', '-D MPIEXEC_PREFLAGS=--allow-run-as-root'], directory='gromacs-2018.2', prefix='/usr/local/gromacs', url='https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz') r = g.runtime() self.assertEqual(r, r'''# https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz COPY --from=0 /usr/local/gromacs /usr/local/gromacs''') @ubuntu @docker def test_runtime_manual(self): """Runtime""" g = generic_cmake( cmake_opts=['-D CMAKE_BUILD_TYPE=Release', '-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda', '-D GMX_BUILD_OWN_FFTW=ON', '-D GMX_GPU=ON', '-D GMX_MPI=OFF', '-D GMX_OPENMP=ON', '-D GMX_PREFER_STATIC_LIBS=ON', '-D MPIEXEC_PREFLAGS=--allow-run-as-root'], directory='gromacs-2018.2', prefix='/usr/local/gromacs', runtime=['/usr/local/gromacs/bin/*', '/usr/local/gromacs/share'], url='https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz') r = g.runtime() self.assertEqual(r, r'''# https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz COPY --from=0 /usr/local/gromacs/bin/* /usr/local/gromacs/bin/ COPY --from=0 /usr/local/gromacs/share /usr/local/gromacs/share''') @ubuntu @docker def test_runtime_annotate(self): """Runtime""" g = generic_cmake( annotate=True, base_annotation='gromacs', cmake_opts=['-D CMAKE_BUILD_TYPE=Release', '-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda', '-D GMX_BUILD_OWN_FFTW=ON', '-D GMX_GPU=ON', '-D GMX_MPI=OFF', '-D GMX_OPENMP=ON', '-D GMX_PREFER_STATIC_LIBS=ON', '-D MPIEXEC_PREFLAGS=--allow-run-as-root'], directory='gromacs-2018.2', prefix='/usr/local/gromacs', url='https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz') r = g.runtime() self.assertEqual(r, r'''# https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz COPY --from=0 /usr/local/gromacs /usr/local/gromacs LABEL hpccm.gromacs.cmake='cmake -DCMAKE_INSTALL_PREFIX=/usr/local/gromacs -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda -D GMX_BUILD_OWN_FFTW=ON -D GMX_GPU=ON -D GMX_MPI=OFF -D GMX_OPENMP=ON -D GMX_PREFER_STATIC_LIBS=ON -D MPIEXEC_PREFLAGS=--allow-run-as-root' \ hpccm.gromacs.url=https://github.com/gromacs/gromacs/archive/v2018.2.tar.gz''')
hpc-container-maker-master
test/test_generic_cmake.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the scif module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import os import tempfile import unittest from helpers import centos, docker, singularity from hpccm.building_blocks.python import python from hpccm.building_blocks.scif import scif from hpccm.primitives.copy import copy from hpccm.primitives.comment import comment from hpccm.primitives.environment import environment from hpccm.primitives.label import label from hpccm.primitives.runscript import runscript from hpccm.primitives.shell import shell class Test_scif(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @docker def test_noname_docker(self): """Default scif building block, no name""" with self.assertRaises(RuntimeError): scif() @docker def test_defaults_docker(self): """Default scif building block""" # The scif module generates a SCI-F recipe file. Use a # temporary file location for it rather than polluting the # test environment. This is slightly unrealistic since the # Docker build would fail since the file is outside the Docker # build environment, but go with it. scif_file = tempfile.NamedTemporaryFile(delete=False, suffix='.scif') s = scif(name='foo', file=scif_file.name) self.assertEqual(str(s), r'''# SCI-F "foo" COPY {0} /scif/recipes/{1} RUN scif install /scif/recipes/{1}'''.format(scif_file.name, os.path.basename(scif_file.name))) try: os.unlink(scif_file.name) except WindowsError: # WindowsError: [Error 32] The process cannot access the file # because it is being used by another process pass @docker def test_arguments_docker(self): """Default scif building block with _arguments""" scif_file = tempfile.NamedTemporaryFile(delete=False, suffix='.scif') s = scif(_arguments='--mount=type=bind,target=/scif/apps/foo/src', file=scif_file.name, name='foo') self.assertEqual(str(s), r'''# SCI-F "foo" COPY {0} /scif/recipes/{1} RUN --mount=type=bind,target=/scif/apps/foo/src scif install /scif/recipes/{1}'''.format(scif_file.name, os.path.basename(scif_file.name))) try: os.unlink(scif_file.name) except WindowsError: # WindowsError: [Error 32] The process cannot access the file # because it is being used by another process pass @singularity def test_defaults_singularity(self): """Default scif building block""" s = scif(name='foo') self.assertEqual(str(s), '') @singularity def test_allsections_singularity(self): """One of each SCI-f section type""" s = scif(name='foo') s += copy(src='file', dest='/src/file') s += comment('My app') s += environment(variables={'ONE': '1'}) s += label(metadata={'A': 'B'}) s += runscript(commands=['default_program']) s += shell(commands=['build_cmds']) s += shell(commands=['test_program'], _test=True) self.assertEqual(str(s), r'''%appenv foo export ONE=1 %appfiles foo file /src/file %apphelp foo My app %appinstall foo build_cmds %applabels foo A B %apprun foo exec default_program "$@" %apptest foo test_program''') @docker def test_allsections_docker(self): """One of each SCI-f section type""" # See comment in the test_defaults_docker test case scif_file = tempfile.NamedTemporaryFile(delete=False, suffix='.scif') s = scif(name='foo', file=scif_file.name) s += copy(src='file', dest='/src/file') s += comment('My app') s += environment(variables={'ONE': '1'}) s += label(metadata={'A': 'B'}) s += runscript(commands=['default_program']) s += shell(commands=['build_cmds']) s += shell(commands=['test_program'], _test=True) str(s) # Force writing the SCI-F recipe file # slurp file content with open(scif_file.name) as f: content = f.read() try: os.unlink(scif_file.name) except WindowsError: # WindowsError: [Error 32] The process cannot access the file # because it is being used by another process pass self.assertEqual(content, r'''%appenv foo export ONE=1 %appfiles foo file /src/file %apphelp foo My app %appinstall foo build_cmds %applabels foo A B %apprun foo exec default_program "$@" %apptest foo test_program''') @centos @singularity def test_building_block_singularity(self): """test building block""" s = scif(name='foo') s += [python()] # list not required, but tests a code branch self.assertEqual(str(s), r'''%apphelp foo Python %appinstall foo yum install -y \ python2 \ python3 rm -rf /var/cache/yum/*''') @docker def test_runtime(self): """Runtime""" s = scif(name='foo') r = s.runtime() self.assertEqual(r, 'COPY --from=0 /scif /scif')
hpc-container-maker-master
test/test_scif.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the charm module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, docker, ppc64le, ubuntu, x86_64 from hpccm.building_blocks.charm import charm class Test_charm(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults(self): """Default charm building block""" c = charm() self.assertEqual(str(c), r'''# Charm++ version 6.10.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ git \ libtool \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/UIUC-PPL/charm/archive/v6.10.2.tar.gz && \ mkdir -p /usr/local && tar -x -f /var/tmp/v6.10.2.tar.gz -C /usr/local -z && \ cd /usr/local/charm-6.10.2 && ./build charm++ multicore-linux-x86_64 --build-shared --with-production -j$(nproc) && \ rm -rf /var/tmp/v6.10.2.tar.gz ENV CHARMBASE=/usr/local/charm-6.10.2 \ LD_LIBRARY_PATH=/usr/local/charm-6.10.2/lib_so:$LD_LIBRARY_PATH \ PATH=/usr/local/charm-6.10.2/bin:$PATH''') @aarch64 @ubuntu @docker def test_aarch64(self): """Default charm building block""" c = charm(version='6.9.0') self.assertEqual(str(c), r'''# Charm++ version 6.9.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ git \ libtool \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/UIUC-PPL/charm/archive/v6.9.0.tar.gz && \ mkdir -p /usr/local && tar -x -f /var/tmp/v6.9.0.tar.gz -C /usr/local -z && \ cd /usr/local/charm-6.9.0 && ./build charm++ multicore-arm8 --build-shared --with-production -j$(nproc) && \ rm -rf /var/tmp/v6.9.0.tar.gz ENV CHARMBASE=/usr/local/charm-6.9.0 \ LD_LIBRARY_PATH=/usr/local/charm-6.9.0/lib_so:$LD_LIBRARY_PATH \ PATH=/usr/local/charm-6.9.0/bin:$PATH''') @ppc64le @ubuntu @docker def test_ppc64le(self): """Default charm building block""" c = charm(version='6.9.0') self.assertEqual(str(c), r'''# Charm++ version 6.9.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ git \ libtool \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/UIUC-PPL/charm/archive/v6.9.0.tar.gz && \ mkdir -p /usr/local && tar -x -f /var/tmp/v6.9.0.tar.gz -C /usr/local -z && \ cd /usr/local/charm-6.9.0 && ./build charm++ multicore-linux-ppc64le --build-shared --with-production -j$(nproc) && \ rm -rf /var/tmp/v6.9.0.tar.gz ENV CHARMBASE=/usr/local/charm-6.9.0 \ LD_LIBRARY_PATH=/usr/local/charm-6.9.0/lib_so:$LD_LIBRARY_PATH \ PATH=/usr/local/charm-6.9.0/bin:$PATH''') @x86_64 @ubuntu @docker def test_ldconfig(self): """ldconfig option""" c = charm(ldconfig=True, version='6.8.2') self.assertEqual(str(c), r'''# Charm++ version 6.8.2 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ git \ libtool \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/UIUC-PPL/charm/archive/v6.8.2.tar.gz && \ mkdir -p /usr/local && tar -x -f /var/tmp/v6.8.2.tar.gz -C /usr/local -z && \ cd /usr/local/charm-v6.8.2 && ./build charm++ multicore-linux-x86_64 --build-shared --with-production -j$(nproc) && \ echo "/usr/local/charm-v6.8.2/lib_so" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/v6.8.2.tar.gz ENV CHARMBASE=/usr/local/charm-v6.8.2 \ PATH=/usr/local/charm-v6.8.2/bin:$PATH''') @x86_64 @ubuntu @docker def test_basedir(self): """basedir option""" c = charm(basedir=['/usr/local/openmpi'], version='6.9.0') self.assertEqual(str(c), r'''# Charm++ version 6.9.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ autoconf \ automake \ git \ libtool \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/UIUC-PPL/charm/archive/v6.9.0.tar.gz && \ mkdir -p /usr/local && tar -x -f /var/tmp/v6.9.0.tar.gz -C /usr/local -z && \ cd /usr/local/charm-6.9.0 && ./build charm++ multicore-linux-x86_64 --build-shared --with-production --basedir=/usr/local/openmpi -j$(nproc) && \ rm -rf /var/tmp/v6.9.0.tar.gz ENV CHARMBASE=/usr/local/charm-6.9.0 \ LD_LIBRARY_PATH=/usr/local/charm-6.9.0/lib_so:$LD_LIBRARY_PATH \ PATH=/usr/local/charm-6.9.0/bin:$PATH''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" c = charm() r = c.runtime() self.assertEqual(r, r'''# Charm++ COPY --from=0 /usr/local/charm-6.10.2 /usr/local/charm-6.10.2 ENV CHARMBASE=/usr/local/charm-6.10.2 \ LD_LIBRARY_PATH=/usr/local/charm-6.10.2/lib_so:$LD_LIBRARY_PATH \ PATH=/usr/local/charm-6.10.2/bin:$PATH''')
hpc-container-maker-master
test/test_charm.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the boost module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu from hpccm.building_blocks.boost import boost class Test_boost(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_defaults_ubuntu(self): """Default boost building block""" b = boost() self.assertEqual(str(b), r'''# Boost version 1.76.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libbz2-dev \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/boost_1_76_0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/boost_1_76_0 && ./bootstrap.sh --prefix=/usr/local/boost --without-libraries=python && \ ./b2 -j$(nproc) -q install && \ rm -rf /var/tmp/boost_1_76_0.tar.bz2 /var/tmp/boost_1_76_0 ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @centos @docker def test_defaults_centos(self): """Default boost building block""" b = boost() self.assertEqual(str(b), r'''# Boost version 1.76.0 RUN yum install -y \ bzip2 \ bzip2-devel \ tar \ wget \ which \ zlib-devel && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/boost_1_76_0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/boost_1_76_0 && ./bootstrap.sh --prefix=/usr/local/boost --without-libraries=python && \ ./b2 -j$(nproc) -q install && \ rm -rf /var/tmp/boost_1_76_0.tar.bz2 /var/tmp/boost_1_76_0 ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @ubuntu @docker def test_python(self): """python option""" b = boost(python=True, version='1.72.0') self.assertEqual(str(b), r'''# Boost version 1.72.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libbz2-dev \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/boost_1_72_0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/boost_1_72_0 && ./bootstrap.sh --prefix=/usr/local/boost && \ ./b2 -j$(nproc) -q install && \ rm -rf /var/tmp/boost_1_72_0.tar.bz2 /var/tmp/boost_1_72_0 ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @ubuntu @docker def test_sourceforge(self): """sourceforge option""" b = boost(sourceforge=True, version='1.57.0') self.assertEqual(str(b), r'''# Boost version 1.57.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libbz2-dev \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/boost_1_57_0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/boost_1_57_0 && ./bootstrap.sh --prefix=/usr/local/boost --without-libraries=python && \ ./b2 -j$(nproc) -q install && \ rm -rf /var/tmp/boost_1_57_0.tar.bz2 /var/tmp/boost_1_57_0 ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @ubuntu @docker def test_ldconfig(self): """ldconfig option""" b = boost(ldconfig=True, version='1.68.0') self.assertEqual(str(b), r'''# Boost version 1.68.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libbz2-dev \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://boostorg.jfrog.io/artifactory/main/release/1.68.0/source/boost_1_68_0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/boost_1_68_0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/boost_1_68_0 && ./bootstrap.sh --prefix=/usr/local/boost --without-libraries=python && \ ./b2 -j$(nproc) -q install && \ echo "/usr/local/boost/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/boost_1_68_0.tar.bz2 /var/tmp/boost_1_68_0''') @ubuntu @docker def test_bootstrap_opts(self): b = boost(bootstrap_opts=['--with-libraries=atomic,chrono'], version='1.72.0') self.assertEqual(str(b), r'''# Boost version 1.72.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libbz2-dev \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/boost_1_72_0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/boost_1_72_0 && ./bootstrap.sh --prefix=/usr/local/boost --with-libraries=atomic,chrono && \ ./b2 -j$(nproc) -q install && \ rm -rf /var/tmp/boost_1_72_0.tar.bz2 /var/tmp/boost_1_72_0 ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @ubuntu @docker def test_b2_opts(self): b = boost(b2_opts=['cxxflags="-std=c++14"'], version='1.72.0') self.assertEqual(str(b), r'''# Boost version 1.72.0 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ libbz2-dev \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \ mkdir -p /var/tmp && tar -x -f /var/tmp/boost_1_72_0.tar.bz2 -C /var/tmp -j && \ cd /var/tmp/boost_1_72_0 && ./bootstrap.sh --prefix=/usr/local/boost --without-libraries=python && \ ./b2 cxxflags="-std=c++14" -j$(nproc) -q install && \ rm -rf /var/tmp/boost_1_72_0.tar.bz2 /var/tmp/boost_1_72_0 ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''') @ubuntu @docker def test_runtime(self): """Runtime""" b = boost() r = b.runtime() self.assertEqual(r, r'''# Boost COPY --from=0 /usr/local/boost /usr/local/boost ENV LD_LIBRARY_PATH=/usr/local/boost/lib:$LD_LIBRARY_PATH''')
hpc-container-maker-master
test/test_boost.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the cli module""" from __future__ import unicode_literals from __future__ import print_function import argparse import logging # pylint: disable=unused-import import unittest from hpccm.cli import KeyValue class Test_cli(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_argparse_userarg(self): parser = argparse.ArgumentParser() parser.add_argument('--userarg', action=KeyValue, nargs='+') args = parser.parse_args(['--userarg', 'a=b', 'c=d', 'e="f f f"']) self.assertEqual(args.userarg['a'], 'b') self.assertEqual(args.userarg['c'], 'd') self.assertEqual(args.userarg['e'], '"f f f"')
hpc-container-maker-master
test/test_cli.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the blob module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import os import unittest from helpers import bash, docker, invalid_ctype, singularity from hpccm.primitives.blob import blob class Test_blob(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @docker def test_empty(self): """No blob specified""" b = blob() self.assertEqual(str(b), '') @invalid_ctype def test_invalid_ctype(self): """Invalid container type specified""" b = blob() with self.assertRaises(RuntimeError): str(b) @docker def test_invalid_files(self): """Invalid file""" b = blob(docker='/path/to/nonexistent/file') self.assertEqual(str(b), '') @docker def test_docker_only_docker(self): """Only Docker blob specified""" path = os.path.dirname(__file__) b = blob(docker=os.path.join(path, 'docker.blob')) self.assertEqual(str(b), 'COPY foo bar\nRUN bar\n') @singularity def test_docker_only_singularity(self): """Only Docker blob specified""" path = os.path.dirname(__file__) b = blob(docker=os.path.join(path, 'docker.blob')) self.assertEqual(str(b), '') @docker def test_singularity_only_docker(self): """Only Singularity blob specified""" path = os.path.dirname(__file__) b = blob(singularity=os.path.join(path, 'singularity.blob')) self.assertEqual(str(b), '') @singularity def test_singularity_only_singularity(self): """Only Singularity blob specified""" path = os.path.dirname(__file__) b = blob(singularity=os.path.join(path, 'singularity.blob')) self.assertEqual(str(b), '''%files foo bar %post bar ''') @docker def test_all_docker(self): """Both Docker and Singularity blobs specified""" path = os.path.dirname(__file__) b = blob(docker=os.path.join(path, 'docker.blob'), singularity=os.path.join(path, 'singularity.blob')) self.assertEqual(str(b), 'COPY foo bar\nRUN bar\n') @singularity def test_all_singularity(self): """Both Docker and Singularity blobs specified""" path = os.path.dirname(__file__) b = blob(docker=os.path.join(path, 'docker.blob'), singularity=os.path.join(path, 'singularity.blob')) self.assertEqual(str(b), '''%files foo bar %post bar ''') @bash def test_all_bash(self): """Both Docker and Singularity blobs specified""" path = os.path.dirname(__file__) b = blob(docker=os.path.join(path, 'docker.blob'), singularity=os.path.join(path, 'singularity.blob')) self.assertEqual(str(b), '')
hpc-container-maker-master
test/test_blob.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Unit testing helpers""" from __future__ import unicode_literals from __future__ import print_function from distutils.version import StrictVersion import logging # pylint: disable=unused-import import hpccm.config from hpccm.common import container_type, cpu_arch, linux_distro def aarch64(function): """Decorator to set the CPU architecture to aarch64""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_arch = cpu_arch.AARCH64 return function(*args, **kwargs) return wrapper def bash(function): """Decorator to set the global container type to bash""" def wrapper(*args, **kwargs): hpccm.config.g_ctype = container_type.BASH return function(*args, **kwargs) return wrapper def broadwell(function): """Decorator to set the CPU type to Broadwell""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_target = 'broadwell' return function(*args, **kwargs) return wrapper def centos(function): """Decorator to set the Linux distribution to CentOS 7""" def wrapper(*args, **kwargs): hpccm.config.g_linux_distro = linux_distro.CENTOS hpccm.config.g_linux_version = StrictVersion('7.0') return function(*args, **kwargs) return wrapper def centos8(function): """Decorator to set the Linux distribution to CentOS 8""" def wrapper(*args, **kwargs): hpccm.config.g_linux_distro = linux_distro.CENTOS hpccm.config.g_linux_version = StrictVersion('8.0') return function(*args, **kwargs) return wrapper def cpu_target_none(function): """Decorator to set the CPU type to None""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_target = None return function(*args, **kwargs) return wrapper def docker(function): """Decorator to set the global container type to docker""" def wrapper(*args, **kwargs): hpccm.config.g_ctype = container_type.DOCKER return function(*args, **kwargs) return wrapper def icelake(function): """Decorator to set the CPU type to Ice Lake""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_target = 'icelake' return function(*args, **kwargs) return wrapper def invalid_cpu_arch(function): """Decorator to set the global CPU architecture to an invalid value""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_arch = None return function(*args, **kwargs) return wrapper def invalid_ctype(function): """Decorator to set the global container type to an invalid value""" def wrapper(*args, **kwargs): hpccm.config.g_ctype = None return function(*args, **kwargs) return wrapper def invalid_distro(function): """Decorator to set the global Linux distribution to an invalid value""" def wrapper(*args, **kwargs): hpccm.config.g_linux_distro = None return function(*args, **kwargs) return wrapper def ppc64le(function): """Decorator to set the CPU architecture to ppc64le""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_arch = cpu_arch.PPC64LE return function(*args, **kwargs) return wrapper def singularity(function): """Decorator to set the global container type to singularity""" def wrapper(*args, **kwargs): hpccm.config.g_ctype = container_type.SINGULARITY return function(*args, **kwargs) return wrapper def singularity26(function): """Decorator to set the global singularity version""" def wrapper(*args, **kwargs): hpccm.config.g_ctype = container_type.SINGULARITY hpccm.config.g_singularity_version = StrictVersion('2.6') return function(*args, **kwargs) return wrapper def singularity32(function): """Decorator to set the global singularity version""" def wrapper(*args, **kwargs): hpccm.config.g_ctype = container_type.SINGULARITY hpccm.config.g_singularity_version = StrictVersion('3.2') return function(*args, **kwargs) return wrapper def singularity37(function): """Decorator to set the global singularity version""" def wrapper(*args, **kwargs): hpccm.config.g_ctype = container_type.SINGULARITY hpccm.config.g_singularity_version = StrictVersion('3.7') return function(*args, **kwargs) return wrapper def thunderx2(function): """Decorator to set the CPU type to ThunderX2""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_target = 'thunderx2' return function(*args, **kwargs) return wrapper def ubuntu(function): """Decorator to set the Linux distribution to Ubuntu 16.04""" def wrapper(*args, **kwargs): hpccm.config.g_linux_distro = linux_distro.UBUNTU hpccm.config.g_linux_version = StrictVersion('16.04') return function(*args, **kwargs) return wrapper def ubuntu18(function): """Decorator to set the Linux distribution to Ubuntu 18.04""" def wrapper(*args, **kwargs): hpccm.config.g_linux_distro = linux_distro.UBUNTU hpccm.config.g_linux_version = StrictVersion('18.04') return function(*args, **kwargs) return wrapper def ubuntu20(function): """Decorator to set the Linux distribution to Ubuntu 20.04""" def wrapper(*args, **kwargs): hpccm.config.g_linux_distro = linux_distro.UBUNTU hpccm.config.g_linux_version = StrictVersion('20.04') return function(*args, **kwargs) return wrapper def ubuntu22(function): """Decorator to set the Linux distribution to Ubuntu 22.04""" def wrapper(*args, **kwargs): hpccm.config.g_linux_distro = linux_distro.UBUNTU hpccm.config.g_linux_version = StrictVersion('22.04') return function(*args, **kwargs) return wrapper def x86_64(function): """Decorator to set the CPU architecture to x86_64""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_arch = cpu_arch.X86_64 return function(*args, **kwargs) return wrapper def zen2(function): """Decorator to set the CPU type to Zen 2""" def wrapper(*args, **kwargs): hpccm.config.g_cpu_target = 'zen2' return function(*args, **kwargs) return wrapper
hpc-container-maker-master
test/helpers.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the downloader module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import docker, singularity, bash from hpccm.templates.downloader import downloader class Test_downloader(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) def test_missing_url(self): """Missing url option""" d = downloader() with self.assertRaises(RuntimeError): d.download_step() def test_url_and_repository(self): """Both URL and repository specified""" d = downloader(repository='https://github.com/foo/bar', url='http://mysite.com/foo.tgz') with self.assertRaises(RuntimeError): d.download_step() @docker def test_basic_wget_docker(self): """Basic wget""" d = downloader(url='http://mysite.com/foo.tgz') self.assertEqual(d.download_step(), r'''mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mysite.com/foo.tgz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/foo.tgz -C /var/tmp -z''') self.assertEqual(d.src_directory, '/var/tmp/foo') @singularity def test_basic_wget_singularity(self): """Basic wget""" d = downloader(url='http://mysite.com/foo.tgz') self.assertEqual(d.download_step(), r'''mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mysite.com/foo.tgz mkdir -p /var/tmp && tar -x -f /var/tmp/foo.tgz -C /var/tmp -z''') self.assertEqual(d.src_directory, '/var/tmp/foo') @bash def test_basic_wget_bash(self): """Basic wget""" d = downloader(url='http://mysite.com/foo.tgz') self.assertEqual(d.download_step(), r'''mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mysite.com/foo.tgz mkdir -p /var/tmp && tar -x -f /var/tmp/foo.tgz -C /var/tmp -z''') self.assertEqual(d.src_directory, '/var/tmp/foo') @docker def test_bad_url(self): """Unrecognized package format, assumes tar can figure it out""" d = downloader(url='http://mysite.com/foo.Z') self.assertEqual(d.download_step(), r'''mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp http://mysite.com/foo.Z && \ mkdir -p /var/tmp && tar -x -f /var/tmp/foo.Z -C /var/tmp''') self.assertEqual(d.src_directory, None) @docker def test_bad_url_noallow(self): """Unrecognzied package format""" d = downloader(url='http://mysite.com/foo.Z') with self.assertRaises(RuntimeError): d.download_step(allow_unknown_filetype=False) @docker def test_basic_git(self): """Basic git""" d = downloader(repository='https://github.com/foo/bar.git') self.assertEqual(d.download_step(), r'''mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 https://github.com/foo/bar.git bar && cd -''') self.assertEqual(d.src_directory, '/var/tmp/bar') @docker def test_git_recursive_branch(self): """Recursive clone of a branch""" d = downloader(branch='dev', repository='https://github.com/foo/bar') self.assertEqual(d.download_step(recursive=True), r'''mkdir -p /var/tmp && cd /var/tmp && git clone --depth=1 --branch dev --recursive https://github.com/foo/bar bar && cd -''') @docker def test_git_commit_wd(self): """Git commit into an alternative working directory""" d = downloader(commit='deadbeef', repository='https://github.com/foo/bar') self.assertEqual(d.download_step(wd='/tmp/git'), r'''mkdir -p /tmp/git && cd /tmp/git && git clone https://github.com/foo/bar bar && cd - && cd /tmp/git/bar && git checkout deadbeef && cd -''') self.assertEqual(d.src_directory, '/tmp/git/bar') @docker def test_tarball(self): """Local tarball, no download""" d = downloader(package='foo.tar.gz') self.assertEqual(d.download_step(), 'mkdir -p /var/tmp && tar -x -f /var/tmp/foo.tar.gz -C /var/tmp -z') self.assertEqual(d.src_directory, '/var/tmp/foo') @docker def test_zipfile(self): """Local zipfile, no download""" d = downloader(package='foo.zip') self.assertEqual(d.download_step(), 'mkdir -p /var/tmp && unzip -d /var/tmp /var/tmp/foo.zip') self.assertEqual(d.src_directory, '/var/tmp/foo')
hpc-container-maker-master
test/test_downloader.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the fftw module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, cpu_target_none, docker, icelake, ppc64le, ubuntu, x86_64 from hpccm.building_blocks.fftw import fftw class Test_fftw(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @cpu_target_none @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default fftw building block""" f = fftw() self.assertEqual(str(f), r'''# FFTW version 3.3.10 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.10.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.10.tar.gz -C /var/tmp -z && \ cd /var/tmp/fftw-3.3.10 && ./configure --prefix=/usr/local/fftw --enable-openmp --enable-shared --enable-sse2 --enable-threads && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/fftw-3.3.10 /var/tmp/fftw-3.3.10.tar.gz ENV LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') @cpu_target_none @x86_64 @centos @docker def test_defaults_centos(self): """Default fftw building block""" f = fftw() self.assertEqual(str(f), r'''# FFTW version 3.3.10 RUN yum install -y \ file \ make \ wget && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.10.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.10.tar.gz -C /var/tmp -z && \ cd /var/tmp/fftw-3.3.10 && ./configure --prefix=/usr/local/fftw --enable-openmp --enable-shared --enable-sse2 --enable-threads && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/fftw-3.3.10 /var/tmp/fftw-3.3.10.tar.gz ENV LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') @cpu_target_none @x86_64 @ubuntu @docker def test_mpi(self): """MPI enabled""" f = fftw(mpi=True) self.assertEqual(str(f), r'''# FFTW version 3.3.10 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.10.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.10.tar.gz -C /var/tmp -z && \ cd /var/tmp/fftw-3.3.10 && ./configure --prefix=/usr/local/fftw --enable-mpi --enable-openmp --enable-shared --enable-sse2 --enable-threads && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/fftw-3.3.10 /var/tmp/fftw-3.3.10.tar.gz ENV LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') @cpu_target_none @x86_64 @ubuntu @docker def test_ldconfig(self): """ldconfig option""" f = fftw(ldconfig=True, version='3.3.8') self.assertEqual(str(f), r'''# FFTW version 3.3.8 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.8.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.8.tar.gz -C /var/tmp -z && \ cd /var/tmp/fftw-3.3.8 && ./configure --prefix=/usr/local/fftw --enable-openmp --enable-shared --enable-sse2 --enable-threads && \ make -j$(nproc) && \ make -j$(nproc) install && \ echo "/usr/local/fftw/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/fftw-3.3.8 /var/tmp/fftw-3.3.8.tar.gz''') @aarch64 @ubuntu @docker def test_aarch64(self): """Default fftw building block""" f = fftw(version='3.3.8') self.assertEqual(str(f), r'''# FFTW version 3.3.8 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.8.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.8.tar.gz -C /var/tmp -z && \ cd /var/tmp/fftw-3.3.8 && ./configure --prefix=/usr/local/fftw --enable-openmp --enable-shared --enable-threads && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/fftw-3.3.8 /var/tmp/fftw-3.3.8.tar.gz ENV LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') @ppc64le @ubuntu @docker def test_ppc64le(self): """Default fftw building block""" f = fftw(version='3.3.8') self.assertEqual(str(f), r'''# FFTW version 3.3.8 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.8.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.8.tar.gz -C /var/tmp -z && \ cd /var/tmp/fftw-3.3.8 && ./configure --prefix=/usr/local/fftw --enable-openmp --enable-shared --enable-threads && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/fftw-3.3.8 /var/tmp/fftw-3.3.8.tar.gz ENV LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') @icelake @x86_64 @ubuntu @docker def test_cpu_optimization_flags(self): """CPU optimization flags""" f = fftw(version='3.3.8') self.assertEqual(str(f), r'''# FFTW version 3.3.8 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ file \ make \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp ftp://ftp.fftw.org/pub/fftw/fftw-3.3.8.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/fftw-3.3.8.tar.gz -C /var/tmp -z && \ cd /var/tmp/fftw-3.3.8 && ./configure --prefix=/usr/local/fftw --enable-avx --enable-avx2 --enable-avx512 --enable-openmp --enable-shared --enable-sse2 --enable-threads && \ make -j$(nproc) && \ make -j$(nproc) install && \ rm -rf /var/tmp/fftw-3.3.8 /var/tmp/fftw-3.3.8.tar.gz ENV LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" f = fftw() r = f.runtime() self.assertEqual(r, r'''# FFTW COPY --from=0 /usr/local/fftw /usr/local/fftw ENV LD_LIBRARY_PATH=/usr/local/fftw/lib:$LD_LIBRARY_PATH''')
hpc-container-maker-master
test/test_fftw.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the runscript module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import bash, docker, invalid_ctype, singularity from hpccm.primitives.runscript import runscript class Test_runscript(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @docker def test_empty(self): """No commands specified""" s = runscript() self.assertEqual(str(s), '') @invalid_ctype def test_invalid_ctype(self): """Invalid container type specified""" s = runscript(commands=['a']) with self.assertRaises(RuntimeError): str(s) @docker def test_single_docker(self): """Single command specified""" cmd = ['z arg1 arg2'] s = runscript(commands=cmd) self.assertEqual(str(s), 'ENTRYPOINT ["z", "arg1", "arg2"]') @singularity def test_single_singularity(self): """Single command specified""" cmd = ['z'] s = runscript(commands=cmd) self.assertEqual(str(s), '%runscript\n exec z "$@"') @docker def test_multiple_docker(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = runscript(commands=cmds) self.assertEqual(str(s), 'ENTRYPOINT ["a"]') @singularity def test_multiple_singularity(self): """List of commands specified""" cmds = ['a arga', 'b argb', 'c'] s = runscript(commands=cmds) self.assertEqual(str(s), '%runscript\n a arga\n b argb\n exec c') @singularity def test_apprun_multiple_singularity(self): """List of commands specified""" cmds = ['a', 'b', 'c'] s = runscript(commands=cmds, _app='foo') self.assertEqual(str(s), '%apprun foo\n a\n b\n exec c') @docker def test_apprun_docker(self): """apprun not implemented in Docker""" cmds = ['a', 'b', 'c'] s = runscript(commands=cmds, _app='foo') self.assertEqual(str(s), 'ENTRYPOINT ["a"]') @singularity def test_multiple_noexec_singularity(self): """exec option""" cmds = ['a', 'b', 'c'] s = runscript(commands=cmds, _exec=False) self.assertEqual(str(s), '%runscript\n a\n b\n c') @docker def test_merge_docker(self): """merge primitives""" r = [] r.append(runscript(commands=['a', 'b'])) r.append(runscript(commands=['c'])) merged = r[0].merge(r) self.assertEqual(str(merged), 'ENTRYPOINT ["a"]') @singularity def test_merge_singularity(self): """merge primitives""" r = [] r.append(runscript(commands=['a', 'b'])) r.append(runscript(commands=['c'])) merged = r[0].merge(r) self.assertEqual(str(merged), '%runscript\n a\n b\n exec c') @bash def test_bash(self): """Single command specified""" cmd = ['z'] s = runscript(commands=cmd) self.assertEqual(str(s), '')
hpc-container-maker-master
test/test_runscript.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the environment module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import bash, docker, invalid_ctype, singularity from hpccm.primitives.environment import environment class Test_environment(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @docker def test_empty(self): """No environment specified""" e = environment() self.assertEqual(str(e), '') @invalid_ctype def test_invalid_ctype(self): """Invalid container type specified""" e = environment(variables={'A': 'B'}) with self.assertRaises(RuntimeError): str(e) @docker def test_single_docker(self): """Single environment variable specified""" e = environment(variables={'A': 'B'}, _export=False) self.assertEqual(str(e), 'ENV A=B') @singularity def test_single_singularity(self): """Single environment variable specified""" e = environment(variables={'A': 'B'}, _export=False) self.assertEqual(str(e), '%environment\n export A=B') @bash def test_single_bash(self): """Single environment variable specified""" e = environment(variables={'A': 'B'}, _export=False) self.assertEqual(str(e), 'export A=B') @docker def test_single_export_docker(self): """Single environment variable specified""" e = environment(variables={'A': 'B'}) self.assertEqual(str(e), 'ENV A=B') @singularity def test_single_export_singularity(self): """Single environment variable specified""" e = environment(variables={'A': 'B'}) self.assertEqual(str(e), '%environment\n export A=B\n%post\n export A=B') @bash def test_single_export_bash(self): """Single environment variable specified""" e = environment(variables={'A': 'B'}) self.assertEqual(str(e), 'export A=B') @docker def test_multiple_docker(self): """Multiple environment variables specified""" e = environment(variables={'ONE': 1, 'TWO': 2, 'THREE': 3}, _export=False) self.assertEqual(str(e), '''ENV ONE=1 \\ THREE=3 \\ TWO=2''') @singularity def test_multiple_singularity(self): """Multiple environment variables specified""" e = environment(variables={'ONE': 1, 'TWO': 2, 'THREE': 3}, _export=False) self.assertEqual(str(e), '''%environment export ONE=1 export THREE=3 export TWO=2''') @bash def test_multiple_bash(self): """Multiple environment variables specified""" e = environment(variables={'ONE': 1, 'TWO': 2, 'THREE': 3}, _export=False) self.assertEqual(str(e), '''export ONE=1 export THREE=3 export TWO=2''') @singularity def test_appenv_multiple_singularity(self): """Multiple app-specific environment variables specified""" e = environment(variables={'ONE': 1, 'TWO': 2, 'THREE': 3}, _app='foo') self.assertEqual(str(e), '''%appenv foo export ONE=1 export THREE=3 export TWO=2''') @docker def test_appenv_docker(self): """appenv not implemented in Docker""" e = environment(variables={'ONE': 1, 'TWO': 2, 'THREE': 3}, _app='foo') self.assertEqual(str(e), '''ENV ONE=1 \\ THREE=3 \\ TWO=2''') @docker def test_merge_docker(self): """merge primitives""" e = [] e.append(environment(variables={'ONE': 1, 'TWO': 2})) e.append(environment(variables={'THREE': 3})) merged = e[0].merge(e) self.assertEqual(str(merged), '''ENV ONE=1 \\ THREE=3 \\ TWO=2''') e.append(environment(variables={'ONE': 'uno'})) key_overwrite = e[0].merge(e) self.assertEqual(str(key_overwrite), '''ENV ONE=uno \\ THREE=3 \\ TWO=2''') @singularity def test_merge_singularity(self): """merge primitives""" e = [] e.append(environment(variables={'ONE': 1, 'TWO': 2})) e.append(environment(variables={'THREE': 3})) merged = e[0].merge(e) self.assertEqual(str(merged), '''%environment export ONE=1 export THREE=3 export TWO=2 %post export ONE=1 export THREE=3 export TWO=2''') e.append(environment(variables={'ONE': 'uno'})) key_overwrite = e[0].merge(e) self.assertEqual(str(key_overwrite), '''%environment export ONE=uno export THREE=3 export TWO=2 %post export ONE=uno export THREE=3 export TWO=2''')
hpc-container-maker-master
test/test_environment.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the openblas module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import aarch64, centos, docker, ppc64le, ubuntu, x86_64 from hpccm.building_blocks.openblas import openblas from hpccm.toolchain import toolchain class Test_openblas(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default openblas building block""" tc = toolchain(CC='gcc', FC='gfortran') o = openblas(toolchain=tc) self.assertEqual(str(o), r'''# OpenBLAS version 0.3.21 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/xianyi/OpenBLAS/archive/v0.3.21.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v0.3.21.tar.gz -C /var/tmp -z && \ cd /var/tmp/OpenBLAS-0.3.21 && \ make CC=gcc FC=gfortran USE_OPENMP=1 && \ mkdir -p /usr/local/openblas && \ cd /var/tmp/OpenBLAS-0.3.21 && \ make install PREFIX=/usr/local/openblas && \ rm -rf /var/tmp/OpenBLAS-0.3.21 /var/tmp/v0.3.21.tar.gz ENV LD_LIBRARY_PATH=/usr/local/openblas/lib:$LD_LIBRARY_PATH''') @x86_64 @ubuntu @docker def test_ldconfig(self): """ldconfig option""" tc = toolchain(CC='gcc', FC='gfortran') o = openblas(ldconfig=True, toolchain=tc, version='0.3.3') self.assertEqual(str(o), r'''# OpenBLAS version 0.3.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/xianyi/OpenBLAS/archive/v0.3.3.tar.gz && \ mkdir -p /var/tmp && tar -x -f /var/tmp/v0.3.3.tar.gz -C /var/tmp -z && \ cd /var/tmp/OpenBLAS-0.3.3 && \ make CC=gcc FC=gfortran USE_OPENMP=1 && \ mkdir -p /usr/local/openblas && \ cd /var/tmp/OpenBLAS-0.3.3 && \ make install PREFIX=/usr/local/openblas && \ echo "/usr/local/openblas/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/OpenBLAS-0.3.3 /var/tmp/v0.3.3.tar.gz''') @aarch64 @ubuntu @docker def test_aarch64(self): """Default openblas building block""" o = openblas(version='0.3.6') self.assertEqual(str(o), r'''# OpenBLAS version 0.3.6 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* 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 TARGET=ARMV8 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 ENV LD_LIBRARY_PATH=/usr/local/openblas/lib:$LD_LIBRARY_PATH''') @ppc64le @ubuntu @docker def test_ppc64le(self): """Default openblas building block""" o = openblas(version='0.3.6') self.assertEqual(str(o), r'''# OpenBLAS version 0.3.6 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ make \ perl \ tar \ wget && \ rm -rf /var/lib/apt/lists/* 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 TARGET=POWER8 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 ENV LD_LIBRARY_PATH=/usr/local/openblas/lib:$LD_LIBRARY_PATH''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" o = openblas() r = o.runtime() self.assertEqual(r, r'''# OpenBLAS COPY --from=0 /usr/local/openblas /usr/local/openblas ENV LD_LIBRARY_PATH=/usr/local/openblas/lib:$LD_LIBRARY_PATH''')
hpc-container-maker-master
test/test_openblas.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods, bad-continuation """Test cases for the libsim module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import centos, docker, ubuntu, x86_64 from hpccm.building_blocks.libsim import libsim class Test_libsim(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @x86_64 @ubuntu @docker def test_defaults_ubuntu(self): """Default libsim building block""" l = libsim() self.assertEqual(str(l), r'''# VisIt libsim version 2.13.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ gzip \ libgl1-mesa-dev \ libglu1-mesa-dev \ libxt-dev \ make \ patch \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp/visit && wget -q -nc --no-check-certificate -P /var/tmp/visit http://portal.nersc.gov/project/visit/releases/2.13.3/build_visit2_13_3 && \ mkdir -p /usr/local/visit/third-party && \ cd /var/tmp/visit && PAR_COMPILER=mpicc bash build_visit2_13_3 --xdb --server-components-only --parallel --no-icet --makeflags -j$(nproc) --prefix /usr/local/visit --system-cmake --system-python --thirdparty-path /usr/local/visit/third-party && \ rm -rf /var/tmp/visit ENV LD_LIBRARY_PATH=/usr/local/visit/2.13.3/linux-x86_64/lib:/usr/local/visit/2.13.3/linux-x86_64/libsim/V2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/visit/bin:$PATH''') @x86_64 @centos @docker def test_defaults_centos(self): """Default libsim building block""" l = libsim() self.assertEqual(str(l), r'''# VisIt libsim version 2.13.3 RUN yum install -y \ gzip \ libXt-devel \ libglvnd-devel \ make \ mesa-libGL-devel \ mesa-libGLU-devel \ patch \ tar \ wget \ which \ zlib-devel && \ rm -rf /var/cache/yum/* RUN mkdir -p /var/tmp/visit && wget -q -nc --no-check-certificate -P /var/tmp/visit http://portal.nersc.gov/project/visit/releases/2.13.3/build_visit2_13_3 && \ mkdir -p /usr/local/visit/third-party && \ cd /var/tmp/visit && PAR_COMPILER=mpicc bash build_visit2_13_3 --xdb --server-components-only --parallel --no-icet --makeflags -j$(nproc) --prefix /usr/local/visit --system-cmake --system-python --thirdparty-path /usr/local/visit/third-party && \ rm -rf /var/tmp/visit ENV LD_LIBRARY_PATH=/usr/local/visit/2.13.3/linux-x86_64/lib:/usr/local/visit/2.13.3/linux-x86_64/libsim/V2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/visit/bin:$PATH''') @x86_64 @ubuntu @docker def test_ldconfig(self): """ldconfig option""" l = libsim(ldconfig=True, version='2.13.3') self.assertEqual(str(l), r'''# VisIt libsim version 2.13.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ gzip \ libgl1-mesa-dev \ libglu1-mesa-dev \ libxt-dev \ make \ patch \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp/visit && wget -q -nc --no-check-certificate -P /var/tmp/visit http://portal.nersc.gov/project/visit/releases/2.13.3/build_visit2_13_3 && \ mkdir -p /usr/local/visit/third-party && \ cd /var/tmp/visit && PAR_COMPILER=mpicc bash build_visit2_13_3 --xdb --server-components-only --parallel --no-icet --makeflags -j$(nproc) --prefix /usr/local/visit --system-cmake --system-python --thirdparty-path /usr/local/visit/third-party && \ echo "/usr/local/visit/2.13.3/linux-x86_64/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ echo "/usr/local/visit/2.13.3/linux-x86_64/libsim/V2/lib" >> /etc/ld.so.conf.d/hpccm.conf && ldconfig && \ rm -rf /var/tmp/visit ENV PATH=/usr/local/visit/bin:$PATH''') @x86_64 @ubuntu @docker def test_non_default_opts(self): """non-default options""" l = libsim(mpi=False, system_cmake=False, system_python=False, thirdparty=False, version='2.13.3') self.assertEqual(str(l), r'''# VisIt libsim version 2.13.3 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ gzip \ libgl1-mesa-dev \ libglu1-mesa-dev \ libxt-dev \ make \ patch \ tar \ wget \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/tmp/visit && wget -q -nc --no-check-certificate -P /var/tmp/visit http://portal.nersc.gov/project/visit/releases/2.13.3/build_visit2_13_3 && \ cd /var/tmp/visit && bash build_visit2_13_3 --xdb --server-components-only --makeflags -j$(nproc) --prefix /usr/local/visit && \ rm -rf /var/tmp/visit ENV LD_LIBRARY_PATH=/usr/local/visit/2.13.3/linux-x86_64/lib:/usr/local/visit/2.13.3/linux-x86_64/libsim/V2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/visit/bin:$PATH''') @x86_64 @ubuntu @docker def test_runtime(self): """Runtime""" l = libsim() r = l.runtime() self.assertEqual(r, r'''# VisIt libsim RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libgl1-mesa-glx \ libglu1-mesa \ libxt6 \ zlib1g && \ rm -rf /var/lib/apt/lists/* COPY --from=0 /usr/local/visit /usr/local/visit ENV LD_LIBRARY_PATH=/usr/local/visit/2.13.3/linux-x86_64/lib:/usr/local/visit/2.13.3/linux-x86_64/libsim/V2/lib:$LD_LIBRARY_PATH \ PATH=/usr/local/visit/bin:$PATH''')
hpc-container-maker-master
test/test_libsim.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Test cases for the apt_get module""" from __future__ import unicode_literals from __future__ import print_function import logging # pylint: disable=unused-import import unittest from helpers import docker, ubuntu from hpccm.building_blocks.apt_get import apt_get class Test_apt_get(unittest.TestCase): def setUp(self): """Disable logging output messages""" logging.disable(logging.ERROR) @ubuntu @docker def test_basic(self): """Basic apt_get""" a = apt_get(ospackages=['gcc', 'g++', 'gfortran']) self.assertEqual(str(a), r'''RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ g++ \ gcc \ gfortran && \ rm -rf /var/lib/apt/lists/*''') @ubuntu @docker def test_add_repo(self): """Add repo and key""" a = apt_get(keys=['https://www.example.com/key.pub'], ospackages=['example'], repositories=['deb http://www.example.com all main']) self.assertEqual(str(a), r'''RUN wget -qO - https://www.example.com/key.pub | apt-key add - && \ echo "deb http://www.example.com all main" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ example && \ rm -rf /var/lib/apt/lists/*''') @ubuntu @docker def test_add_repo_signed_by(self): """Add repo and key, using the signed-by method rather than apt-key""" a = apt_get(_apt_key=False, keys=['https://www.example.com/key.pub'], ospackages=['example'], repositories=['deb [signed-by=/usr/share/keyrings/key.gpg] http://www.example.com all main']) self.assertEqual(str(a), r'''RUN mkdir -p /usr/share/keyrings && \ rm -f /usr/share/keyrings/key.gpg && \ wget -qO - https://www.example.com/key.pub | gpg --dearmor -o /usr/share/keyrings/key.gpg && \ echo "deb [signed-by=/usr/share/keyrings/key.gpg] http://www.example.com all main" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ example && \ rm -rf /var/lib/apt/lists/*''') @ubuntu @docker def test_download(self): """Download parameter""" a = apt_get(download=True, download_directory='/tmp/download', ospackages=['libibverbs1']) self.assertEqual(str(a), r'''RUN apt-get update -y && \ mkdir -m 777 -p /tmp/download && cd /tmp/download && \ DEBIAN_FRONTEND=noninteractive apt-get download -y --no-install-recommends \ libibverbs1 && \ rm -rf /var/lib/apt/lists/*''') @ubuntu @docker def test_extract(self): """Extract parameter""" a = apt_get(download=True, extract='/usr/local/ofed', ospackages=['libibverbs1']) self.assertEqual(str(a), r'''RUN apt-get update -y && \ mkdir -m 777 -p /var/tmp/apt_get_download && cd /var/tmp/apt_get_download && \ DEBIAN_FRONTEND=noninteractive apt-get download -y --no-install-recommends \ libibverbs1 && \ mkdir -p /usr/local/ofed && \ find /var/tmp/apt_get_download -regextype posix-extended -type f -regex "/var/tmp/apt_get_download/(libibverbs1).*deb" -exec dpkg --extract {} /usr/local/ofed \; && \ rm -rf /var/tmp/apt_get_download && \ rm -rf /var/lib/apt/lists/*''')
hpc-container-maker-master
test/test_apt_get.py
""" HPC Base image Contents: CUDA version 10.1 FFTW version 3.3.8 GNU compilers (upstream) HDF5 version 1.10.5 Mellanox OFED version 4.6-1.0.1.1 MVAPICH version 2.3.2 Python 2 and 3 (upstream) """ # pylint: disable=invalid-name, undefined-variable, used-before-assignment # Choose between either Ubuntu 16.04 (default) or CentOS 7 # Add '--userarg centos=true' to the command line to select CentOS devel_image = 'nvcr.io/nvidia/cuda:10.1-devel-ubuntu16.04' runtime_image = 'nvcr.io/nvidia/cuda:10.1-runtime-ubuntu16.04' if USERARG.get('centos', False): devel_image = 'nvcr.io/nvidia/cuda:10.1-devel-centos7' runtime_image = 'nvcr.io/nvidia/cuda:10.1-runtime-centos7' ###### # Devel stage ###### Stage0 += comment(__doc__, reformat=False) Stage0 += baseimage(image=devel_image, _as='devel') # Python Stage0 += python() # GNU compilers compiler = gnu() Stage0 += compiler # Mellanox OFED Stage0 += mlnx_ofed(version='4.6-1.0.1.1') # MVAPICH2 Stage0 += mvapich2(version='2.3.2', toolchain=compiler.toolchain) # FFTW Stage0 += fftw(version='3.3.8', mpi=True, toolchain=compiler.toolchain) # HDF5 Stage0 += hdf5(version='1.10.5', toolchain=compiler.toolchain) ###### # Runtime image ###### Stage1 += baseimage(image=runtime_image) Stage1 += Stage0.runtime(_from='devel')
hpc-container-maker-master
recipes/hpcbase-gnu-mvapich2.py
""" HPC Base image Contents: FFTW version 3.3.8 HDF5 version 1.10.6 Mellanox OFED version 5.0-2.1.8.0 NVIDIA HPC SDK version 20.7 OpenMPI version 4.0.4 Python 2 and 3 (upstream) """ # pylint: disable=invalid-name, undefined-variable, used-before-assignment # The NVIDIA HPC SDK End-User License Agreement must be accepted. # https://docs.nvidia.com/hpc-sdk/eula nvhpc_eula=False if USERARG.get('nvhpc_eula_accept', False): nvhpc_eula=True else: raise RuntimeError('NVIDIA HPC SDK EULA not accepted. To accept, use "--userarg nvhpc_eula_accept=yes"\nSee NVIDIA HPC SDK EULA at https://docs.nvidia.com/hpc-sdk/eula') # Choose between either Ubuntu 18.04 (default) or RockyLinux 8 # Add '--userarg rockylinux=true' to the command line to select RockyLinux image = 'ubuntu:18.04' if USERARG.get('rockylinux', False): image = 'rockylinux:8' ###### # Devel stage ###### Stage0 += comment(__doc__, reformat=False) Stage0 += baseimage(image=image, _as='devel') # Python Stage0 += python() # NVIDIA HPC SDK compiler = nvhpc(eula=nvhpc_eula, mpi=False, redist=['compilers/lib/*'], version='20.7') compiler.toolchain.CUDA_HOME = '/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/cuda' Stage0 += compiler # Mellanox OFED Stage0 += mlnx_ofed(version='5.0-2.1.8.0') # OpenMPI Stage0 += openmpi(version='4.0.4', toolchain=compiler.toolchain) # FFTW Stage0 += fftw(version='3.3.8', mpi=True, toolchain=compiler.toolchain) # HDF5 Stage0 += hdf5(version='1.10.6', toolchain=compiler.toolchain) # nvidia-container-runtime Stage0 += environment(variables={ 'NVIDIA_VISIBLE_DEVICES': 'all', 'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility', 'NVIDIA_REQUIRE_CUDA': '"cuda>=10.1 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411"'}) ###### # Runtime image ###### Stage1 += baseimage(image=image) Stage1 += Stage0.runtime(_from='devel') # nvidia-container-runtime Stage0 += environment(variables={ 'NVIDIA_VISIBLE_DEVICES': 'all', 'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility', 'NVIDIA_REQUIRE_CUDA': '"cuda>=10.1 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411"'})
hpc-container-maker-master
recipes/hpcbase-nvhpc-openmpi.py
""" Recipe for a NVIDIA HPC SDK container and typical development environment. $ hpccm --recipe nvhpc.py --userarg eula=yes $ hpccm --recipe nvhpc.py --userarg eula=yes cuda_multi=no arch=x86_64 """ from distutils.version import StrictVersion import platform # Verify correct version of HPCCM is used if StrictVersion(hpccm.__version__) < StrictVersion('21.7.0'): raise RuntimeError('requires HPCCM version 21.7.0 or later') arch = USERARG.get('arch', platform.machine()) image = USERARG.get('image', 'ubuntu:20.04') version = USERARG.get('version', '21.7') release = '20' + version[:2] default_cuda = '11.4' cuda_multi=True if USERARG.get('cuda_multi', False) in [0, '0', 'no', 'false']: cuda_multi=False # The NVIDIA HPC SDK End-User License Agreement must be accepted. # https://docs.nvidia.com/hpc-sdk/eula eula=False if USERARG.get('eula', False) in [1, '1', 'yes', 'true']: eula=True else: raise RuntimeError('NVIDIA HPC SDK EULA not accepted. To accept, use "--userarg eula=yes"\nSee NVIDIA HPC SDK EULA at https://docs.nvidia.com/hpc-sdk/eula') if cuda_multi is True: # CUDA 10.2, 11.0, 11.4 cuda_driver = '"cuda>=10.2"' else: # CUDA 11.4 only, but enhanced forward compatibility means 11.2 is # sufficient cuda_driver = '"cuda>=11.2"' Stage0 += baseimage(image=image, _arch=arch) # Typical development environment common_packages = ['automake', 'autoconf', 'autoconf-archive', 'binutils', 'bzip2', 'ca-certificates', 'cmake', 'diffutils', 'file', 'gdb', 'git', 'gzip', 'libtool', 'make', 'patch', 'tar', 'vim', 'wget'] Stage0 += packages(apt=common_packages + ['libaec-dev', 'libncursesw5', 'libsz2', 'libtinfo5', 'lmod', 'xz-utils', 'zlib1g-dev'], epel=True, yum=common_packages + ['Lmod', 'libaec-devel', 'xz', 'zlib-devel']) # Mellanox OFED Stage0 += mlnx_ofed(version='5.2-2.2.0.0') # NVIDIA HPC SDK Stage0 += nvhpc(cuda=default_cuda, cuda_multi=cuda_multi, eula=eula, _hpcx=True, mpi=False, version=version) # Container metadata Stage0 += environment(variables={'HPCSDK_VERSION': version, 'HPCSDK_RELEASE': release}) Stage0 += label( metadata={'com.nvidia.hpcsdk.version': '"{}"'.format(version), 'com.nvidia.hpcsdk.release': '"{}"'.format(release)}) # nvidia-container-runtime and enroot Stage0 += environment(variables={ 'MELLANOX_VISIBLE_DEVICES': 'all', # enroot 'NVIDIA_VISIBLE_DEVICES': 'all', 'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility', 'NVIDIA_REQUIRE_CUDA': cuda_driver})
hpc-container-maker-master
recipes/nvhpc.py
"""Spack container (https://github.com/spack/spack) Set the user argument 'package' to specify the Spack package to install. Otherwise, it will just build a base Spack container image. Sample workflow: $ hpccm.py --recipe recipes/spack.py --userarg package="[email protected] +cuda" > Dockerfile.gromacs.spack $ docker build -t gromacs.spack -f Dockerfile.gromacs.spack . $ nvidia-docker run --rm -ti gromacs.spack bash -l container:/> spack load gromacs """ # pylint: disable=invalid-name, undefined-variable, used-before-assignment from hpccm.templates.git import git spack_branch = 'develop' Stage0 += comment(__doc__, reformat=False) Stage0 += baseimage(image='ubuntu:16.04') # Base dependencies Stage0 += python() Stage0 += gnu() # Additional dependencies ospackages = ['autoconf', 'build-essential', 'bzip2', 'ca-certificates', 'coreutils', 'curl', 'environment-modules', 'git', 'gzip', 'libssl-dev', 'make', 'openssh-client', 'patch', 'pkg-config', 'tcl', 'tar', 'unzip', 'zlib1g'] Stage0 += apt_get(ospackages=ospackages) # Setup and install Spack Stage0 += shell(commands=[ git().clone_step(repository='https://github.com/spack/spack', branch=spack_branch, path='/opt'), 'ln -s /opt/spack/share/spack/setup-env.sh /etc/profile.d/spack.sh', 'ln -s /opt/spack/share/spack/spack-completion.bash /etc/profile.d']) Stage0 += environment(variables={'PATH': '/opt/spack/bin:$PATH', 'FORCE_UNSAFE_CONFIGURE': '1'}) spack_package = USERARG.get('package', None) if spack_package: Stage0 += shell(commands=['spack install {}'.format(spack_package), 'spack clean --all'])
hpc-container-maker-master
recipes/spack.py
""" HPC Base image Contents: CUDA version 10.1 FFTW version 3.3.8 GNU compilers (upstream) HDF5 version 1.10.5 Mellanox OFED version 4.6-1.0.1.1 OpenMPI version 4.0.2 Python 2 and 3 (upstream) """ # pylint: disable=invalid-name, undefined-variable, used-before-assignment # Choose between either Ubuntu 16.04 (default) or CentOS 7 # Add '--userarg centos=true' to the command line to select CentOS devel_image = 'nvcr.io/nvidia/cuda:10.1-devel-ubuntu16.04' runtime_image = 'nvcr.io/nvidia/cuda:10.1-runtime-ubuntu16.04' if USERARG.get('centos', False): devel_image = 'nvcr.io/nvidia/cuda:10.1-devel-centos7' runtime_image = 'nvcr.io/nvidia/cuda:10.1-runtime-centos7' ###### # Devel stage ###### Stage0 += comment(__doc__, reformat=False) Stage0 += baseimage(image=devel_image, _as='devel') # Python Stage0 += python() # GNU compilers compiler = gnu() Stage0 += compiler # Mellanox OFED Stage0 += mlnx_ofed(version='4.6-1.0.1.1') # OpenMPI Stage0 += openmpi(version='4.0.2', toolchain=compiler.toolchain) # FFTW Stage0 += fftw(version='3.3.8', mpi=True, toolchain=compiler.toolchain) # HDF5 Stage0 += hdf5(version='1.10.5', toolchain=compiler.toolchain) ###### # Runtime image ###### Stage1 += baseimage(image=runtime_image) Stage1 += Stage0.runtime(_from='devel')
hpc-container-maker-master
recipes/hpcbase-gnu-openmpi.py
""" HPC Base image Contents: FFTW version 3.3.8 HDF5 version 1.10.6 Mellanox OFED version 5.0-2.1.8.0 MVAPICH version 2.3.3 NVIDIA HPC SDK version 20.7 Python 2 and 3 (upstream) """ # pylint: disable=invalid-name, undefined-variable, used-before-assignment # The NVIDIA HPC SDK End-User License Agreement must be accepted. # https://docs.nvidia.com/hpc-sdk/eula nvhpc_eula=False if USERARG.get('nvhpc_eula_accept', False): nvhpc_eula=True else: raise RuntimeError('NVIDIA HPC SDK EULA not accepted. To accept, use "--userarg nvhpc_eula_accept=yes"\nSee NVIDIA HPC SDK EULA at https://docs.nvidia.com/hpc-sdk/eula') # Choose between either Ubuntu 18.04 (default) or RockyLinux 8 # Add '--userarg rockylinux=true' to the command line to select RockyLinux image = 'ubuntu:18.04' if USERARG.get('rockylinux', False): image = 'rockylinux:8' ###### # Devel stage ###### Stage0 += comment(__doc__, reformat=False) Stage0 += baseimage(image=image, _as='devel') # Python Stage0 += python() # NVIDIA HPC SDK compiler = nvhpc(eula=nvhpc_eula, mpi=False, redist=['compilers/lib/*'], version='20.7') Stage0 += compiler # Mellanox OFED Stage0 += mlnx_ofed(version='5.0-2.1.8.0') # MVAPICH2 Stage0 += mvapich2(cuda=False, version='2.3.3', toolchain=compiler.toolchain) # FFTW Stage0 += fftw(version='3.3.8', mpi=True, toolchain=compiler.toolchain) # HDF5 Stage0 += hdf5(version='1.10.6', toolchain=compiler.toolchain) # nvidia-container-runtime Stage0 += environment(variables={ 'NVIDIA_VISIBLE_DEVICES': 'all', 'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility', 'NVIDIA_REQUIRE_CUDA': '"cuda>=10.1 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411"'}) ###### # Runtime image ###### Stage1 += baseimage(image=image) Stage1 += Stage0.runtime(_from='devel') # nvidia-container-runtime Stage0 += environment(variables={ 'NVIDIA_VISIBLE_DEVICES': 'all', 'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility', 'NVIDIA_REQUIRE_CUDA': '"cuda>=10.1 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411"'})
hpc-container-maker-master
recipes/hpcbase-nvhpc-mvapich2.py
""" MPI Bandwidth Contents: CentOS 7 GNU compilers (upstream) Mellanox OFED OpenMPI PMI2 (SLURM) UCX Building: 1. Docker to Singularity $ hpccm --recipe mpi_bandwidth.py > Dockerfile $ sudo docker build -t mpi_bw -f Dockerfile . $ singularity build mpi_bw.sif docker-daemon://mpi_bw:latest 2. Singularity $ hpccm --recipe mpi_bandwidth.py --format singularity --singularity-version=3.2 > Singularity.def $ sudo singularity build mpi_bw.sif Singularity.def Running with Singularity: 1. Using a compatible host MPI runtime $ mpirun -n 2 singularity run mpi_bw.sif mpi_bandwidth 2. Using the MPI runtime inside the container $ singularity run mpi_bw.sif mpirun -n 2 -H node1:1,node2:1 --launch-agent "singularity exec \$SINGULARITY_CONTAINER orted" mpi_bandwidth 3. Using SLURM srun $ srun -n 2 --mpi=pmi2 singularity run mpi_bw.sif mpi_bandwidth """ Stage0 += comment(__doc__, reformat=False) # CentOS base image Stage0 += baseimage(image='centos:7', _as='build') # GNU compilers Stage0 += gnu(fortran=False) # Mellanox OFED Stage0 += mlnx_ofed() # UCX Stage0 += ucx(cuda=False) # PMI2 Stage0 += slurm_pmi2() # OpenMPI (use UCX instead of IB directly) Stage0 += openmpi(cuda=False, infiniband=False, pmi='/usr/local/slurm-pmi2', ucx='/usr/local/ucx') # MPI Bandwidth Stage0 += shell(commands=[ 'wget -q -nc --no-check-certificate -P /var/tmp https://hpc-tutorials.llnl.gov/mpi/examples/mpi_bandwidth.c', 'mpicc -o /usr/local/bin/mpi_bandwidth /var/tmp/mpi_bandwidth.c']) ### Runtime distributable stage Stage1 += baseimage(image='centos:7') Stage1 += Stage0.runtime() Stage1 += copy(_from='build', src='/usr/local/bin/mpi_bandwidth', dest='/usr/local/bin/mpi_bandwidth')
hpc-container-maker-master
recipes/mpi_bandwidth.py
"""EasyBuild container (https://github.com/easybuilders/easybuild) Set the user argument 'easyconfig' to specify the EasyConfig to build. Otherwise, it will just build a base EasyBuild container image. Sample workflow: $ hpccm.py --recipe recipes/easybuild.py --userarg easyconfig=GROMACS-2019.3-fosscuda-2019b.eb > Dockerfile.gromacs.eb $ docker build -t gromacs.eb -f Dockerfile.gromacs.eb . $ nvidia-docker run --rm -ti gromacs.eb bash -l container:/tmp> module load GROMACS ... """ # pylint: disable=invalid-name, undefined-variable, used-before-assignment import os Stage0 += comment(__doc__, reformat=False) Stage0 += baseimage(image='rockylinux:8') Stage0 += shell(commands=['yum update -y rocky-release', 'rm -rf /var/cache/yum/*']) # Base dependencies Stage0 += python(python3=False) Stage0 += gnu() Stage0 += ofed() Stage0 += packages(epel=True, powertools=True, yum=['bzip2', 'diffutils', 'file', 'git', 'gzip', 'libtool', 'Lmod', 'make', 'openssh-clients', 'openssl-devel', 'patch', 'rsh', 'tar', 'unzip', 'which', 'xz']) # Setup and install EasyBuild Stage0 += pip(packages=['easybuild'], pip='pip2') Stage0 += shell(commands=['useradd -m easybuild', 'mkdir -p /opt/easybuild', 'chown easybuild:easybuild /opt/easybuild']) # Module environment Stage0 += environment(variables={'MODULEPATH': '/opt/easybuild/modules/all:/home/easybuild/.local/easybuild/modules/all:$MODULEPATH'}) easyconfig = USERARG.get('easyconfig', None) if easyconfig: # If the easyconfig is a file in the local build context, inject it # into the container image if os.path.isfile(easyconfig): Stage0 += copy(src=easyconfig, dest='/home/easybuild') Stage0 += shell(commands=['runuser easybuild -l -c "eb {} -r --installpath /opt/easybuild"'.format(easyconfig)])
hpc-container-maker-master
recipes/easybuild.py
# Generic recipe to build a OFED+UCX+MPI+CUDA container environment # that supports both OFED 4.x and 5.x. # Development stage Stage0 += baseimage(image='nvcr.io/nvidia/cuda:11.0-devel-ubuntu18.04', _as='devel') # Compiler Stage0 += gnu() # Communication libraries Stage0 += gdrcopy(ldconfig=True) Stage0 += knem(ldconfig=True) # Mellanox legacy OFED support mlnx_versions=['4.2-1.5.1.0', '4.3-1.0.1.0', '4.4-1.0.0.0', '4.5-1.0.1.0', '4.6-1.0.1.1', '4.7-3.2.9.0', '4.9-0.1.7.0'] Stage0 += multi_ofed(inbox=False, mlnx_versions=mlnx_versions, prefix="/usr/local/ofed", symlink=False) # RDMA-core based OFED support Stage0 += mlnx_ofed(version="5.2-2.2.0.0", symlink=False) # UCX default - RDMA-core based OFED Stage0 += ucx(version='1.10.0', cuda=True, gdrcopy='/usr/local/gdrcopy', knem='/usr/local/knem', disable_static=True, enable_mt=True) # UCX - Mellanox legacy support Stage0 += ucx(version='1.10.0', build_environment={ "LD_LIBRARY_PATH": "/usr/local/ofed/4.6-1.0.1.1/lib:${LD_LIBRARY_PATH}"}, cuda=True, environment=False, gdrcopy='/usr/local/gdrcopy', knem='/usr/local/knem', prefix='/usr/local/ucx-mlnx-legacy', disable_static=True, enable_mt=True, with_verbs='/usr/local/ofed/4.6-1.0.1.1/usr', with_rdmacm='/usr/local/ofed/4.6-1.0.1.1/usr') # Symlink legacy UCX into legacy OFED versions Stage0 += shell(commands=[ 'ln -s /usr/local/ucx-mlnx-legacy/{1}/* /usr/local/ofed/{0}/usr/{1}'.format(version, directory) for version in mlnx_versions for directory in ['bin', 'lib']]) # PMI2 support Stage0 += slurm_pmi2(prefix="/usr/local/pmi", version='20.11.9') # OpenMPI Stage0 += openmpi(cuda=True, infiniband=False, ldconfig=True, ucx=True, version='4.0.5', disable_oshmem=True, disable_static=True, enable_mca_no_build='btl-uct', with_slurm=False, with_pmi='/usr/local/pmi') # Deployment stage Stage1 += baseimage(image='nvcr.io/nvidia/cuda:11.0-base-ubuntu18.04') Stage1 += Stage0.runtime(_from='devel') # Allow running MPI as root Stage1 += environment(variables={'OMPI_ALLOW_RUN_AS_ROOT': '1', 'OMPI_ALLOW_RUN_AS_ROOT_CONFIRM': '1'}) # Entrypoint Stage1 += copy(src='entrypoint.sh', dest='/usr/local/bin/entrypoint.sh') Stage1 += runscript(commands=['/usr/local/bin/entrypoint.sh']) # Performance and compatibility tuning Stage1 += environment(variables={'CUDA_CACHE_DISABLE': '1', 'MELLANOX_VISIBLE_DEVICES': 'all', # enroot 'OMPI_MCA_pml': 'ucx'})
hpc-container-maker-master
recipes/osu_benchmarks/common.py
# Use the generic OFED+UCX+OpenMPI recipe hpccm.include('common.py') # Build the OSU Micro-Benchmarks in the development stage Stage0 += generic_autotools( build_environment={'CC': 'mpicc', 'CXX': 'mpicxx'}, enable_cuda=True, prefix='/usr/local/osu', url='http://mvapich.cse.ohio-state.edu/download/mvapich/osu-micro-benchmarks-5.7.tar.gz', with_cuda='/usr/local/cuda') # Copy the OSU Micro-Benchmark binaries into the deployment stage Stage1 += copy(_from='devel', src='/usr/local/osu', dest='/usr/local/osu') # Add the OSU Micro-Benchmarks to the default PATH base_path = '/usr/local/osu/libexec/osu-micro-benchmarks' Stage1 += environment(variables={'PATH': '{0}:{0}/mpi/collective:{0}/mpi/one-sided:{0}/mpi/pt2pt:{0}/mpi/startup:$PATH'.format(base_path)})
hpc-container-maker-master
recipes/osu_benchmarks/osu_benchmarks.py
""" MILC 7.8.1 Contents: Ubuntu 16.04 CUDA version 11.2 GNU compilers (upstream) OFED (upstream) OpenMPI version 3.1.4 QUDA version 0.8.0 """ # pylint: disable=invalid-name, undefined-variable, used-before-assignment # pylama: ignore=E0602 gpu_arch = USERARG.get('GPU_ARCH', 'sm_60') # add docstring to Dockerfile Stage0 += comment(__doc__.strip(), reformat=False) ############################################################################### # Devel stage ############################################################################### Stage0 += baseimage(image='nvcr.io/nvidia/cuda:11.2.0-devel-ubuntu18.04', _as='devel') Stage0 += gnu() Stage0 += cmake(eula=True) Stage0 += ofed() Stage0 += openmpi(version='3.1.4') # build QUDA Stage0 += packages(ospackages=['ca-certificates', 'git']) Stage0 += generic_cmake(branch='develop', cmake_opts=['-D CMAKE_BUILD_TYPE=RELEASE', '-D QUDA_DIRAC_CLOVER=ON', '-D QUDA_DIRAC_DOMAIN_WALL=ON', '-D QUDA_DIRAC_STAGGERED=ON', '-D QUDA_DIRAC_TWISTED_CLOVER=ON', '-D QUDA_DIRAC_TWISTED_MASS=ON', '-D QUDA_DIRAC_WILSON=ON', '-D QUDA_FORCE_GAUGE=ON', '-D QUDA_FORCE_HISQ=ON', '-D QUDA_GPU_ARCH={}'.format(gpu_arch), '-D QUDA_INTERFACE_MILC=ON', '-D QUDA_INTERFACE_QDP=ON', '-D QUDA_LINK_HISQ=ON', '-D QUDA_MPI=ON'], install=False, ldconfig=True, postinstall=['cp -a /var/tmp/quda/build/* /usr/local/quda'], preconfigure=['mkdir -p /usr/local/quda'], prefix='/usr/local/quda', repository='https://github.com/lattice/quda.git') # build MILC Stage0 += generic_build(branch='develop', build=['cp Makefile ks_imp_rhmc', 'cd ks_imp_rhmc', 'make -j 1 su3_rhmd_hisq \ CC=/usr/local/openmpi/bin/mpicc \ LD=/usr/local/openmpi/bin/mpicxx \ QUDA_HOME=/usr/local/quda \ WANTQUDA=true \ WANT_GPU=true \ WANT_CL_BCG_GPU=true \ WANT_FN_CG_GPU=true \ WANT_FL_GPU=true \ WANT_FF_GPU=true \ WANT_GF_GPU=true \ MPP=true \ PRECISION=2 \ WANTQIO=""'], install=['mkdir -p /usr/local/milc/bin', 'cp /var/tmp/milc_qcd/ks_imp_rhmc/su3_rhmd_hisq /usr/local/milc/bin'], prefix='/usr/local/milc', repository='https://github.com/milc-qcd/milc_qcd') Stage0 += environment(variables={'PATH': '/usr/local/milc/bin:$PATH'}) ############################################################################### # Release stage ############################################################################### Stage1 += baseimage(image='nvcr.io/nvidia/cuda:11.2.0-base-ubuntu18.04') Stage1 += packages(ospackages=['libcublas-11-2']) Stage1 += Stage0.runtime() Stage1 += environment(variables={'PATH': '/usr/local/milc/bin:$PATH'})
hpc-container-maker-master
recipes/milc/milc.py
r""" GROMACS 2020 Contents: Ubuntu 16.04 CUDA version 10.1 GNU compilers (upstream) OFED (upstream) OpenMPI version 3.1.4 """ gromacs_version = USERARG.get('gromacs', '2020') Stage0 += comment(__doc__.strip(), reformat=False) Stage0 += baseimage(image='nvcr.io/nvidia/cuda:10.1-devel-ubuntu16.04', _as='build') Stage0 += python(python3=False) Stage0 += gnu(fortran=False) Stage0 += cmake(eula=True) Stage0 += ofed() Stage0 += openmpi(version='3.1.4') Stage0 += generic_cmake(cmake_opts=['-D CMAKE_BUILD_TYPE=Release', '-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda', '-D GMX_BUILD_OWN_FFTW=ON', '-D GMX_GPU=ON', '-D GMX_MPI=ON', '-D GMX_OPENMP=ON', '-D GMX_PREFER_STATIC_LIBS=ON', '-D MPIEXEC_PREFLAGS=--allow-run-as-root'], prefix='/usr/local/gromacs', url='http://ftp.gromacs.org/pub/gromacs/gromacs-{}.tar.gz'.format(gromacs_version)) Stage0 += environment(variables={'PATH': '$PATH:/usr/local/gromacs/bin'}) Stage0 += label(metadata={'gromacs.version': gromacs_version}) ###### # Runtime image stage ###### Stage1 += baseimage(image='nvcr.io/nvidia/cuda:10.1-base-ubuntu16.04') Stage1 += packages(ospackages=['cuda-cufft-10-1']) Stage1 += Stage0.runtime(_from='build') Stage1 += environment(variables={'PATH': '$PATH:/usr/local/gromacs/bin'}) Stage1 += label(metadata={'gromacs.version': gromacs_version})
hpc-container-maker-master
recipes/gromacs/gromacs.py
"""This example demonstrates how to specify a multi-stage recipe. Usage: $ hpccm.py --recipe recipes/examples/multistage.py """ ###### # Devel stage ###### # Devel stage base image Stage0 += baseimage(image='nvcr.io/nvidia/cuda:9.0-devel-ubuntu16.04', _as='devel') # Install compilers (upstream) Stage0 += gnu() # Build FFTW using all default options Stage0 += fftw() ###### # Runtime stage ###### # Runtime stage base image Stage1 += baseimage(image='nvcr.io/nvidia/cuda:9.0-runtime-ubuntu16.04') # Copy the compiler runtime and FFTW from the devel stage and setup the # runtime environment. # The _from option is not necessary, but increases clarity. Stage1 += Stage0.runtime(_from='devel')
hpc-container-maker-master
recipes/examples/multistage.py
""" Basic development container image """ Stage0 += baseimage(image='ubuntu:18.04') # GNU compilers compiler = gnu() Stage0 += compiler # Additional development tools Stage0 += packages(ospackages=['autoconf', 'autoconf-archive', 'automake', 'bzip2', 'ca-certificates', 'cmake', 'git', 'gzip', 'libtool', 'make', 'patch', 'xz-utils'])
hpc-container-maker-master
recipes/examples/gnu-devel.py
"""This example demonstrates recipe basics. Usage: $ hpccm.py --recipe recipes/examples/basic.py --format docker # hpccm.py --recipe recipes/examples/basic.py --format singularity """ # Choose a base image Stage0 += baseimage(image='ubuntu:16.04') # Install GNU compilers (upstream) Stage0 += apt_get(ospackages=['gcc', 'g++', 'gfortran'])
hpc-container-maker-master
recipes/examples/basic.py
""" Demonstrate how to include a recipe in another recipe """ # the gnu-devel recipe file must be in the same directory hpccm.include('gnu-devel.py') Stage0 += generic_build(branch='v1.3', build=['make COMPILER=GNU'], install=['cp clover_leaf /usr/local/bin'], repository='https://github.com/UK-MAC/CloverLeaf_Serial.git')
hpc-container-maker-master
recipes/examples/cloverleaf.py
#!/usr/bin/env python """This example demonstrates importing hpccm in a Python script. Rather than using the hpccm command line tool to convert a recipe into a container specification, import hpccm directly. The script is responsible for handling user arguments, managing layers, and printing the output. Note: HPCCM must be installed via pip prior to using this script. Usage: $ python recipes/examples/script.py --help $ python recipes/examples/script.py --linux ubuntu $ python recipes/examples/script.py --format singularity """ from __future__ import unicode_literals from __future__ import print_function import argparse import hpccm ### Parse command line arguments parser = argparse.ArgumentParser(description='HPCCM example') parser.add_argument('--compiler', type=str, default='gnu', choices=['gnu', 'llvm', 'nvhpc'], help='Compiler choice (default: gnu)') parser.add_argument('--format', type=str, default='docker', choices=['docker', 'singularity'], help='Container specification format (default: docker)') parser.add_argument('--linux', type=str, default='centos', choices=['centos', 'ubuntu'], help='Linux distribution choice (default: centos)') parser.add_argument('--nvhpc_eula_accept', action='store_true', default=False, help='Accept PGI EULA (default: false)') args = parser.parse_args() ### Create Stage Stage0 = hpccm.Stage() ### Linux distribution if args.linux == 'centos': Stage0 += hpccm.primitives.baseimage(image='centos:7') elif args.linux == 'ubuntu': Stage0 += hpccm.primitives.baseimage(image='ubuntu:16.04') ### Compiler if args.compiler == 'gnu': Stage0 += hpccm.building_blocks.gnu() elif args.compiler == 'llvm': Stage0 += hpccm.building_blocks.llvm() elif args.compiler == 'nvhpc': if not args.nvhpc_eula_accept: print('EULA not accepted. To accept, use "--nvhpc_eula_accept".\n' 'See NVIDIA EULA at https://docs.nvidia.com/hpc-sdk/eula') exit(1) Stage0 += hpccm.building_blocks.nvhpc(eula=args.nvhpc_eula_accept) ### Set container specification output format hpccm.config.set_container_format(args.format) ### Output container specification print(Stage0)
hpc-container-maker-master
recipes/examples/script.py
""" Build the CUDA-STREAM benchmark for multiple CUDA compute capabilities. Make each build available as a SCI-F application. """ Stage0 += baseimage(image='nvcr.io/nvidia/cuda:9.1-devel-centos7', _as='devel') # Install the GNU compiler Stage0 += gnu(fortran=False) # Install SCI-F Stage0 += pip(packages=['scif'], upgrade=True) # Download a single copy of the source code Stage0 += packages(ospackages=['ca-certificates', 'git']) Stage0 += shell(commands=['cd /var/tmp', 'git clone --depth=1 https://github.com/bcumming/cuda-stream.git cuda-stream']) # Build CUDA-STREAM as a SCI-F application for each CUDA compute capability for cc in ['35', '60', '70']: binpath = '/scif/apps/cc{}/bin'.format(cc) stream = scif(name='cc{}'.format(cc)) stream += comment('CUDA-STREAM built for CUDA compute capability {}'.format(cc)) stream += shell(commands=['nvcc -std=c++11 -ccbin=g++ -gencode arch=compute_{0},code=\\"sm_{0},compute_{0}\\" -o {1}/stream /var/tmp/cuda-stream/stream.cu'.format(cc, binpath)]) stream += environment(variables={'PATH': '{}:$PATH'.format(binpath)}) stream += label(metadata={'COMPUTE_CAPABILITY': cc}) stream += shell(commands=['stream'], _test=True) stream += runscript(commands=['stream']) Stage0 += stream # Runtime stage Stage1 += baseimage(image='nvcr.io/nvidia/cuda:9.1-base-centos7') # Install SCI-F Stage1 += pip(packages=['scif'], upgrade=True) # Install runtime components from the first stage Stage1 += Stage0.runtime()
hpc-container-maker-master
recipes/examples/scif.py
"""This example demonstrates user arguments. The CUDA and OpenMPI versions can be specified on the command line. If they are not, then reasonable defaults are used. Note: no validation is performed on the user supplied information. Usage: $ hpccm.py --recipe recipes/examples/userargs.py --userarg cuda=9.0 ompi=2.1.2 """ # Set the image tag based on the specified version (default to 9.1) cuda_version = USERARG.get('cuda', '9.1') image = 'nvcr.io/nvidia/cuda:{}-devel-ubuntu16.04'.format(cuda_version) Stage0 += baseimage(image=image) # Set the OpenMPI version based on the specified version (default to 3.0.0) ompi_version = USERARG.get('ompi', '3.0.0') Stage0 += openmpi(infiniband=False, version=ompi_version)
hpc-container-maker-master
recipes/examples/userargs.py
""" Recipe for a HPC Container Maker (HPCCM) container image Docker: $ sudo docker build -t hpccm -f Dockerfile . $ sudo docker run --rm -v $(pwd):/recipes hpccm --recipe /recipes/... Singularity: $ sudo singularity build hpccm.simg Singularity.def $ ./hpccm.simg --recipe ... """ from hpccm.common import container_type Stage0 += comment(__doc__, reformat=False) Stage0 += baseimage(image='python:3-slim', _distro='ubuntu', _docker_env=False) Stage0 += shell(commands=['pip install --no-cache-dir hpccm'], chdir=False) if hpccm.config.g_ctype == container_type.DOCKER: # Docker automatically passes through command line arguments Stage0 += runscript(commands=['hpccm']) elif hpccm.config.g_ctype == container_type.SINGULARITY: # Singularity does not automatically pass through command line arguments Stage0 += runscript(commands=['hpccm $@'])
hpc-container-maker-master
recipes/hpccm/bootstrap.py
######## # LAMMPS recipe # # User arguments: # arch: x86_64 or aarch64 (default: x86_64) # build_image # gdrcopy (default: 1.3) # gpu_arch: Pascal60, Volta70, or Turing75 (default: Volta70) # knem (default: 1.1.3) # lammps_version (default: patch_19Sep2019) # mlnx_ofed (default: 4.6-1.0.1.1) # ompi (default: 4.0.2) # qemu (default: False) # runtime_image # ucx (default: 1.6.1) ######## from distutils.version import StrictVersion import hpccm.version if StrictVersion(hpccm.__version__) < StrictVersion('19.11.0'): raise Exception('requires HPCCM version 19.11.0 or later') # Use appropriate container base images based on the CPU architecture arch = USERARG.get('arch', 'x86_64') if arch == 'aarch64': # Early Access images - NGC registration required to use default_build_image = 'nvcr.io/ea-cuda-sc19/arm-partners/cuda-aarch64:10.2-devel-ubuntu18.04' default_runtime_image = 'nvcr.io/ea-cuda-sc19/arm-partners/cuda-aarch64:10.2-base-ubuntu18.04' elif arch == 'x86_64': default_build_image = 'nvcr.io/nvidia/cuda:10.1-devel-ubuntu18.04' default_runtime_image = 'nvcr.io/nvidia/cuda:10.1-base-ubuntu18.04' else: raise Exception('unrecognized architecture: {}'.format(arch)) ######## # Build stage (Stage 0) ######## # Base image Stage0 += baseimage(image=USERARG.get('build_image', default_build_image), _arch=arch, _as='build') if arch == 'aarch64' and USERARG.get('qemu', False): # Install QEMU emulator for aarch64 container image builds on x86 systems Stage0 += copy(_from='multiarch/qemu-user-static', src='/usr/bin/qemu-aarch64-static', dest='/usr/bin') # Base development environment Stage0 += gnu(version='8') Stage0 += cmake(eula=True) # Communication stack: OpenMPI + UCX + KNEM + Mellanox OFED + gdrcopy # (x86 only) Stage0 += mlnx_ofed(version=USERARG.get('mlnx_ofed', '4.6-1.0.1.1')) if hpccm.config.g_cpu_arch == hpccm.config.cpu_arch.X86_64: Stage0 += gdrcopy(ldconfig=True, version=USERARG.get('gdrcopy', '1.3')) Stage0 += knem(ldconfig=True, version=USERARG.get('knem', '1.1.3')) Stage0 += ucx(knem='/usr/local/knem', ldconfig=True, version=USERARG.get('ucx', '1.6.1')) mpi = openmpi(ldconfig=True, version=USERARG.get('ompi', '4.0.2'), ucx='/usr/local/ucx') Stage0 += mpi ######## # LAMMPS ######## gpu_arch = USERARG.get('gpu_arch', 'Volta70') if gpu_arch not in ['Pascal60', 'Volta70', 'Turing75']: raise Exception('unrecognized GPU architecture: {}'.format(gpu_arch)) lammps_version = USERARG.get('lammps_version', 'patch_19Sep2019') compute_capability = 'sm' + gpu_arch[-2:] srcdir = '/var/tmp/lammps-{}'.format(lammps_version) Stage0 += comment('LAMMPS version {0} for CUDA compute capability {1}'.format( lammps_version, compute_capability)) # LAMMPS dependencies Stage0 += apt_get(ospackages=['bc', 'git', 'libgomp1', 'libhwloc-dev', 'make', 'tar', 'wget']) # LAMMPS build Stage0 += generic_cmake( build_directory='{0}/build-{1}'.format(srcdir, gpu_arch), cmake_opts=['-D BUILD_SHARED_LIBS=ON', '-D CUDA_USE_STATIC_CUDA_RUNTIME=OFF', '-D KOKKOS_ARCH={}'.format(gpu_arch), '-D CMAKE_BUILD_TYPE=Release', '-D MPI_C_COMPILER={}'.format(mpi.toolchain.CC), '-D BUILD_MPI=yes', '-D PKG_MPIIO=on', '-D BUILD_OMP=yes', '-D BUILD_LIB=no', '-D CMAKE_CXX_COMPILER={}/lib/kokkos/bin/nvcc_wrapper'.format(srcdir), '-D PKG_USER-REAXC=yes', '-D PKG_KSPACE=yes', '-D PKG_MOLECULE=yes', '-D PKG_REPLICA=yes', '-D PKG_RIGID=yes', '-D PKG_MISC=yes', '-D PKG_MANYBODY=yes', '-D PKG_ASPHERE=yes', '-D PKG_GPU=no', '-D PKG_KOKKOS=yes', '-D KOKKOS_ENABLE_CUDA=yes', '-D KOKKOS_ENABLE_HWLOC=yes'], directory='{}/cmake'.format(srcdir), # Force CUDA dynamic linking, see # https://github.com/openucx/ucx/wiki/NVIDIA-GPU-Support preconfigure=['sed -i \'s/^cuda_args=""/cuda_args="--cudart shared"/g\' {}/lib/kokkos/bin/nvcc_wrapper'.format(srcdir)], prefix='/usr/local/lammps-{}'.format(compute_capability), url='https://github.com/lammps/lammps/archive/{}.tar.gz'.format(lammps_version)) ######## # Runtime stage (Stage 1) ######## Stage1 += baseimage(image=USERARG.get('runtime_image', default_runtime_image)) # Build stage runtime support + LAMMPS Stage1 += Stage0.runtime() ######## # LAMMPS ######## Stage1 += environment(variables={ 'LD_LIBRARY_PATH': '/usr/local/lammps-{}/lib:$LD_LIBRARY_PATH'.format( compute_capability), 'PATH': '/usr/local/lammps-{}/bin:$PATH'.format(compute_capability), # Workaround, see https://github.com/openucx/ucx/wiki/NVIDIA-GPU-Support 'UCX_MEMTYPE_CACHE': 'n'})
hpc-container-maker-master
recipes/lammps/lammps.py
#!/usr/bin/env python from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function import argparse import hpccm import yaml if __name__ == '__main__': parser = argparse.ArgumentParser( description='Jupyter notebook container generator') parser.add_argument('--environment', type=str, help='Conda environment file') parser.add_argument('--format', type=str, default='docker', choices=['docker', 'singularity'], help='Container specification format (default: docker)') parser.add_argument('--image', type=str, default='ubuntu:18.04', help='Base container image (default: ubuntu:18.04)') parser.add_argument('--notebook', required=True, type=str, help='Jupyter notebook file') parser.add_argument('--packager', type=str, default='pip', choices=['anaconda', 'pip'], help='Python package manager (default: pip)') parser.add_argument('--requirements', type=str, help='pip requirements file') args = parser.parse_args() ### Create Stage stage = hpccm.Stage() ### Base image stage += hpccm.primitives.baseimage(image=args.image, _docker_env=False) ### Install Python and Jupyter (and requirements / environment) if args.packager == 'pip': stage += hpccm.building_blocks.python(python2=False) stage += hpccm.building_blocks.pip(packages=['ipython', 'jupyter'], pip='pip3', requirements=args.requirements) elif args.packager == 'anaconda': stage += hpccm.building_blocks.conda(environment=args.environment, eula=True, packages=['ipython', 'jupyter']) ### Make the port accessible (Docker only) stage += hpccm.primitives.raw(docker='EXPOSE 8888') ### Add the notebook itself stage += hpccm.primitives.copy(src=args.notebook, dest='/notebook/', _mkdir=True) ### Run Jupyter if args.packager == 'pip': stage += hpccm.primitives.runscript( commands=['jupyter notebook --no-browser --ip 0.0.0.0 --notebook-dir /notebook --allow-root']) elif args.packager == 'anaconda': env = 'base' if args.environment: with open(args.environment) as e: y = yaml.safe_load(e) env = y.get('name', 'base') stage += hpccm.primitives.shell(commands=[ 'echo "#!/bin/bash\\nsource /usr/local/anaconda/bin/activate {}\\njupyter notebook --ip 0.0.0.0 --no-browser --notebook-dir /notebook --allow-root" > /usr/local/bin/entrypoint.sh'.format(env), 'chmod a+x /usr/local/bin/entrypoint.sh']) stage += hpccm.primitives.runscript( commands=['/usr/local/bin/entrypoint.sh']) ### Set container specification output format hpccm.config.set_container_format(args.format) ### Output container specification print(stage)
hpc-container-maker-master
recipes/jupyter/jupyter.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Global configuration # # Import this as # import hpccm.config # # And access variables as # hpccm.config.var from __future__ import absolute_import from distutils.version import StrictVersion import archspec.cpu import logging import platform import sys from hpccm.common import cpu_arch from hpccm.common import container_type from hpccm.common import linux_distro # Global variables g_cpu_arch = cpu_arch.X86_64 # CPU architecture if platform.machine() == 'aarch64': g_cpu_arch = cpu_arch.AARCH64 elif platform.machine() == 'ppc64le': g_cpu_arch = cpu_arch.PPC64LE g_cpu_target = None # CPU optimization target g_ctype = container_type.DOCKER # Container type g_linux_distro = linux_distro.UBUNTU # Linux distribution g_linux_version = StrictVersion('16.04') # Linux distribution version g_singularity_version = StrictVersion('2.6') # Singularity version g_wd = '/var/tmp' # Working directory def get_cpu_architecture(): """Return the architecture string for the currently configured CPU architecture, e.g., `aarch64`, `ppc64le`, or `x86_64`. """ this = sys.modules[__name__] if this.g_cpu_arch == cpu_arch.AARCH64: return 'aarch64' elif this.g_cpu_arch == cpu_arch.PPC64LE: if this.g_linux_distro == linux_distro.UBUNTU: return 'ppc64el' else: return 'ppc64le' elif this.g_cpu_arch == cpu_arch.X86_64: return 'x86_64' else: # pragma: no cover raise RuntimeError('Unrecognized processor architecture') def get_cpu_optimization_flags(compiler, version='9999'): """Return the CPU optimization flags for the target and compiler combination. # Arguments compiler: A compiler family string recognized by archspec. version: The version of the compiler. The default version is `9999`, i.e., assume the compiler supports the latest optimization flags. """ this = sys.modules[__name__] if not this.g_cpu_target: return None if this.g_cpu_target not in archspec.cpu.TARGETS: logging.warning('unrecognized CPU target "{}"'.format(this.g_cpu_target)) return None try: return archspec.cpu.TARGETS[this.g_cpu_target].optimization_flags(compiler, version) except Exception as e: logging.warning('get_cpu_optimization_flags: {}'.format(e)) return None def get_format(): """Return the container format string for the currently configured format, e.g., `bash`, `docker`, or `singularity`.""" this = sys.modules[__name__] if this.g_ctype == container_type.BASH: return 'bash' elif this.g_ctype == container_type.DOCKER: return 'docker' elif this.g_ctype == container_type.SINGULARITY: return 'singularity' else: # pragma: no cover raise RuntimeError('Unrecognized format') def set_container_format(ctype): """Set the container format # Arguments ctype (string): 'docker' to specify the Dockerfile format, or 'singularity' to specify the Singularity definition file format # Raises RuntimeError: invalid container type argument """ this = sys.modules[__name__] if ctype == 'docker': this.g_ctype = container_type.DOCKER elif ctype == 'singularity': this.g_ctype = container_type.SINGULARITY else: raise RuntimeError('Unrecognized container format: {}'.format(ctype)) def set_cpu_architecture(arch): """Set the CPU architecture In most cases, the `baseimage` primitive should be relied upon to set the CPU architecture. Only use this function if you really know what you are doing. # Arguments arch (string): Value values are `aarch64`, `ppc64le`, and `x86_64`. `arm` and `arm64v8` are aliases for `aarch64`, `power` is an alias for `ppc64le`, and `amd64` and `x86` are aliases for `x86_64`. """ this = sys.modules[__name__] if arch == 'aarch64' or arch == 'arm' or arch == 'arm64v8': this.g_cpu_arch = cpu_arch.AARCH64 elif arch == 'ppc64le' or arch == 'power': this.g_cpu_arch = cpu_arch.PPC64LE elif arch == 'x86_64' or arch == 'amd64' or arch == 'x86': this.g_cpu_arch = cpu_arch.X86_64 else: logging.warning('Unable to determine the CPU architecture, defaulting to x86_64') this.g_cpu_arch = cpu_arch.X86_64 def set_cpu_target(target): """Set the CPU optimization target # Arguments target (string): A CPU microarchitecture string recognized by archspec. """ this = sys.modules[__name__] this.g_cpu_target = target def set_linux_distro(distro): """Set the Linux distribution and version In most cases, the `baseimage` primitive should be relied upon to set the Linux distribution. Only use this function if you really know what you are doing. # Arguments distro (string): Valid values are `centos7`, `centos8`, `rhel7`, `rhel8`, `rockylinux8`, `ubuntu16`, `ubuntu18`, `ubuntu20`, and `ubuntu22`. `ubuntu` is an alias for `ubuntu16`, `centos` is an alias for `centos7`, and `rhel` is an alias for `rhel7`. """ this = sys.modules[__name__] if distro == 'centos': this.g_linux_distro = linux_distro.CENTOS this.g_linux_version = StrictVersion('7.0') elif distro == 'centos7': this.g_linux_distro = linux_distro.CENTOS this.g_linux_version = StrictVersion('7.0') elif distro == 'centos8': this.g_linux_distro = linux_distro.CENTOS this.g_linux_version = StrictVersion('8.0') elif distro == 'rhel': this.g_linux_distro = linux_distro.RHEL this.g_linux_version = StrictVersion('7.0') elif distro == 'rhel7': this.g_linux_distro = linux_distro.RHEL this.g_linux_version = StrictVersion('7.0') elif distro == 'rhel8': this.g_linux_distro = linux_distro.RHEL this.g_linux_version = StrictVersion('8.0') elif distro == 'rockylinux8': this.g_linux_distro = linux_distro.ROCKYLINUX this.g_linux_version = StrictVersion('8.0') elif distro == 'ubuntu': this.g_linux_distro = linux_distro.UBUNTU this.g_linux_version = StrictVersion('16.04') elif distro == 'ubuntu16': this.g_linux_distro = linux_distro.UBUNTU this.g_linux_version = StrictVersion('16.04') elif distro == 'ubuntu18': this.g_linux_distro = linux_distro.UBUNTU this.g_linux_version = StrictVersion('18.04') elif distro == 'ubuntu20': this.g_linux_distro = linux_distro.UBUNTU this.g_linux_version = StrictVersion('20.04') elif distro == 'ubuntu22': this.g_linux_distro = linux_distro.UBUNTU this.g_linux_version = StrictVersion('22.04') else: logging.warning('Unable to determine the Linux distribution, defaulting to Ubuntu') this.g_linux_distro = linux_distro.UBUNTU this.g_linux_version = StrictVersion('16.04') def set_singularity_version(ver): """Set the Singularity definition file format version The Singularity definition file format was extended in version 3.2 to enable multi-stage builds. However, these changes are not backwards compatible. # Arguments ver (string): Singularity definition file format version. """ this = sys.modules[__name__] this.g_singularity_version = StrictVersion(ver) def set_working_directory(wd): """Set the working directory to use for staging inside the container # Arguments wd (string): working directory path """ this = sys.modules[__name__] this.g_wd = wd def test_cpu_feature_flag(flag): """Return True or False depending on whether the CPU supports the given feature flag # Arguments flag: A CPU feature flag, e.g., `avx`. """ this = sys.modules[__name__] if this.g_cpu_target not in archspec.cpu.TARGETS: logging.warning('unrecognized CPU target "{}"'.format(this.g_cpu_target)) return False if this.g_cpu_target: try: return flag in archspec.cpu.TARGETS[this.g_cpu_target] except Exception as e: logging.warning('get_cpu_optimization_flags: {}'.format(e)) return False
hpc-container-maker-master
hpccm/config.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import absolute_import __version__ = '23.5.0'
hpc-container-maker-master
hpccm/version.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Object base class""" from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function class base_object(object): """Object base class This base class is necessary for MRO inheritance to work. The built-in `object` class initializer does not accept keyword arguments, so it must be called like `super().__init__()`. However, for building blocks to pass keyword arguments to templates, the template initializers must be called like `super().__init__(**kwargs)`. There must be a base class at the bottom that only inherits from `object` and does not call `super()` with keyword arguments. """ def __init__(self, **kwargs): """Initialize base class""" super(base_object, self).__init__()
hpc-container-maker-master
hpccm/base_object.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import absolute_import from hpccm.version import __version__ from hpccm.base_object import base_object from hpccm.common import cpu_arch from hpccm.common import container_type from hpccm.common import linux_distro from hpccm.Stage import Stage from hpccm.recipe import include from hpccm.recipe import recipe from hpccm.toolchain import toolchain import hpccm.building_blocks import hpccm.templates import hpccm.primitives # Templates # For backwards compatibility with recipes that use "hpccm.git()", etc. from hpccm.templates.ConfigureMake import ConfigureMake from hpccm.templates.git import git from hpccm.templates.rm import rm from hpccm.templates.sed import sed from hpccm.templates.tar import tar from hpccm.templates.wget import wget
hpc-container-maker-master
hpccm/__init__.py
#!/usr/bin/env python3 # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function import archspec.cpu import argparse import logging import hpccm from hpccm.version import __version__ class KeyValue(argparse.Action): # pylint: disable=too-few-public-methods """Extend argparse to handle key value pair options""" def __init__(self, option_strings, dest, nargs=None, **kwargs): """Initializing custom action, i.e., call the base class init""" super(KeyValue, self).__init__(option_strings, dest, nargs, **kwargs) def __call__(self, parser, namespace, values, option_string=None): """Process key value pair arguments""" d = {} for kv in values: key, value = kv.split('=') d[key] = value setattr(namespace, self.dest, d) def main(): # pragma: no cover parser = argparse.ArgumentParser(description='HPC Container Maker') parser.add_argument('--cpu-target', type=str, default=None, choices=[a for a in sorted(archspec.cpu.TARGETS)], help='cpu microarchitecture optimization target') parser.add_argument('--format', type=str, default='docker', choices=[i.name.lower() for i in hpccm.container_type], help='select output format') parser.add_argument('--print-exceptions', action='store_true', default=False, help='print exceptions (stack traces)') parser.add_argument('--recipe', required=True, help='generate a container spec for the RECIPE file') parser.add_argument('--single-stage', action='store_true', default=False, help='only process the first stage of a multi-stage ' + 'recipe') parser.add_argument('--singularity-version', type=str, default='2.6', help='set Singularity definition file format version') parser.add_argument('--userarg', action=KeyValue, metavar='key=value', nargs='+', help='specify user parameters') parser.add_argument('--version', action='version', version=__version__) parser.add_argument('--working-directory', '--wd', type=str, default='/var/tmp', help='set container working directory') args = parser.parse_args() # configure logger logging.basicConfig(format='%(levelname)s: %(message)s') recipe = hpccm.recipe(args.recipe, cpu_target=args.cpu_target, ctype=hpccm.container_type[args.format.upper()], raise_exceptions=args.print_exceptions, single_stage=args.single_stage, singularity_version=args.singularity_version, userarg=args.userarg, working_directory=args.working_directory) print(recipe) if __name__ == "__main__": # pragma: no cover main()
hpc-container-maker-master
hpccm/cli.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Common stuff used by multiple parts of HPC Container Maker""" from enum import Enum class container_type(Enum): """Supported container types""" DOCKER = 1 SINGULARITY = 2 BASH = 3 class cpu_arch(Enum): """Supported CPU architectures""" X86_64 = 1 AARCH64 = 2 PPC64LE = 3 class linux_distro(Enum): """Supported Linux distribution types""" UBUNTU = 1 CENTOS = 2 RHEL = 2 REDHAT = 2 ROCKYLINUX = 2
hpc-container-maker-master
hpccm/common.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=invalid-name, too-few-public-methods """Build toolchain""" from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function class toolchain(object): """Class for the build toolchain. Attributes map to the commonly used environment variables, e.g, CC is the C compiler, CXX is the C++ compiler.""" __attrs__ = ['CC', 'CFLAGS', 'CPPFLAGS', 'CUDA_HOME', 'CXX', 'CXXFLAGS', 'F77', 'F90', 'FC', 'FCFLAGS', 'FFLAGS', 'FLIBS', 'LDFLAGS', 'LD_LIBRARY_PATH', 'LIBS'] def __init__(self, **kwargs): """Initialize toolchain""" self.CC = kwargs.get('CC') self.CFLAGS = kwargs.get('CFLAGS') self.CPPFLAGS = kwargs.get('CPPFLAGS') self.CUDA_HOME = kwargs.get('CUDA_HOME') self.CXX = kwargs.get('CXX') self.CXXFLAGS = kwargs.get('CXXFLAGS') self.F77 = kwargs.get('F77') self.F90 = kwargs.get('F90') self.FC = kwargs.get('FC') self.FCFLAGS = kwargs.get('FCFLAGS') self.FFLAGS = kwargs.get('FFLAGS') self.FLIBS = kwargs.get('FLIBS') self.LDFLAGS = kwargs.get('LDFLAGS') self.LD_LIBRARY_PATH = kwargs.get('LD_LIBRARY_PATH') self.LIBS = kwargs.get('LIBS') def __copy__(self): """Copy all the attributes even if __dict__ only returns the pairs with non-null values.""" cls = self.__class__ result = cls.__new__(cls) for key in self.__attrs__: val = getattr(self, key) setattr(result, key, val if val else None) return result def __deepcopy__(self, memo): """Copy all the attributes even if __dict__ only returns the pairs with non-null values.""" result = self.__copy__() memo[id(self)] = result return result @property def __dict__(self): """Return only those attributes that have non-null values. This enables usage like 'environment(variables=var(toolchain))'""" return {key: getattr(self, key) for key in self.__attrs__ if getattr(self, key)}
hpc-container-maker-master
hpccm/toolchain.py