diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1fe07741..4289ee44 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -95,3 +95,11 @@ updates: package-ecosystem: pip schedule: interval: weekly + - directory: enterprise/redhat/openshift-ai/gaudi/docker + groups: + gaudi-openshift: + patterns: + - "requirements.txt" + package-ecosystem: pip + schedule: + interval: weekly diff --git a/enterprise/redhat/openshift-ai/gaudi/demo/oneapi-sample.ipynb b/enterprise/redhat/openshift-ai/gaudi/demo/oneapi-sample.ipynb new file mode 100644 index 00000000..9bd94af3 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/demo/oneapi-sample.ipynb @@ -0,0 +1,315 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1e973d1b-c6d0-48a5-a774-0f114101e81e", + "metadata": {}, + "source": [ + "# Getting started with PyTorch on Intel® Gaudi.\n", + "\n", + "This notebook is to help you get started quickly using the Intel® Gaudi accelerator in this container. A simple MNIST model is trained on the Gaudi acclerator. You can tune some of the parameters below to change configuration of the training. For more information and reference please refer to the official documentation of [Intel® Gaudi acclerator](https://docs.habana.ai/en/latest/index.html)." + ] + }, + { + "cell_type": "markdown", + "id": "7eaacf55-bea2-43be-bb48-163848db1a30", + "metadata": { + "tags": [] + }, + "source": [ + "### Setup modes for training\n", + "\n", + "1. lazy_mode: Set to True(False) to enable(disable) lazy mode.\n", + "2. enable_amp: Set to True(False) to enable Automatic Mixed Precision.\n", + "3. epochs: Number of epochs for training\n", + "4. lr: Learning rate for training\n", + "5. batch_size: Number of samples in a batch\n", + "6. milestones: Milestone epochs for the stepLR scheduler." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5e7cf831-6fe6-46ed-a6fd-f2651cc226af", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "lazy_mode = False\n", + "enable_amp = False\n", + "epochs = 20\n", + "batch_size = 128\n", + "lr = 0.01\n", + "milestones = [10,15]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cee8ad90-c52d-4a50-876f-ce0762cb1b62", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import os\n", + "os.environ['HABANA_LOGS']='/opt/app-root/logs'\n", + "if lazy_mode:\n", + " os.environ['PT_HPU_LAZY_MODE'] = '1'\n", + "else:\n", + " os.environ['PT_HPU_LAZY_MODE'] = '0'" + ] + }, + { + "cell_type": "markdown", + "id": "6eac33d0-2e64-4233-8b3f-40bb7217fef8", + "metadata": { + "tags": [] + }, + "source": [ + "### Import packages" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "06ad44ff-9744-4d6f-af90-375e64717b59", + "metadata": {}, + "outputs": [], + "source": [ + "import torch\n", + "import torch.nn as nn\n", + "import torch.optim as optim\n", + "import torch.nn.functional as F\n", + "import torchvision\n", + "import torchvision.transforms as transforms\n", + "import os\n", + "\n", + "# Import Habana Torch Library\n", + "import habana_frameworks.torch.core as htcore" + ] + }, + { + "cell_type": "markdown", + "id": "062de7f3-4561-4af3-a9ed-2c4cfc918f2f", + "metadata": {}, + "source": [ + "### Define Model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9df57abb-0b63-4e1c-9d9b-87e74964300e", + "metadata": {}, + "outputs": [], + "source": [ + "class SimpleModel(nn.Module):\n", + " def __init__(self):\n", + " super(SimpleModel, self).__init__()\n", + "\n", + " self.fc1 = nn.Linear(784, 256)\n", + " self.fc2 = nn.Linear(256, 64)\n", + " self.fc3 = nn.Linear(64, 10)\n", + "\n", + " def forward(self, x):\n", + "\n", + " out = x.view(-1,28*28)\n", + " out = F.relu(self.fc1(out))\n", + " out = F.relu(self.fc2(out))\n", + " out = self.fc3(out)\n", + "\n", + " return out" + ] + }, + { + "cell_type": "markdown", + "id": "d899885b-5b4d-4557-a90c-9d507875c2ee", + "metadata": {}, + "source": [ + "### Define training routine" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7b17e9aa-fa11-4870-a7d4-183b803177ab", + "metadata": {}, + "outputs": [], + "source": [ + "def train(net,criterion,optimizer,trainloader,device):\n", + "\n", + " net.train()\n", + " if not lazy_mode:\n", + " net = torch.compile(net,backend=\"hpu_backend\")\n", + " train_loss = 0.0\n", + " correct = 0\n", + " total = 0\n", + "\n", + " for batch_idx, (data, targets) in enumerate(trainloader):\n", + "\n", + " data, targets = data.to(device), targets.to(device)\n", + "\n", + " optimizer.zero_grad()\n", + " if enable_amp:\n", + " with torch.autocast(device_type=\"hpu\", dtype=torch.bfloat16):\n", + " outputs = net(data)\n", + " loss = criterion(outputs, targets)\n", + " else:\n", + " outputs = net(data)\n", + " loss = criterion(outputs, targets)\n", + "\n", + " loss.backward()\n", + " \n", + " # API call to trigger execution\n", + " if lazy_mode:\n", + " htcore.mark_step()\n", + " \n", + " optimizer.step()\n", + "\n", + " # API call to trigger execution\n", + " if lazy_mode:\n", + " htcore.mark_step()\n", + "\n", + " train_loss += loss.item()\n", + " _, predicted = outputs.max(1)\n", + " total += targets.size(0)\n", + " correct += predicted.eq(targets).sum().item()\n", + "\n", + " train_loss = train_loss/(batch_idx+1)\n", + " train_acc = 100.0*(correct/total)\n", + " print(\"Training loss is {} and training accuracy is {}\".format(train_loss,train_acc))" + ] + }, + { + "cell_type": "markdown", + "id": "b7a22d69-a91f-48e1-8fac-e1cfe68590b7", + "metadata": {}, + "source": [ + "### Define testing routine" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f9aa379b-b376-4623-9b5c-f778c3d90ce7", + "metadata": {}, + "outputs": [], + "source": [ + "def test(net,criterion,testloader,device):\n", + "\n", + " net.eval()\n", + " test_loss = 0\n", + " correct = 0\n", + " total = 0\n", + "\n", + " with torch.no_grad():\n", + "\n", + " for batch_idx, (data, targets) in enumerate(testloader):\n", + "\n", + " data, targets = data.to(device), targets.to(device)\n", + " \n", + " if enable_amp:\n", + " with torch.autocast(device_type=\"hpu\", dtype=torch.bfloat16):\n", + " outputs = net(data)\n", + " loss = criterion(outputs, targets)\n", + " else:\n", + " outputs = net(data)\n", + " loss = criterion(outputs, targets)\n", + "\n", + "\n", + " # API call to trigger execution\n", + " if lazy_mode:\n", + " htcore.mark_step()\n", + "\n", + " test_loss += loss.item()\n", + " _, predicted = outputs.max(1)\n", + " total += targets.size(0)\n", + " correct += predicted.eq(targets).sum().item()\n", + "\n", + " test_loss = test_loss/(batch_idx+1)\n", + " test_acc = 100.0*(correct/total)\n", + " print(\"Testing loss is {} and testing accuracy is {}\".format(test_loss,test_acc))" + ] + }, + { + "cell_type": "markdown", + "id": "22e76af9-e355-4299-b84d-f34c9a25e76d", + "metadata": {}, + "source": [ + "### Run the main routine to train and test the model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c8ddfb1-d4f7-44b2-aff0-f86f1db8c971", + "metadata": {}, + "outputs": [], + "source": [ + "load_path = './data'\n", + "save_path = './checkpoints'\n", + "\n", + "if(not os.path.exists(save_path)):\n", + " os.makedirs(save_path)\n", + "\n", + "# Target the Gaudi HPU device\n", + "device = torch.device(\"hpu\")\n", + "\n", + "# Data\n", + "transform = transforms.Compose([\n", + " transforms.ToTensor(),\n", + "])\n", + "\n", + "trainset = torchvision.datasets.MNIST(root=load_path, train=True,\n", + " download=True, transform=transform)\n", + "trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,\n", + " shuffle=True, num_workers=2)\n", + "testset = torchvision.datasets.MNIST(root=load_path, train=False,\n", + " download=True, transform=transform)\n", + "testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size,\n", + " shuffle=False, num_workers=2)\n", + "\n", + "net = SimpleModel()\n", + "net.to(device)\n", + "\n", + "criterion = nn.CrossEntropyLoss()\n", + "optimizer = optim.SGD(net.parameters(), lr=lr,\n", + " momentum=0.9, weight_decay=5e-4)\n", + "scheduler = torch.optim.lr_scheduler.MultiStepLR(optimizer, milestones=milestones, gamma=0.1)\n", + "\n", + "for epoch in range(1, epochs+1):\n", + " print(\"=====================================================================\")\n", + " print(\"Epoch : {}\".format(epoch))\n", + " train(net,criterion,optimizer,trainloader,device)\n", + " test(net,criterion,testloader,device)\n", + "\n", + " torch.save(net.state_dict(), os.path.join(save_path,'epoch_{}.pth'.format(epoch)))\n", + "\n", + " scheduler.step()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/Dockerfile.rhel9.2 b/enterprise/redhat/openshift-ai/gaudi/docker/Dockerfile.rhel9.2 new file mode 100644 index 00000000..d1449fd8 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/Dockerfile.rhel9.2 @@ -0,0 +1,236 @@ +ARG BASE_IMAGE +ARG BASE_TAG +FROM ${BASE_IMAGE}:${BASE_TAG} AS gaudi-base +ARG ARTIFACTORY_URL +ARG VERSION +ARG REVISION + +LABEL vendor="Intel Corporation" +LABEL release="${VERSION}-${REVISION}" + +ENV HOME="/opt/app-root/src" +WORKDIR /opt/app-root/src + +RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ + dnf clean all && rm -rf /var/cache/yum + +RUN echo "[BaseOS]" > /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \ + echo "name=CentOS Linux 9 - BaseOS" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \ + echo "baseurl=https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \ + echo "gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo + +RUN echo "[centos9]" > /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \ + echo "name=CentOS Linux 9 - AppStream" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \ + echo "baseurl=https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \ + echo "gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo + +RUN dnf install -y \ + clang \ + cmake3 \ + cpp \ + gcc \ + gcc-c++ \ + glibc \ + glibc-headers \ + glibc-devel \ + jemalloc \ + libarchive \ + libksba \ + unzip \ + llvm \ + lsof \ + python3-devel \ + openssh-clients \ + openssl \ + openssl-devel \ + libjpeg-devel \ + openssh-server \ + lsb_release \ + wget \ + git \ + libffi-devel \ + bzip2-devel \ + zlib-devel \ + mesa-libGL \ + iproute \ + python3-dnf-plugin-versionlock && \ + # update pkgs (except OS version) for resolving potentials CVEs + dnf versionlock add redhat-release* && \ + dnf update -y && \ + dnf clean all && rm -rf /var/cache/yum + +RUN mkdir -p /licenses && \ + wget -O /licenses/LICENSE https://raw.githubusercontent.com/intel/ai-containers/main/LICENSE + +ENV PYTHON_VERSION=3.10 +COPY install-python310.sh . +RUN ./install-python310.sh rhel9.2 && rm install-python310.sh +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +COPY install_efa.sh . +RUN ./install_efa.sh && rm install_efa.sh && rm -rf /etc/ld.so.conf.d/efa.conf /etc/profile.d/efa.sh + +ENV LIBFABRIC_VERSION="1.20.0" +ENV LIBFABRIC_ROOT="/opt/habanalabs/libfabric-${LIBFABRIC_VERSION}" +ENV MPI_ROOT=/opt/amazon/openmpi +ENV LD_LIBRARY_PATH=$LIBFABRIC_ROOT/lib:${MPI_ROOT}/lib:/usr/lib/habanalabs:$LD_LIBRARY_PATH +ENV PATH=${LIBFABRIC_ROOT}/bin:${MPI_ROOT}/bin:$PATH +ENV OPAL_PREFIX=${MPI_ROOT} +ENV MPICC=${MPI_ROOT}/bin/mpicc +ENV RDMAV_FORK_SAFE=1 +ENV FI_EFA_USE_DEVICE_RDMA=1 + +RUN echo "[habanalabs]" > /etc/yum.repos.d/habanalabs.repo && \ + echo "name=Habana RH9 Linux repo" >> /etc/yum.repos.d/habanalabs.repo && \ + echo "baseurl=https://${ARTIFACTORY_URL}/artifactory/rhel/9/9.2" >> /etc/yum.repos.d/habanalabs.repo && \ + echo "gpgkey=https://${ARTIFACTORY_URL}/artifactory/rhel/9/9.2/repodata/repomd.xml.key" >> /etc/yum.repos.d/habanalabs.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/habanalabs.repo + +# for Habana GPG key with SHA-1 signature +RUN update-crypto-policies --set DEFAULT:SHA1 + +RUN dnf install -y habanalabs-rdma-core-"$VERSION"-"$REVISION".el9 \ + habanalabs-thunk-"$VERSION"-"$REVISION".el9 \ + habanalabs-firmware-tools-"$VERSION"-"$REVISION".el9 \ + habanalabs-graph-"$VERSION"-"$REVISION".el9 && \ + rm -f /etc/yum.repos.d/habanalabs.repo && rm -f /etc/yum.repos.d/habana.repo && rm -rf /tmp/* && \ + dnf clean all && rm -rf /var/cache/yum + +RUN rpm -V habanalabs-rdma-core && rpm -V habanalabs-thunk && rpm -V habanalabs-firmware-tools && rpm -V habanalabs-graph + +# There is no need to store pip installation files inside docker image +ENV PIP_NO_CACHE_DIR=on +ENV PIP_DISABLE_PIP_VERSION_CHECK=1 +ENV RDMA_CORE_ROOT=/opt/habanalabs/rdma-core/src +ENV RDMA_CORE_LIB=${RDMA_CORE_ROOT}/build/lib + +RUN wget -nv -O /tmp/libfabric-${LIBFABRIC_VERSION}.tar.bz2 https://github.com/ofiwg/libfabric/releases/download/v${LIBFABRIC_VERSION}/libfabric-${LIBFABRIC_VERSION}.tar.bz2 && \ + cd /tmp/ && tar xf /tmp/libfabric-${LIBFABRIC_VERSION}.tar.bz2 && \ + cd /tmp/libfabric-${LIBFABRIC_VERSION} && \ + ./configure --prefix=$LIBFABRIC_ROOT --enable-psm3-verbs --enable-verbs=yes --with-synapseai=/usr && \ + make && make install && cd / && rm -rf /tmp/libfabric-${LIBFABRIC_VERSION}.tar.bz2 /tmp/libfabric-${LIBFABRIC_VERSION} + +RUN wget -nv -O /tmp/main.zip https://github.com/HabanaAI/hccl_ofi_wrapper/archive/refs/heads/main.zip && \ + unzip /tmp/main.zip -d /tmp && \ + cd /tmp/hccl_ofi_wrapper-main && \ + make && cp -f libhccl_ofi_wrapper.so /usr/lib/habanalabs/libhccl_ofi_wrapper.so && \ + cd / && \ + rm -rf /tmp/main.zip /tmp/hccl_ofi_wrapper-main + +ENV GC_KERNEL_PATH=/usr/lib/habanalabs/libtpc_kernels.so +ENV HABANA_LOGS=/opt/app-root/log/habana_logs/ +ENV HABANA_SCAL_BIN_PATH=/opt/habanalabs/engines_fw +ENV HABANA_PLUGINS_LIB_PATH=/opt/habanalabs/habana_plugins + +ENV APP_ROOT="/opt/app-root" + +RUN python3.10 -m pip install "pip>=23.3" "setuptools>=70.0.0" "wheel==0.38.4" + +WORKDIR ${APP_ROOT} + +RUN python3.10 -m venv ${APP_ROOT} && \ + wget -O ${APP_ROOT}/bin/fix-permissions \ + https://raw.githubusercontent.com/sclorg/s2i-python-container/master/3.9-minimal/root/usr/bin/fix-permissions && \ + chown -R 1001:0 ${APP_ROOT} && \ + chmod +x ${APP_ROOT}/bin/fix-permissions && \ + ${APP_ROOT}/bin/fix-permissions ${APP_ROOT} -P && \ + echo "unset BASH_ENV PROMPT_COMMAND ENV" >> ${APP_ROOT}/bin/activate + +USER 1001 + +ENV BASH_ENV="${APP_ROOT}/bin/activate" +ENV ENV="${APP_ROOT}/bin/activate" +ENV PROMPT_COMMAND=". ${APP_ROOT}/bin/activate" + +SHELL ["/bin/bash", "-c"] + +RUN python -m pip install habana_media_loader=="${VERSION}"."${REVISION}" + + +FROM gaudi-base AS gaudi-pytorch + +ARG PT_VERSION +ARG VERSION +ARG REVISION +ARG ARTIFACTORY_URL +ENV BASE_NAME=rhel9.2 + +LABEL name="PyTorch Installer" +LABEL summary="Habanalabs PyTorch installer layer for RHEL9.2" +LABEL description="Image with pre installed Habanalabs packages for PyTorch" + +RUN echo "/usr/lib/habanalabs" > $(python -c "import sysconfig; print(sysconfig.get_path('platlib'))")/habanalabs-graph.pth + +USER root + +RUN echo "[CRB]" > /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "name=CentOS Linux 9 - CRB" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "baseurl=https://mirror.stream.centos.org/9-stream/CRB/x86_64/os" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo + +RUN dnf install --allowerasing -y \ + curl \ + cairo-devel \ + numactl-devel \ + iproute \ + which \ + zlib-devel \ + lapack-devel \ + openblas-devel \ + numactl \ + gperftools-devel && \ + dnf clean all && rm -rf /var/cache/yum + +RUN dnf config-manager --add-repo https://yum.repos.intel.com/mkl/setup/intel-mkl.repo -y && \ + dnf install --allowerasing -y intel-mkl-64bit-2020.4-912 && \ + dnf clean all && rm -rf /var/cache/yum + +# Set LD_PRELOAD after all required installations to +# avoid warnings during docker creation +ENV LD_PRELOAD=/lib64/libtcmalloc.so.4 +ENV TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD=7516192768 + +RUN rm -rf /tmp/* + +USER 1001 + +COPY --chown=1001:0 install_packages.sh . +RUN ./install_packages.sh && rm -f install_packages.sh + +USER root + +RUN /sbin/ldconfig && echo "source /etc/profile.d/habanalabs.sh" >> ~/.bashrc && \ + chown 1001:0 ~/.bashrc + +USER 1001 + +FROM gaudi-pytorch AS gaudi-notebooks + +WORKDIR ${APP_ROOT}/src + +COPY --chown=1001:0 requirements.txt requirements.txt +COPY --chown=1001:0 start-notebook.sh /opt/app-root/bin +COPY --chown=1001:0 builder /opt/app-root/builder +COPY --chown=1001:0 utils /opt/app-root/bin/utils + +USER 1001 + +RUN python -m pip install -r requirements.txt && \ + chmod -R g+w ${APP_ROOT}/lib/python3.10/site-packages && \ + fix-permissions ${APP_ROOT} -P && \ + chmod -R g+w /opt/app-root/src && \ + sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \ + jupyter labextension disable "@jupyterlab/apputils-extension:announcements" + +RUN cd ${APP_ROOT}/ && \ + git clone https://github.com/HabanaAI/vllm-fork.git && \ + cd vllm-fork && \ + VLLM_TARGET_DEVICE=hpu pip install -e . + +WORKDIR ${APP_ROOT}/src +ENV NOTEBOOK_SAMPLE_LINK="https://raw.githubusercontent.com/sharvil10/ai-containers/main/enterprise/redhat/openshift-ai/gaudi/demo/Getting-started.ipynb" + +ENTRYPOINT ["bash", "-c", "/opt/app-root/builder/run"] diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/Dockerfile.rhel9.4 b/enterprise/redhat/openshift-ai/gaudi/docker/Dockerfile.rhel9.4 new file mode 100644 index 00000000..18eeef28 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/Dockerfile.rhel9.4 @@ -0,0 +1,249 @@ +ARG BASE_IMAGE +ARG BASE_TAG +FROM ${BASE_IMAGE}:${BASE_TAG} AS gaudi-base +ARG ARTIFACTORY_URL +ARG VERSION +ARG REVISION + +LABEL vendor="Intel Corporation" +LABEL release="${VERSION}-${REVISION}" + +ENV HOME="/opt/app-root/src" +WORKDIR /opt/app-root/src + +RUN echo "[BaseOS]" > /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \ + echo "name=CentOS Linux 9 - BaseOS" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \ + echo "baseurl=https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \ + echo "gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Linux-BaseOS.repo + +RUN echo "[centos9]" > /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \ + echo "name=CentOS Linux 9 - AppStream" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \ + echo "baseurl=https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \ + echo "gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Linux-AppStream.repo + +RUN echo "[CRB]" > /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "name=CentOS Linux 9 - CRB" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "baseurl=https://mirror.stream.centos.org/9-stream/CRB/x86_64/os" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo + +RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ + dnf clean all && rm -rf /var/cache/yum + +RUN dnf install -y \ + clang \ + cmake3 \ + cpp \ + gcc \ + gcc-c++ \ + glibc \ + glibc-headers \ + glibc-devel \ + jemalloc \ + libarchive \ + libksba \ + unzip \ + llvm \ + lsof \ + python3-devel \ + openssh-clients \ + openssl-1:3.0.7-27.el9 \ + openssl-devel-1:3.0.7-27.el9 \ + libjpeg-devel \ + openssh-server \ + lsb_release \ + wget \ + git \ + libffi-devel \ + bzip2-devel \ + zlib-devel \ + mesa-libGL \ + iproute \ + python3.11 \ + python3.11-pip \ + python3.11-devel \ + ffmpeg-free \ + perl-Net-SSLeay-1.92-2.el9 \ + python3-dnf-plugin-versionlock && \ + # update pkgs (except OS version) for resolving potentials CVEs + dnf versionlock add redhat-release* openssl* perl-Net-SSLeay && \ + dnf update -y && \ + dnf clean all && rm -rf /var/cache/yum + +RUN mkdir -p /licenses && \ + wget -O /licenses/LICENSE https://raw.githubusercontent.com/intel/ai-containers/main/LICENSE + +RUN alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 && \ + alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 && \ + alternatives --set python3 /usr/bin/python3.11 && \ + alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip3.11 2 && \ + alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip3.9 1 && \ + alternatives --set pip3 /usr/bin/pip3.11 + +COPY install_efa.sh . +RUN ./install_efa.sh && rm install_efa.sh && rm -rf /etc/ld.so.conf.d/efa.conf /etc/profile.d/efa.sh + +ENV LIBFABRIC_VERSION="1.20.0" +ENV LIBFABRIC_ROOT="/opt/habanalabs/libfabric-${LIBFABRIC_VERSION}" +ENV MPI_ROOT=/opt/amazon/openmpi +ENV LD_LIBRARY_PATH=$LIBFABRIC_ROOT/lib:${MPI_ROOT}/lib:/usr/lib/habanalabs:$LD_LIBRARY_PATH +ENV PATH=${LIBFABRIC_ROOT}/bin:${MPI_ROOT}/bin:$PATH +ENV OPAL_PREFIX=${MPI_ROOT} +ENV MPICC=${MPI_ROOT}/bin/mpicc +ENV RDMAV_FORK_SAFE=1 +ENV FI_EFA_USE_DEVICE_RDMA=1 + +RUN echo "[habanalabs]" > /etc/yum.repos.d/habanalabs.repo && \ + echo "name=Habana RH9 Linux repo" >> /etc/yum.repos.d/habanalabs.repo && \ + echo "baseurl=https://${ARTIFACTORY_URL}/artifactory/rhel/9/9.4" >> /etc/yum.repos.d/habanalabs.repo && \ + echo "gpgkey=https://${ARTIFACTORY_URL}/artifactory/rhel/9/9.4/repodata/repomd.xml.key" >> /etc/yum.repos.d/habanalabs.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/habanalabs.repo + +# for Habana GPG key with SHA-1 signature +RUN update-crypto-policies --set DEFAULT:SHA1 + +RUN dnf install -y habanalabs-rdma-core-"$VERSION"-"$REVISION".el9 \ + habanalabs-thunk-"$VERSION"-"$REVISION".el9 \ + habanalabs-firmware-tools-"$VERSION"-"$REVISION".el9 \ + habanalabs-graph-"$VERSION"-"$REVISION".el9 && \ + rm -f /etc/yum.repos.d/habanalabs.repo && rm -f /etc/yum.repos.d/habana.repo && rm -rf /tmp/* && \ + dnf clean all && rm -rf /var/cache/yum + +RUN rpm -V habanalabs-rdma-core && rpm -V habanalabs-thunk && rpm -V habanalabs-firmware-tools && rpm -V habanalabs-graph + +# There is no need to store pip installation files inside docker image +ENV PIP_NO_CACHE_DIR=on +ENV PIP_DISABLE_PIP_VERSION_CHECK=1 +ENV RDMA_CORE_ROOT=/opt/habanalabs/rdma-core/src +ENV RDMA_CORE_LIB=${RDMA_CORE_ROOT}/build/lib + +RUN wget -nv -O /tmp/libfabric-${LIBFABRIC_VERSION}.tar.bz2 https://github.com/ofiwg/libfabric/releases/download/v${LIBFABRIC_VERSION}/libfabric-${LIBFABRIC_VERSION}.tar.bz2 && \ + cd /tmp/ && tar xf /tmp/libfabric-${LIBFABRIC_VERSION}.tar.bz2 && \ + cd /tmp/libfabric-${LIBFABRIC_VERSION} && \ + ./configure --prefix=$LIBFABRIC_ROOT --enable-psm3-verbs --enable-verbs=yes --with-synapseai=/usr && \ + make && make install && cd / && rm -rf /tmp/libfabric-${LIBFABRIC_VERSION}.tar.bz2 /tmp/libfabric-${LIBFABRIC_VERSION} + +RUN wget -nv -O /tmp/main.zip https://github.com/HabanaAI/hccl_ofi_wrapper/archive/refs/heads/main.zip && \ + unzip /tmp/main.zip -d /tmp && \ + cd /tmp/hccl_ofi_wrapper-main && \ + make && cp -f libhccl_ofi_wrapper.so /usr/lib/habanalabs/libhccl_ofi_wrapper.so && \ + cd / && \ + rm -rf /tmp/main.zip /tmp/hccl_ofi_wrapper-main + +ENV APP_ROOT="/opt/app-root" + +RUN python3.11 -m pip install pip==23.3.1 setuptools==67.3.3 wheel==0.38.4 + +WORKDIR ${APP_ROOT} + +RUN python3.11 -m venv ${APP_ROOT} && \ + wget -O ${APP_ROOT}/bin/fix-permissions \ + https://raw.githubusercontent.com/sclorg/s2i-python-container/master/3.9-minimal/root/usr/bin/fix-permissions && \ + chown -R 1001:0 ${APP_ROOT} && \ + chmod +x ${APP_ROOT}/bin/fix-permissions && \ + ${APP_ROOT}/bin/fix-permissions ${APP_ROOT} -P && \ + echo "unset BASH_ENV PROMPT_COMMAND ENV" >> ${APP_ROOT}/bin/activate + +USER 1001 + +ENV BASH_ENV="${APP_ROOT}/bin/activate" +ENV ENV="${APP_ROOT}/bin/activate" +ENV PROMPT_COMMAND=". ${APP_ROOT}/bin/activate" + +SHELL ["/bin/bash", "-c"] + +RUN python -m pip install habana_media_loader=="${VERSION}"."${REVISION}" + +ENV GC_KERNEL_PATH=/usr/lib/habanalabs/libtpc_kernels.so +ENV HABANA_LOGS=/opt/app-root/log/habana_logs/ +ENV HABANA_SCAL_BIN_PATH=/opt/habanalabs/engines_fw +ENV HABANA_PLUGINS_LIB_PATH=/opt/habanalabs/habana_plugins + +FROM gaudi-base AS gaudi-pytorch + +ARG PT_VERSION +ARG VERSION +ARG REVISION +ARG ARTIFACTORY_URL +ENV BASE_NAME=rhel9.4 + +LABEL name="PyTorch Installer" +LABEL summary="Habanalabs PyTorch installer layer for RHEL9.2" +LABEL description="Image with pre installed Habanalabs packages for PyTorch" + +RUN echo "/usr/lib/habanalabs" > $(python -c "import sysconfig; print(sysconfig.get_path('platlib'))")/habanalabs-graph.pt + +USER root + +RUN echo "[CRB]" > /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "name=CentOS Linux 9 - CRB" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "baseurl=https://mirror.stream.centos.org/9-stream/CRB/x86_64/os" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Linux-CRB.repo + +RUN dnf install --allowerasing -y \ + curl \ + cairo-devel \ + numactl-devel \ + iproute \ + which \ + zlib-devel \ + lapack-devel \ + openblas-devel \ + numactl \ + gperftools-devel && \ + dnf clean all && rm -rf /var/cache/yum + +RUN dnf config-manager --add-repo https://yum.repos.intel.com/mkl/setup/intel-mkl.repo -y && \ + dnf install --allowerasing -y intel-mkl-64bit-2020.4-912 && \ + dnf clean all && rm -rf /var/cache/yum + +RUN rm -rf /tmp/* + +USER 1001 + +COPY --chown=1001:0 install_packages.sh . + +# Set LD_PRELOAD after all required installations to +# avoid warnings during docker creation +ENV LD_PRELOAD=/lib64/libtcmalloc.so.4 +ENV TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD=7516192768 + +RUN ./install_packages.sh && rm -f install_packages.sh + +USER root + +RUN /sbin/ldconfig && echo "source /etc/profile.d/habanalabs.sh" >> ~/.bashrc && \ + chown 1001:0 ~/.bashrc + +USER 1001 + +FROM gaudi-pytorch AS gaudi-notebooks + +WORKDIR ${APP_ROOT}/src + +COPY --chown=1001:0 requirements.txt requirements.txt +COPY --chown=1001:0 start-notebook.sh /opt/app-root/bin +COPY --chown=1001:0 builder /opt/app-root/builder +COPY --chown=1001:0 utils /opt/app-root/bin/utils + +USER 1001 + +RUN python -m pip install -r requirements.txt && \ + chmod -R g+w ${APP_ROOT}/lib/python3.11/site-packages && \ + fix-permissions ${APP_ROOT} -P && \ + chmod -R g+w /opt/app-root/src && \ + sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \ + jupyter labextension disable "@jupyterlab/apputils-extension:announcements" + +RUN cd ${APP_ROOT}/ && \ + git clone https://github.com/HabanaAI/vllm-fork.git && \ + cd vllm-fork && \ + VLLM_TARGET_DEVICE=hpu pip install -e . + +WORKDIR ${APP_ROOT}/src +ENV JUPYTER_PRELOAD_REPOS="https://github.com/IntelAI/oneAPI-samples" +ENV REPO_BRANCH="main" +ENTRYPOINT ["bash", "-c", "/opt/app-root/builder/run"] diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/builder/run b/enterprise/redhat/openshift-ai/gaudi/docker/builder/run new file mode 100755 index 00000000..f91d869e --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/builder/run @@ -0,0 +1,39 @@ +#!/bin/bash + +set -eo pipefail + +set -x + +APP_ROOT=${APP_ROOT:-/opt/app-root} + +# Pre-clone repositories defined in JUPYTER_PRELOAD_REPOS +if [ -n "${JUPYTER_PRELOAD_REPOS}" ]; then + for repo in $(echo "${JUPYTER_PRELOAD_REPOS}" | tr ',' ' '); do + # Check for the presence of "@branch" in the repo string + REPO_BRANCH=$(echo "${repo}" | cut -s -d'@' -f2) + if [[ -n ${REPO_BRANCH} ]]; then + # Remove the branch from the repo string and convert REPO_BRANCH to git clone arg + repo=$(echo "${repo}" | cut -d'@' -f1) + REPO_BRANCH="-b ${REPO_BRANCH}" + fi + echo "Checking if repository $repo exists locally" + REPO_DIR=$(basename "${repo}") + if [ -d "${REPO_DIR}" ]; then + pushd "${REPO_DIR}" + # Do nothing if the repo already exists + echo "The ${repo} has already been cloned" + : + popd + else + GIT_SSL_NO_VERIFY=true git clone "${repo}" "${REPO_DIR}" "${REPO_BRANCH}" + fi + done +fi + +if [ -n "${NOTEBOOK_SAMPLES_LINK}" ]; then + for link in $(echo "${NOTEBOOK_SAMPLES_LINK}" | tr ',' ' '); do + wget "${link}" + done +fi + +"${APP_ROOT}"/bin/start-notebook.sh "$@" diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/docker-compose.yaml b/enterprise/redhat/openshift-ai/gaudi/docker/docker-compose.yaml new file mode 100644 index 00000000..d2901e32 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/docker-compose.yaml @@ -0,0 +1,64 @@ +# Copyright (c) 2024 Intel Corporation +# +# 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. + +services: + gaudi-base: + build: + args: + BASE_IMAGE: ${BASE_IMAGE:-registry.access.redhat.com/ubi9/ubi} + BASE_TAG: ${RHEL_OS:-9.2} + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + no_proxy: "" + ARTIFACTORY_URL: ${ARTIFACTORY_URL:-vault.habana.ai} + VERSION: ${VERSION:-1.17.0} + REVISION: ${REVISION:-495} + context: . + target: gaudi-base + dockerfile: Dockerfile.rhel${RHEL_OS:-9.2} + image: gaudi-base:${RHEL_OS:-9.2}-${VERSION:-1.17.0}-${REVISION:-495} + gaudi-pytorch: + build: + args: + BASE_IMAGE: ${BASE_IMAGE:-registry.access.redhat.com/ubi9/ubi} + BASE_TAG: ${RHEL_OS:-9.2} + BASE_NAME: rhel${RHEL_OS:-rhel9.2} + PT_VERSION: ${PT_VERSION:-2.3.1} + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + no_proxy: "" + ARTIFACTORY_URL: ${ARTIFACTORY_URL:-vault.habana.ai} + VERSION: ${VERSION:-1.17.0} + REVISION: ${REVISION:-495} + context: . + target: gaudi-pytorch + dockerfile: Dockerfile.rhel${RHEL_OS:-9.2} + image: gaudi-pytorch:${RHEL_OS:-9.2}-${VERSION:-1.17.0}-${REVISION:-495} + gaudi-notebooks: + build: + args: + BASE_IMAGE: ${BASE_IMAGE:-registry.access.redhat.com/ubi9/ubi} + BASE_TAG: ${RHEL_OS:-9.2} + BASE_NAME: ${BASE_NAME:-rhel9.2} + PT_VERSION: ${PT_VERSION:-2.3.1} + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + no_proxy: "" + ARTIFACTORY_URL: ${ARTIFACTORY_URL:-vault.habana.ai} + VERSION: ${VERSION:-1.17.0} + REVISION: ${REVISION:-495} + context: . + target: gaudi-notebooks + dockerfile: Dockerfile.rhel${RHEL_OS:-9.2} + image: gaudi-notebooks:${RHEL_OS:-9.2}-${VERSION:-1.17.0}-${REVISION:-495} diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/install-python310.sh b/enterprise/redhat/openshift-ai/gaudi/docker/install-python310.sh new file mode 100755 index 00000000..a9d25005 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/install-python310.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# Copyright (c) 2024 Intel Corporation +# +# 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. + +set -e + +_BASE_NAME=${1:-"ubuntu22.04"} +_SSL_LIB="" + +# preinstall dependencies and define variables +case "${_BASE_NAME}" in +*ubuntu22.04*) + echo "Skip install Python3.10 from source on Ubuntu22.04" + exit 0 + ;; +*debian* | *ubuntu*) + apt update + apt install -y libsqlite3-dev libreadline-dev + ;; +*rhel*) + yum install -y sqlite-devel readline-devel xz-devel + ;; +*tencentos3.1*) + dnf install -y sqlite-devel readline-devel zlib-devel xz-devel bzip2-devel libffi-devel + wget -nv -O /opt/openssl-1.1.1w.tar.gz https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz && + cd /opt/ && + tar xzf openssl-1.1.1w.tar.gz && + rm -rf openssl-1.1.1w.tar.gz && + cd openssl-1.1.1w && + ./config --prefix=/usr/local/openssl-1.1.1w shared zlib && + make && make install + ln -s /etc/pki/tls/cert.pem /usr/local/openssl-1.1.1w/ssl/cert.pem + + PATH=$PATH:/usr/local/protoc/bin:/usr/local/openssl-1.1.1w/bin + LD_LIBRARY_PATH=/usr/local/openssl-1.1.1w/lib:$LD_LIBRARY_PATH + _SSL_LIB="--with-openssl=/usr/local/openssl-1.1.1w" + ;; +*amzn2*) + yum install -y sqlite-devel readline-devel + wget -nv -O /opt/openssl-1.1.1w.tar.gz https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz && + cd /opt/ && + tar xzf openssl-1.1.1w.tar.gz && + rm -rf openssl-1.1.1w.tar.gz && + cd openssl-1.1.1w && + ./config --prefix=/usr/local/openssl-1.1.1w shared zlib && + make && make install + ln -s /etc/pki/tls/cert.pem /usr/local/openssl-1.1.1w/ssl/cert.pem + + PATH=$PATH:/usr/local/protoc/bin:/usr/local/openssl-1.1.1w/bin + LD_LIBRARY_PATH=/usr/local/openssl-1.1.1w/lib:$LD_LIBRARY_PATH + _SSL_LIB="--with-openssl=/usr/local/openssl-1.1.1w" + ;; +esac + +# install Python +wget -nv -O /opt/Python-3.10.14.tgz https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tgz +cd /opt/ +tar xzf Python-3.10.14.tgz +rm -f Python-3.10.14.tgz +cd Python-3.10.14 +./configure --enable-optimizations --enable-loadable-sqlite-extensions --enable-shared $_SSL_LIB +make -j && make altinstall + +# post install +case "${_BASE_NAME}" in +*rhel9*) + alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 2 && + alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 && + alternatives --set python3 /usr/local/bin/python3.10 + export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + ;; +*tencentos3.1*) + alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 4 && + alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 3 && + alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 && + alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 && + alternatives --set python3 /usr/local/bin/python3.10 + export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + ;; +*amzn2*) + update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 3 && + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2 && + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 + ;; +*debian*) + update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 3 + update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.8 2 + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 + ;; +esac + +python3 -m pip install --upgrade pip setuptools diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/install_efa.sh b/enterprise/redhat/openshift-ai/gaudi/docker/install_efa.sh new file mode 100755 index 00000000..4175e8f8 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/install_efa.sh @@ -0,0 +1,40 @@ +#!/bin/bash -ex + +# Copyright (c) 2024 Intel Corporation +# +# 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. + +DEFAULT_EFA_INSTALLER_VER=1.29.0 +efa_installer_version=${1:-$DEFAULT_EFA_INSTALLER_VER} + +tmp_dir=$(mktemp -d) +wget -nv https://efa-installer.amazonaws.com/aws-efa-installer-"$efa_installer_version".tar.gz -P "$tmp_dir" +tar -xf "$tmp_dir"/aws-efa-installer-"$efa_installer_version".tar.gz -C "$tmp_dir" +pushd "$tmp_dir"/aws-efa-installer +# shellcheck disable=SC1091 +case $( + . /etc/os-release + echo -n "$ID" +) in +rhel) + # we cannot install dkms packages on RHEL images due to OCP rules + rm -f RPMS/RHEL8/x86_64/dkms*.rpm + ;; +tencentos) + dnf install -y RPMS/ROCKYLINUX8/x86_64/rdma-core/libibverbs-46.0-1.el8.x86_64.rpm RPMS/ROCKYLINUX8/x86_64/rdma-core/libibverbs-utils-46.0-1.el8.x86_64.rpm + patch -f -p1 -i /tmp/tencentos_efa_patch.txt --reject-file=tencentos_efa_patch.rej --no-backup-if-mismatch + ;; +esac +./efa_installer.sh -y --skip-kmod --skip-limit-conf --no-verify +popd +rm -rf "$tmp_dir" diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/install_packages.sh b/enterprise/redhat/openshift-ai/gaudi/docker/install_packages.sh new file mode 100755 index 00000000..d67bb4f3 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/install_packages.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright (c) 2024 Intel Corporation +# +# 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. + +set -ex + +pt_package_name="pytorch_modules-v${PT_VERSION}_${VERSION}_${REVISION}.tgz" +os_string="ubuntu${OS_NUMBER}" +case "${BASE_NAME}" in +*rhel9.2*) + os_string="rhel92" + ;; +*rhel9.4*) + os_string="rhel94" + ;; +*rhel8*) + os_string="rhel86" + ;; +*amzn2*) + os_string="amzn2" + ;; +*tencentos*) + os_string="tencentos31" + ;; +esac +pt_artifact_path="https://${ARTIFACTORY_URL}/artifactory/gaudi-pt-modules/${VERSION}/${REVISION}/pytorch/${os_string}" + +tmp_path=$(mktemp --directory) +wget --no-verbose "${pt_artifact_path}/${pt_package_name}" +tar -xf "${pt_package_name}" -C "${tmp_path}"/. +pushd "${tmp_path}" +./install.sh "$VERSION" "$REVISION" +popd +# cleanup +rm -rf "${tmp_path}" "${pt_package_name}" diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/requirements.txt b/enterprise/redhat/openshift-ai/gaudi/docker/requirements.txt new file mode 100644 index 00000000..9d3a3ca7 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/requirements.txt @@ -0,0 +1,43 @@ +# LLM Packages +deepspeed @ git+https://github.com/HabanaAI/DeepSpeed.git@1.17.0 + +# Datascience and useful extensions +kafka-python~=2.0.2 +matplotlib~=3.8.3 +pandas~=2.2.0 +plotly~=5.20.0 +scikit-learn +scipy~=1.12.0 +skl2onnx~=1.16.0 +codeflare-sdk~=0.18.0 + +# DB connectors +pymongo~=4.6.2 +psycopg~=3.1.18 +pyodbc~=5.1.0 +mysql-connector-python~=8.3.0 + +# JupyterLab packages +odh-elyra~=3.16.7 +jupyterlab~=3.6.7 # Wait on upgrade till plugins are ready +jupyter-bokeh~=3.0.7 # Upgrade would bring in jupyterlab 4 +jupyter-server~=2.14.1 +jupyter-server-proxy~=4.2.0 # Upgrade would bring in jupyterlab 4 +jupyter-server-terminals~=0.5.3 +jupyterlab-git~=0.44.0 +jupyterlab-lsp~=4.2.0 +jupyterlab-widgets~=3.0.10 +jupyter-resource-usage~=0.7.2 +nbdime~=3.2.1 +nbgitpuller~=1.2.0 + +# pycodestyle is dependency of below packages +# and to achieve compatible of pycodestyle with python-lsp-server[all] +# pinned the below packages +autopep8~=2.0.4 +flake8~=7.0.0 +# Base packages +wheel~=0.43.0 +setuptools>=70.0.0 +pip>=23.3 +aiohttp==3.10.2 diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/start-notebook.sh b/enterprise/redhat/openshift-ai/gaudi/docker/start-notebook.sh new file mode 100755 index 00000000..f13aa7d8 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/start-notebook.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# Copyright (c) 2024 Intel Corporation +# +# 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. + +# Load bash libraries +SCRIPT_DIR=${APP_ROOT}/bin +# shellcheck disable=SC1091 +source "${SCRIPT_DIR}"/utils/process.sh + +if [ -f "${SCRIPT_DIR}/utils/setup-elyra.sh" ]; then + # shellcheck disable=SC1091 + source "${SCRIPT_DIR}"/utils/setup-elyra.sh +fi + +# Initialize notebooks arguments variable +NOTEBOOK_PROGRAM_ARGS="" + +# Set default ServerApp.port value if NOTEBOOK_PORT variable is defined +if [ -n "${NOTEBOOK_PORT}" ]; then + NOTEBOOK_PROGRAM_ARGS+="--ServerApp.port=${NOTEBOOK_PORT} " +fi + +# Set default ServerApp.base_url value if NOTEBOOK_BASE_URL variable is defined +if [ -n "${NOTEBOOK_BASE_URL}" ]; then + NOTEBOOK_PROGRAM_ARGS+="--ServerApp.base_url=${NOTEBOOK_BASE_URL} " +fi + +# Set default ServerApp.root_dir value if NOTEBOOK_ROOT_DIR variable is defined +if [ -n "${NOTEBOOK_ROOT_DIR}" ]; then + NOTEBOOK_PROGRAM_ARGS+="--ServerApp.root_dir=${NOTEBOOK_ROOT_DIR} " +else + NOTEBOOK_PROGRAM_ARGS+="--ServerApp.root_dir=${HOME} " +fi + +# Add additional arguments if NOTEBOOK_ARGS variable is defined +if [ -n "${NOTEBOOK_ARGS}" ]; then + NOTEBOOK_PROGRAM_ARGS+=${NOTEBOOK_ARGS} +fi + +echo "${NOTEBOOK_PROGRAM_ARGS}" + +# Start the JupyterLab notebook +# shellcheck disable=SC2086 +start_process jupyter lab ${NOTEBOOK_PROGRAM_ARGS} \ + --ServerApp.ip=0.0.0.0 \ + --ServerApp.allow_origin="*" \ + --ServerApp.open_browser=False diff --git a/enterprise/redhat/openshift-ai/gaudi/docker/utils/process.sh b/enterprise/redhat/openshift-ai/gaudi/docker/utils/process.sh new file mode 100755 index 00000000..95028188 --- /dev/null +++ b/enterprise/redhat/openshift-ai/gaudi/docker/utils/process.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright (c) 2024 Intel Corporation +# +# 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. + +function start_process() { + trap stop_process TERM INT + + echo "Running command:" "$@" + echo -e "$@" + "$@" & + + PID=$! + wait $PID + trap - TERM INT + wait $PID + STATUS=$? + exit $STATUS +} + +function stop_process() { + kill -TERM "$PID" +} diff --git a/enterprise/redhat/openshift-ai/README.md b/enterprise/redhat/openshift-ai/oneapi/README.md similarity index 100% rename from enterprise/redhat/openshift-ai/README.md rename to enterprise/redhat/openshift-ai/oneapi/README.md diff --git a/enterprise/redhat/openshift-ai/assets/step-1.png b/enterprise/redhat/openshift-ai/oneapi/assets/step-1.png similarity index 100% rename from enterprise/redhat/openshift-ai/assets/step-1.png rename to enterprise/redhat/openshift-ai/oneapi/assets/step-1.png diff --git a/enterprise/redhat/openshift-ai/assets/step-2.png b/enterprise/redhat/openshift-ai/oneapi/assets/step-2.png similarity index 100% rename from enterprise/redhat/openshift-ai/assets/step-2.png rename to enterprise/redhat/openshift-ai/oneapi/assets/step-2.png diff --git a/enterprise/redhat/openshift-ai/assets/step-3.png b/enterprise/redhat/openshift-ai/oneapi/assets/step-3.png similarity index 100% rename from enterprise/redhat/openshift-ai/assets/step-3.png rename to enterprise/redhat/openshift-ai/oneapi/assets/step-3.png diff --git a/enterprise/redhat/openshift-ai/assets/step-4.png b/enterprise/redhat/openshift-ai/oneapi/assets/step-4.png similarity index 100% rename from enterprise/redhat/openshift-ai/assets/step-4.png rename to enterprise/redhat/openshift-ai/oneapi/assets/step-4.png diff --git a/enterprise/redhat/openshift-ai/manifests/intel-optimized-ml.yaml b/enterprise/redhat/openshift-ai/oneapi/manifests/intel-optimized-ml.yaml similarity index 100% rename from enterprise/redhat/openshift-ai/manifests/intel-optimized-ml.yaml rename to enterprise/redhat/openshift-ai/oneapi/manifests/intel-optimized-ml.yaml diff --git a/enterprise/redhat/openshift-ai/manifests/intel-optimized-pytorch.yaml b/enterprise/redhat/openshift-ai/oneapi/manifests/intel-optimized-pytorch.yaml similarity index 100% rename from enterprise/redhat/openshift-ai/manifests/intel-optimized-pytorch.yaml rename to enterprise/redhat/openshift-ai/oneapi/manifests/intel-optimized-pytorch.yaml diff --git a/enterprise/redhat/openshift-ai/manifests/intel-optimized-tensorflow.yaml b/enterprise/redhat/openshift-ai/oneapi/manifests/intel-optimized-tensorflow.yaml similarity index 100% rename from enterprise/redhat/openshift-ai/manifests/intel-optimized-tensorflow.yaml rename to enterprise/redhat/openshift-ai/oneapi/manifests/intel-optimized-tensorflow.yaml