Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of Habana SynapseAI notebook to 1.15.1 #533

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,20 @@ jupyter-datascience-anaconda-python-3.8: base-anaconda-python-3.8
$(call image,$@,jupyter/datascience/anaconda-python-3.8,$<)


####################################### Buildchain for Habana SynapseAI #######################################
# This is needed because SynapseAI 1.15+ currently requires a custom python, this builds it from their base image so future support should only require changing base image
# Build and push base-habana-python-3.10 image to the registry
.PHONY: base-habana-python-3.10
base-habana-python-3.10:
$(call image,$@,base/habana-python-3.10)

# Build and push habana-jupyter-1.15.1-ubi9-python-3.10 image to the registry
.PHONY: habana-jupyter-1.15.1-ubi9-python-3.10
habana-jupyter-1.15.1-ubi9-python-3.10: base-habana-python-3.10
$(call image,$@,habana/1.15.1/ubi9-python-3.10,$<)



####################################### Deployments #######################################

# Download kubectl binary
Expand Down
80 changes: 80 additions & 0 deletions base/habana-python-3.10/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
FROM vault.habana.ai/gaudi-docker/1.15.1/rhel9.2/habanalabs/pytorch-installer-2.2.0:1.15.1-15 as base

LABEL name="odh-notebook-habana-jupyter-1.15.1-ubi9-python-3.10" \
summary="Jupyter HabanaAI 1.15.1 notebook image for ODH notebooks" \
description="Jupyter HabanaAI 1.15.1 notebook image with base Python 3.10 builder image based on ubi9 for ODH notebooks" \
io.k8s.display-name="Jupyter HabanaAI 1.15.1 notebook image for ODH notebooks" \
io.k8s.description="Jupyter HabanaAI 1.15.1 notebook image with base Python 3.10 builder image based on ubi9 for ODH notebooks" \
authoritative-source-url="https://github.com/opendatahub-io/notebooks" \
io.openshift.build.commit.ref="main" \
io.openshift.build.source-location="https://github.com/opendatahub-io/notebooks/tree/main/habana/1.15.1/ubi9-python-3.10" \
io.openshift.build.image="quay.io/opendatahub/workbench-images:habana-jupyter-1.15.1-ubi9-python-3.10"

COPY --from=registry.access.redhat.com/ubi9/python-39:latest /usr/bin/fix-permissions /usr/bin
COPY --from=registry.access.redhat.com/ubi9/python-39:latest /usr/bin/rpm-file-permissions /usr/bin

ENV PATH=/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
APP_ROOT="/opt/app-root"

ENV HOME="${APP_ROOT}/src"

WORKDIR ${HOME}

RUN mkdir -p ${APP_ROOT}/src && \
rpm-file-permissions && \
useradd -u 1001 -r -g 0 -d ${HOME} -c "Default Application User" default && \
chown -R 1001:0 ${APP_ROOT}

FROM base as notebook-base

ENV PYTHON_VERSION=3.10 \
PATH=$HOME/.local/bin/:$PATH \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
PIP_NO_CACHE_DIR=off

RUN python3.10 -m venv --system-site-packages ${APP_ROOT} && \
chown -R 1001:0 ${APP_ROOT} && \
fix-permissions ${APP_ROOT} -P && \
rpm-file-permissions && \
echo "unset BASH_ENV PROMPT_COMMAND ENV" >> ${APP_ROOT}/bin/activate

ENV BASH_ENV="${APP_ROOT}/bin/activate" \
ENV="${APP_ROOT}/bin/activate" \
PROMPT_COMMAND=". ${APP_ROOT}/bin/activate"

# Squash a warning from the Habana runtime
ENV TSAN_OPTIONS='ignore_noninstrumented_modules=1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we really compiling something with thread sanitizer enabled? this gives you 3 to 10x more memory consumption and about the same amount of performance degradation; tsan is intended for debug builds only


WORKDIR /opt/app-root/bin

# Install micropipenv to deploy packages from Pipfile.lock
RUN pip install --no-cache-dir -U "micropipenv[toml]"

# Install Python dependencies from Pipfile.lock file
COPY Pipfile.lock ./

RUN echo "Installing softwares and packages" && micropipenv install && rm -f ./Pipfile.lock

# OS Packages needs to be installed as root
USER root

# Install usefull OS packages
RUN dnf install -y mesa-libGL && dnf clean all && rm -rf /var/cache/yum

# Install the oc client
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
-o /tmp/openshift-client-linux.tar.gz && \
tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
rm -f /tmp/openshift-client-linux.tar.gz

# Fix permissions to support pip in Openshift environments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be done in the same RUN as the micropipenv install that created these files

RUN chmod -R g+w /opt/app-root/lib/python3.10/site-packages && \
fix-permissions /opt/app-root -P

# Other apps and tools installed as default user
USER 1001

WORKDIR /opt/app-root/src
14 changes: 14 additions & 0 deletions base/habana-python-3.10/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
# Base packages
wheel = "~=0.43.0"
setuptools = "~=69.2.0"

[requires]
python_version = "3.10"
39 changes: 39 additions & 0 deletions base/habana-python-3.10/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions habana/1.15.1/ubi9-python-3.10/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2022 Habana Labs, Ltd.
#
# SPDX-License-Identifier: Apache-2.0

ARG BASE_IMAGE
FROM ${BASE_IMAGE}

USER root

## Label the image with details required by ODH
LABEL name="odh-notebook-habana-jupyter-1.15.1-ubi9-python-3.10" \
summary="Jupyter HabanaAI 1.15.1 notebook image for ODH notebooks" \
description="Jupyter HabanaAI 1.15.1 notebook image with base Python 3.10 builder image based on ubi9 for ODH notebooks" \
io.k8s.display-name="Jupyter HabanaAI 1.15.1 notebook image for ODH notebooks" \
io.k8s.description="Jupyter HabanaAI 1.15.1 notebook image with base Python 3.10 builder image based on ubi9 for ODH notebooks" \
authoritative-source-url="https://github.com/opendatahub-io/notebooks" \
io.openshift.build.commit.ref="main" \
io.openshift.build.source-location="https://github.com/opendatahub-io/notebooks/tree/main/habana/1.15.1/ubi9-python-3.10" \
io.openshift.build.image="quay.io/opendatahub/workbench-images:habana-jupyter-1.15.1-ubi9-python-3.10"

WORKDIR /opt/app-root/bin

COPY utils utils/

COPY Pipfile.lock start-notebook.sh ./

# Install Python dependencies from Pipfile.lock file
RUN echo "Installing softwares and packages" && micropipenv install && rm -f ./Pipfile.lock

# Disable announcement plugin of jupyterlab
RUN jupyter labextension disable "@jupyterlab/apputils-extension:announcements"

# Fix permissions to support pip in Openshift environments
RUN chmod -R g+w /opt/app-root/lib/python3.10/site-packages && \
fix-permissions /opt/app-root -P

WORKDIR /opt/app-root/src

# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y
RUN sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json

USER 1001

ENTRYPOINT ["start-notebook.sh"]

WORKDIR /opt/app-root/src
24 changes: 24 additions & 0 deletions habana/1.15.1/ubi9-python-3.10/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
# JupyterLab packages
jupyterlab = "~=3.6.7" # Wait on upgrade till plugins are ready
jupyter-server = "~=2.13.0"
jupyter-server-proxy = "~=4.0.0" # Upgrade would bring in jupyterlab 4
jupyter-server-terminals = "~=0.5.3"
jupyterlab-git = "~=0.44.0"
nbdime = "~=3.2.1"
nbgitpuller = "~=1.2.0"

# Base packages
wheel = "~=0.43.0"
setuptools = "~=69.2.0"

[requires]
python_version = "3.10"
Loading