1
+ # Copyright (c) 2022 Habana Labs, Ltd.
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ #
5
+ # HabanaLabs Dockerfile base installer layer for RedHat 8.6
6
+ # Reference: https://github.com/HabanaAI/Setup_and_Install/blob/1.13.0/dockerfiles/base/Dockerfile.rhel8.6
7
+ ARG BASE_IMAGE
8
+ FROM ${BASE_IMAGE}
9
+
10
+ ARG ARTIFACTORY_URL="vault.habana.ai"
11
+ ARG VERSION="1.13.0"
12
+ ARG REVISION="463"
13
+ ARG PT_VERSION="2.1.0"
14
+
15
+ USER root
16
+
17
+ RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && \
18
+ dnf clean all && rm -rf /var/cache/yum
19
+
20
+ RUN echo "[appstream]" > /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \
21
+ echo "name=CentOS Linux 8 - AppStream" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \
22
+ echo "mirrorlist=http://mirrorlist.centos.org/?release=\$ releasever-stream&arch=\$ basearch&repo=AppStream&infra=\$ infra" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \
23
+ echo "gpgcheck=0" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo
24
+
25
+
26
+ RUN echo "[BaseOS]" > /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \
27
+ echo "name=CentOS Linux 8 - BaseOS" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \
28
+ echo "mirrorlist=http://mirrorlist.centos.org/?release=\$ releasever-stream&arch=\$ basearch&repo=BaseOS&infra=\$ infra" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \
29
+ echo "gpgcheck=0" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
30
+
31
+ RUN dnf install -y \
32
+ clang \
33
+ cmake3 \
34
+ cpp \
35
+ gcc \
36
+ gcc-c++ \
37
+ glibc \
38
+ glibc-headers \
39
+ glibc-devel \
40
+ jemalloc \
41
+ libarchive \
42
+ libksba \
43
+ unzip \
44
+ llvm \
45
+ lsof \
46
+ python38-devel \
47
+ openssh-clients \
48
+ libjpeg-devel \
49
+ openssh-server \
50
+ redhat-lsb-core \
51
+ wget \
52
+ git \
53
+ mesa-libGL \
54
+ python3-dnf-plugin-versionlock && \
55
+ # update pkgs (except OS version) for resolving potentials CVEs
56
+ dnf versionlock add redhat-release* && \
57
+ dnf update -y && \
58
+ dnf clean all && rm -rf /var/cache/yum
59
+
60
+ ENV LD_LIBRARY_PATH=/usr/lib/habanalabs:$LD_LIBRARY_PATH
61
+ ENV RDMAV_FORK_SAFE=1
62
+
63
+ RUN echo "[habanalabs]" > /etc/yum.repos.d/habanalabs.repo && \
64
+ echo "name=Habana RH8 Linux repo" >> /etc/yum.repos.d/habanalabs.repo && \
65
+ echo "baseurl=https://${ARTIFACTORY_URL}/artifactory/rhel/8/8.6" >> /etc/yum.repos.d/habanalabs.repo && \
66
+ echo "gpgkey=https://${ARTIFACTORY_URL}/artifactory/rhel/8/8.6/repodata/repomd.xml.key" >> /etc/yum.repos.d/habanalabs.repo
67
+
68
+ RUN echo "[powertools]" > /etc/yum.repos.d/powertools.repo && \
69
+ echo "name=powertools" >> /etc/yum.repos.d/powertools.repo && \
70
+ echo "baseurl=http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/" >> /etc/yum.repos.d/powertools.repo && \
71
+ echo "gpgcheck=0" >> /etc/yum.repos.d/powertools.repo
72
+
73
+ RUN dnf install -y habanalabs-rdma-core-"$VERSION" -"$REVISION" .el8 \
74
+ habanalabs-thunk-"$VERSION" -"$REVISION" .el8 \
75
+ habanalabs-firmware-tools-"$VERSION" -"$REVISION" .el8 \
76
+ habanalabs-graph-"$VERSION" -"$REVISION" .el8 && \
77
+ rm -f /etc/yum.repos.d/habanalabs.repo && rm -rf /tmp/* && \
78
+ dnf clean all && rm -rf /var/cache/yum
79
+
80
+ RUN rpm -V habanalabs-rdma-core && rpm -V habanalabs-thunk && rpm -V habanalabs-firmware-tools && rpm -V habanalabs-graph
81
+
82
+ # There is no need to store pip installation files inside docker image
83
+ ENV PIP_NO_CACHE_DIR=on
84
+ ENV PIP_DISABLE_PIP_VERSION_CHECK=1
85
+ ENV RDMA_CORE_ROOT=/opt/habanalabs/rdma-core/src
86
+ ENV RDMA_CORE_LIB=${RDMA_CORE_ROOT}/build/lib
87
+
88
+ # Install python packages
89
+ # RUN python3.8 -m pip install hpu_media_loader=="${VERSION}"."${REVISION}"
90
+ # Install Python packages and Jupyterlab extensions from Pipfile.lock
91
+ COPY Pipfile.lock ./
92
+
93
+ RUN echo "Installing softwares and packages" && micropipenv install && rm -f ./Pipfile.lock
94
+
95
+ RUN echo "export LANG=en_US.UTF-8" >> /root/.bashrc
96
+ RUN export LANG=en_US.UTF-8
97
+ ENV GC_KERNEL_PATH=/usr/lib/habanalabs/libtpc_kernels.so
98
+ ENV HABANA_LOGS=/var/log/habana_logs/
99
+ ENV HABANA_SCAL_BIN_PATH=/opt/habanalabs/engines_fw
100
+ ENV HABANA_PLUGINS_LIB_PATH=/opt/habanalabs/habana_plugins
101
+
102
+ # # Install habana tensorflow
103
+ # Reference: https://github.com/HabanaAI/Setup_and_Install/blob/1.13.0/dockerfiles/tensorflow/Dockerfile.rhel8.6
104
+ # For AML/CentOS/RHEL OS'es TFIO_DATAPATH have to be specified to import tensorflow_io lib correctly
105
+ ENV TFIO_DATAPATH=/opt/app-root/src/python3.8/site-packages/
106
+
107
+ # For AML/CentOS/RHEL ca-cert file is expected exactly under /etc/ssl/certs/ca-certificates.crt
108
+ # otherwise curl will fail during access to S3 AWS storage
109
+ RUN ln -s /etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt
110
+
111
+ # # Install habana pytorch
112
+ # Reference: https://github.com/HabanaAI/Setup_and_Install/blob/1.13.0/dockerfiles/pytorch/Dockerfile.rhel8.6
113
+ ENV LANG=en_US.UTF-8
114
+ ENV PYTHONPATH=/root:/usr/lib/habanalabs/
115
+
116
+ RUN dnf install -y \
117
+ curl \
118
+ cairo-devel \
119
+ numactl-devel \
120
+ iproute \
121
+ which \
122
+ zlib-devel \
123
+ lapack-devel \
124
+ openblas-devel \
125
+ numactl \
126
+ gperftools-devel && \
127
+ dnf clean all && rm -rf /var/cache/yum
128
+
129
+ RUN wget --no-verbose https://"${ARTIFACTORY_URL}" /artifactory/gaudi-pt-modules/"${VERSION}" /"${REVISION}" \
130
+ /pytorch/rhel86/pytorch_modules-v"${PT_VERSION}" _"${VERSION}" _"${REVISION}" .tgz && \
131
+ mkdir /root/habanalabs /root/habanalabs/pytorch_temp && \
132
+ tar -xf pytorch_modules-v"${PT_VERSION}" _"${VERSION}" _"${REVISION}" .tgz -C /root/habanalabs/pytorch_temp/. && \
133
+ pip3 install /root/habanalabs/pytorch_temp/*.whl && \
134
+ pip3 install $(grep "lightning" /root/habanalabs/pytorch_temp/requirements-pytorch.txt) && \
135
+ pip3 install tensorboard~=2.12.2 protobuf==3.20.3 && \
136
+ pip3 uninstall -y pillow && \
137
+ pip3 uninstall -y pillow-simd && \
138
+ pip3 install pillow-simd==7.0.0.post3 && \
139
+ rm -rf /root/habanalabs/pytorch_temp/ && \
140
+ rm -rf pytorch_modules-v"${PT_VERSION}" _"${VERSION}" _"${REVISION}" .tgz &&\
141
+ echo "source /etc/profile.d/habanalabs.sh" >> ~/.bashrc
142
+
143
+ ENV LD_PRELOAD=/lib64/libtcmalloc.so.4
144
+ ENV TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD=7516192768
145
+
146
+ RUN dnf clean all && rm -rf /var/cache/dnf && rm -rf /tmp/*
147
+
148
+ # # Label the image with details required by ODH
149
+ LABEL name="odh-notebook-habana-jupyter-1.3.0-ubi8-python-3.8" \
150
+ summary="Jupyter HabanaAI 1.13.0 notebook image for ODH notebooks" \
151
+ description="Jupyter HabanaAI 1.13.0 notebook image with base Python 3.8 builder image based on ubi8 for ODH notebooks" \
152
+ io.k8s.display-name="Jupyter HabanaAI 1.13.0 notebook image for ODH notebooks" \
153
+ io.k8s.description="Jupyter HabanaAI 1.13.0 notebook image with base Python 3.8 builder image based on ubi8 for ODH notebooks" \
154
+ authoritative-source-url="https://github.com/opendatahub-io/notebooks" \
155
+ io.openshift.build.commit.ref="main" \
156
+ io.openshift.build.source-location="https://github.com/opendatahub-io/notebooks/tree/main/habana/1.13.0/ubi8-python-3.8" \
157
+ io.openshift.build.image="quay.io/opendatahub/workbench-images:habana-jupyter-1.13.0-ubi8-python-3.8"
158
+
159
+ # Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x
160
+ RUN sed -i -e "s/Python.*/$(python --version| cut -d '.' -f-2)\" ,/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \
161
+ # Fix permissions to support pip in Openshift environments \
162
+ chmod -R g+w /opt/app-root/lib/python3.8/site-packages && \
163
+ fix-permissions /opt/app-root -P
164
+
165
+ USER 1001
166
+
167
+ WORKDIR /opt/app-root/src
0 commit comments