Skip to content

RHOAIENG-27434: Create ROCm Tensorflow Python 3.12 Image #1259

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ else ifeq ($(PYTHON_VERSION), 3.12)
runtimes/datascience/ubi9-python-$(PYTHON_VERSION) \
runtimes/pytorch/ubi9-python-$(PYTHON_VERSION) \
runtimes/tensorflow/ubi9-python-$(PYTHON_VERSION) \
runtimes/rocm-pytorch/ubi9-python-$(PYTHON_VERSION)
# runtimes/rocm-tensorflow/ubi9-python-$(PYTHON_VERSION)
# jupyter/rocm/tensorflow/ubi9-python-$(PYTHON_VERSION)
runtimes/rocm-pytorch/ubi9-python-$(PYTHON_VERSION) \
jupyter/rocm/pytorch/ubi9-python-$(PYTHON_VERSION) \
jupyter/rocm/tensorflow/ubi9-python-$(PYTHON_VERSION)
# rstudio/rhel9-python-$(PYTHON_VERSION)
# rstudio/c9s-python-$(PYTHON_VERSION)
else
Expand Down Expand Up @@ -514,14 +514,15 @@ all-images: \
runtime-cuda-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-runtime-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION)
# rocm-runtime-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION)
rocm-runtime-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION)
# rstudio-c9s-python-$(RELEASE_PYTHON_VERSION)
# cuda-rstudio-c9s-python-$(RELEASE_PYTHON_VERSION)
# rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION)
# cuda-rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION)
# rocm-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION)

# rocm-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION)
else
$(error Invalid Python version $(RELEASE_PYTHON_VERSION))
endif
Expand Down
6 changes: 6 additions & 0 deletions jupyter/datascience/ubi9-python-3.12/mssql-2022.repo-x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/rhel/9.0/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
177 changes: 177 additions & 0 deletions jupyter/rocm/tensorflow/ubi9-python-3.12/Dockerfile.rocm
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
######################################################
# mongocli-builder (build stage only, not published) #
######################################################
FROM registry.access.redhat.com/ubi9/go-toolset:latest AS mongocli-builder

ARG MONGOCLI_VERSION=2.0.3

WORKDIR /tmp/
RUN curl -Lo mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip https://github.com/mongodb/mongodb-cli/archive/refs/tags/mongocli/v${MONGOCLI_VERSION}.zip
RUN unzip ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip
RUN cd ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}/ && \
CGO_ENABLED=1 GOOS=linux go build -a -tags strictfipsruntime -o /tmp/mongocli ./cmd/mongocli/

####################
# base #
####################
FROM registry.access.redhat.com/ubi9/python-312:latest AS base

WORKDIR /opt/app-root/bin

# OS Packages needs to be installed as root
USER 0

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

# Other apps and tools installed as default user
USER 1001

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

# 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

########################
# rocm-base #
########################
FROM base AS rocm-base

USER 0
WORKDIR /opt/app-root/bin

# Please keep in sync with ROCm/python3.12 dependent images
ARG ROCM_VERSION=6.4.1
ARG AMDGPU_VERSION=6.4.1

# Install the ROCm rpms
# ref: https://github.com/ROCm/ROCm-docker/blob/master/dev/Dockerfile-centos-7-complete
# Note: Based on 6.4 above new package mivisionx is a pre-requistes, which bring in more dependent packages
# so we are only installing meta packages of rocm
# ref: https://rocm.docs.amd.com/projects/install-on-linux/en/develop/reference/package-manager-integration.html#packages-in-rocm-programming-models
RUN echo "[ROCm]" > /etc/yum.repos.d/rocm.repo && \
echo "name=ROCm" >> /etc/yum.repos.d/rocm.repo && \
echo "baseurl=https://repo.radeon.com/rocm/el9/${ROCM_VERSION}/main" >> /etc/yum.repos.d/rocm.repo && \
echo "enabled=1" >> /etc/yum.repos.d/rocm.repo && \
echo "gpgcheck=0" >> /etc/yum.repos.d/rocm.repo && \
echo "[amdgpu]" > /etc/yum.repos.d/amdgpu.repo && \
echo "name=amdgpu" >> /etc/yum.repos.d/amdgpu.repo && \
echo "baseurl=https://repo.radeon.com/amdgpu/${AMDGPU_VERSION}/rhel/9.4/main/x86_64" >> /etc/yum.repos.d/amdgpu.repo && \
echo "enabled=1" >> /etc/yum.repos.d/amdgpu.repo && \
echo "gpgcheck=0" >> /etc/yum.repos.d/amdgpu.repo && \
dnf install -y 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm' && \
dnf clean all && dnf makecache && \
dnf install -y ocl-icd ocl-icd-devel opencl-icd opencl-icd-loader && \
dnf install -y rocm-developer-tools rocm-ml-sdk rocm-opencl-sdk rocm-openmp-sdk rocm-utils && \
dnf clean all && rm -rf /var/cache/dnf

# Restore notebook user workspace
USER 1001
WORKDIR /opt/app-root/src

########################
# rocm-jupyter-minimal #
########################
FROM rocm-base AS rocm-jupyter-minimal

ARG JUPYTER_REUSABLE_UTILS=jupyter/utils
ARG MINIMAL_SOURCE_CODE=jupyter/minimal/ubi9-python-3.12

WORKDIR /opt/app-root/bin

COPY ${JUPYTER_REUSABLE_UTILS} utils/

USER 0

# Dependencies for PDF export
RUN ./utils/install_pdf_deps.sh
ENV PATH="/usr/local/texlive/bin/x86_64-linux:/usr/local/pandoc/bin:$PATH"

USER 1001

COPY ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./

WORKDIR /opt/app-root/src

ENTRYPOINT ["start-notebook.sh"]

############################
# rocm-jupyter-datascience #
############################
FROM rocm-jupyter-minimal AS rocm-jupyter-datascience

ARG DATASCIENCE_SOURCE_CODE=jupyter/datascience/ubi9-python-3.12

WORKDIR /opt/app-root/bin

# OS Packages needs to be installed as root
USER root

# Install useful OS packages
RUN dnf install -y jq unixODBC postgresql git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum

# Copy dynamically-linked mongocli built in earlier build stage
COPY --from=mongocli-builder /tmp/mongocli /opt/app-root/bin/

# Install MSSQL Client, We need a special repo for MSSQL as they do their own distribution
COPY ${DATASCIENCE_SOURCE_CODE}/mssql-2022.repo-x86_64 /etc/yum.repos.d/mssql-2022.repo

RUN ACCEPT_EULA=Y dnf install -y mssql-tools18 unixODBC-devel && dnf clean all && rm -rf /var/cache/yum

ENV PATH="$PATH:/opt/mssql-tools18/bin"

# Other apps and tools installed as default user
USER 1001

# Copy Elyra setup to utils so that it's sourced at startup
COPY ${DATASCIENCE_SOURCE_CODE}/setup-elyra.sh ${DATASCIENCE_SOURCE_CODE}/utils ./utils/

WORKDIR /opt/app-root/src


###########################
# rocm-jupyter-tensorflow #
###########################
FROM rocm-jupyter-datascience AS rocm-jupyter-tensorflow

ARG DATASCIENCE_SOURCE_CODE=jupyter/datascience/ubi9-python-3.12
ARG TENSORFLOW_SOURCE_CODE=jupyter/rocm/tensorflow/ubi9-python-3.12

WORKDIR /opt/app-root/bin

LABEL name="odh-notebook-jupyter-rocm-tensorflow-ubi9-python-3.12" \
summary="Jupyter AMD tensorflow notebook image for ODH notebooks" \
description="Jupyter AMD tensorflow notebook image with base Python 3.12 builder image based on UBI9 for ODH notebooks" \
io.k8s.display-name="Jupyter AMD tensorflow notebook image for ODH notebooks" \
io.k8s.description="Jupyter AMD tensorflow notebook image with base Python 3.12 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/jupyter/rocm/tensorflow/ubi9-python-3.12" \
io.openshift.build.image="quay.io/opendatahub/workbench-images:rocm-jupyter-tensorflow-ubi9-python-3.12"

COPY ${TENSORFLOW_SOURCE_CODE}/Pipfile.lock ./

RUN echo "Installing softwares and packages" && \
micropipenv install --dev && \
rm -f ./Pipfile.lock && \
# setup path for runtime configuration
mkdir /opt/app-root/runtimes && \
# Remove default Elyra runtime-images \
rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json && \
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \
# copy jupyter configuration
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter && \
# Disable announcement plugin of jupyterlab \
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
# Apply JupyterLab addons \
/opt/app-root/bin/utils/addons/apply.sh && \
# Fix permissions to support pip in Openshift environments \
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
fix-permissions /opt/app-root -P

WORKDIR /opt/app-root/src
58 changes: 58 additions & 0 deletions jupyter/rocm/tensorflow/ubi9-python-3.12/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]
# tf2onnx has pinned protobuf version, that causes conflict with other packages
# This is a workaround to avoid the conflict
tf2onnx = "~= 1.16.1"

[packages]
# ROCm TensorFlow packages
tensorflow_rocm = "~=2.18.1"
tensorboard = "~=2.18.0"

# Datascience and useful extensions
boto3 = "~=1.37.8"
kafka-python-ng = "~=2.2.3"
kfp = "~=2.12.1"
matplotlib = "~=3.10.1"
numpy = "~=1.26.4"
pandas = "~=2.2.3"
plotly = "~=6.0.0"
scikit-learn = "~=1.6.1"
scipy = "~=1.15.2"
skl2onnx = "~=1.17.0"
onnxconverter-common = "~=1.13.0" # Required for skl2onnx, as upgraded version is not compatible with protobuf
codeflare-sdk = "~=0.29.0"
kubeflow-training = "==1.9.0"

# DB connectors
pymongo = "~=4.11.2"
psycopg = "~=3.2.5"
pyodbc = "~=5.2.0"
mysql-connector-python = "~=9.3.0"

# JupyterLab packages

odh-elyra = "==4.2.1"

jupyterlab = "==4.2.7"
jupyter-bokeh = "~=4.0.5"
jupyter-server = "~=2.15.0"
jupyter-server-proxy = "~=4.4.0"
jupyter-server-terminals = "~=0.5.3"
jupyterlab-git = "~=0.50.1"
jupyterlab-lsp = "~=5.1.0"
jupyterlab-widgets = "~=3.0.13"
jupyter-resource-usage = "~=1.1.0"
nbdime = "~=4.0.2"
nbgitpuller = "~=1.2.2"

# Base packages
wheel = "~=0.45.1"
setuptools = "~=78.1.1"

[requires]
python_version = "3.12"
Loading
Loading