From 04a7d08d204084d807b66a024e677a699e57466b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Gamen=C8=9B?= Date: Thu, 25 Apr 2024 19:49:40 +0200 Subject: [PATCH 1/4] Intermediary model container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Costin Gamenț --- training/model/Containerfile | 8 ++++++++ training/model/Makefile | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 training/model/Containerfile create mode 100644 training/model/Makefile diff --git a/training/model/Containerfile b/training/model/Containerfile new file mode 100644 index 00000000..776fdbb3 --- /dev/null +++ b/training/model/Containerfile @@ -0,0 +1,8 @@ +FROM quay.io/centos-bootc/centos-bootc:stream9 + +ARG MODEL_REPO=https://huggingface.co/ibm/granite-7b-base +ARG MODEL_PATH=/usr/share/ai-model + +RUN dnf install -y git-lfs +RUN mkdir -p "${MODEL_PATH}" +RUN git clone --progress --verbose "${MODEL_REPO}" "${MODEL_PATH}" diff --git a/training/model/Makefile b/training/model/Makefile new file mode 100644 index 00000000..c0b2d3b6 --- /dev/null +++ b/training/model/Makefile @@ -0,0 +1,22 @@ +FROM ?= + +REGISTRY ?= quay.io +REGISTRY_ORG ?= ai-lab +IMAGE_NAME ?= granite-model +IMAGE_TAG ?= latest + +CONTAINER_TOOL ?= podman +CONTAINER_TOOL_EXTRA_ARGS ?= + +MODEL_REPO ?= +MODEL_PATH ?= + +.PHONY: image +image: + "${CONTAINER_TOOL}" build \ + --file Containerfile \ + --tag "${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}:${IMAGE_TAG}" \ + $(FROM:%=--build-arg BASEIMAGE=%) \ + $(MODEL_REPO:%=--build-arg MODEL_REPO=%) \ + $(MODEL_PATH:%=--build-arg MODEL_PATH=%) \ + ${CONTAINER_TOOL_EXTRA_ARGS} From c3197ce22908d87991d8ea087af94b2a3d3e31d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Gamen=C8=9B?= Date: Thu, 25 Apr 2024 21:17:17 +0200 Subject: [PATCH 2/4] Use ugly Python hack for smaller download MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Costin Gamenț --- training/model/Containerfile | 10 +++++----- training/model/Makefile | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/training/model/Containerfile b/training/model/Containerfile index 776fdbb3..f6e317ae 100644 --- a/training/model/Containerfile +++ b/training/model/Containerfile @@ -1,8 +1,8 @@ FROM quay.io/centos-bootc/centos-bootc:stream9 -ARG MODEL_REPO=https://huggingface.co/ibm/granite-7b-base -ARG MODEL_PATH=/usr/share/ai-model +ARG MODEL_REPO='' +ARG MODEL_PATH='' -RUN dnf install -y git-lfs -RUN mkdir -p "${MODEL_PATH}" -RUN git clone --progress --verbose "${MODEL_REPO}" "${MODEL_PATH}" +RUN dnf install -y python3-pip && python -m pip install huggingface_hub +RUN mkdir -p "${MODEL_PATH}" \ + && echo from huggingface_hub import snapshot_download\;snapshot_download\(repo_id=\'${MODEL_REPO}\', local_dir=\'${MODEL_PATH}\', local_dir_use_symlinks=False\) | python diff --git a/training/model/Makefile b/training/model/Makefile index c0b2d3b6..db8b9e01 100644 --- a/training/model/Makefile +++ b/training/model/Makefile @@ -8,8 +8,8 @@ IMAGE_TAG ?= latest CONTAINER_TOOL ?= podman CONTAINER_TOOL_EXTRA_ARGS ?= -MODEL_REPO ?= -MODEL_PATH ?= +MODEL_REPO ?= ibm/granite-7b-base +MODEL_PATH ?= /usr/share/ai-model .PHONY: image image: From 4490863fe08972fa874c69f29d4e236cf5c4203a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Gamen=C8=9B?= Date: Tue, 30 Apr 2024 12:08:38 +0200 Subject: [PATCH 3/4] better download script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Costin Gamenț --- training/model/Containerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/training/model/Containerfile b/training/model/Containerfile index f6e317ae..e1153745 100644 --- a/training/model/Containerfile +++ b/training/model/Containerfile @@ -1,8 +1,11 @@ -FROM quay.io/centos-bootc/centos-bootc:stream9 +FROM registry.access.redhat.com/ubi9/ubi ARG MODEL_REPO='' +ARG MODEL_NAME='' ARG MODEL_PATH='' -RUN dnf install -y python3-pip && python -m pip install huggingface_hub +RUN dnf install -y python3-pip && python3 -m pip install huggingface_hub RUN mkdir -p "${MODEL_PATH}" \ - && echo from huggingface_hub import snapshot_download\;snapshot_download\(repo_id=\'${MODEL_REPO}\', local_dir=\'${MODEL_PATH}\', local_dir_use_symlinks=False\) | python + && echo from huggingface_hub import snapshot_download > /root/hf_download \ + && echo snapshot_download\(repo_id=\'${MODEL_REPO}\', local_dir=\'${MODEL_PATH}\', local_dir_use_symlinks=False\) >> /root/hf_download \ + && python3 /root/hf_download From fc2fe7a916a8c4591adfd5aebce066c3b88da83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Gamen=C8=9B?= Date: Tue, 30 Apr 2024 18:12:03 +0200 Subject: [PATCH 4/4] Update training/model/Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gregory Pereira Signed-off-by: Costin Gamenț --- training/model/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/training/model/Makefile b/training/model/Makefile index db8b9e01..de2d0baa 100644 --- a/training/model/Makefile +++ b/training/model/Makefile @@ -2,7 +2,7 @@ FROM ?= REGISTRY ?= quay.io REGISTRY_ORG ?= ai-lab -IMAGE_NAME ?= granite-model +IMAGE_NAME ?= granite-7b-lab IMAGE_TAG ?= latest CONTAINER_TOOL ?= podman