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

Begin process of packaging PRAGmatic #597

Merged
merged 1 commit into from
Feb 5, 2025
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ jobs:

- name: Build Images
run: |
make build_rm
make build-rm
25 changes: 21 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ SHAREDIR ?= ${PREFIX}/share
PYTHON ?= $(shell command -v python3 python|head -n1)
DESTDIR ?= /
PATH := $(PATH):$(HOME)/.local/bin

IMAGE ?= ramalama
GPU ?= cpu

default: help

help:
@echo "Build Container"
@echo "Build Container Image"
@echo
@echo " - make build"
@echo " - make build IMAGE=ramalama"
@echo " - make multi-arch"
@echo " - make multi-arch IMAGE=ramalama"
@echo
@echo "Build RAG Container Image"
@echo
@echo " - make build-rag IMAGE=quay.io/ramalama/ramalama GPU=ramalama"
@echo
@echo "Build Docling Container Image"
@echo
@echo " - make build-docling IMAGE=quay.io/ramalama/ramalama GPU=ramalama"
@echo
@echo "Build docs"
@echo
@echo " - make docs"
Expand Down Expand Up @@ -79,14 +88,22 @@ install: docs completions
build:
./container_build.sh build $(IMAGE)

.PHONY: build_rm
build_rm:
.PHONY: build-rm
build-rm:
./container_build.sh -r build $(IMAGE)

.PHONY: build_multi_arch
build_multi_arch:
./container_build.sh multi-arch $(IMAGE)

.PHONY: build-rag
build-rag:
podman build --build-arg IMAGE=${IMAGE} --build-arg GPU=${GPU} -t ${IMAGE}-rag container-images/pragmatic

.PHONY: build-docling
build-docling:
podman build --build-arg IMAGE=${IMAGE} --build-arg CONTENT=docling --build-arg GPU=${GPU} -t ${IMAGE}-docling container-images/pragmatic

.PHONY: install-docs
install-docs: docs
make -C docs install
Expand Down
8 changes: 8 additions & 0 deletions container-images/pragmatic/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG IMAGE=quay.io/ramalama/ramalama:latest
FROM $IMAGE

ARG GPU=cpu
ARG CONTENT=rag
COPY ./build_pragmatic.sh /tmp/
RUN echo $CONTENT
RUN sh /tmp/build_pragmatic.sh ${GPU} ${CONTENT}
45 changes: 45 additions & 0 deletions container-images/pragmatic/build_pragmatic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -exu -o pipefail

export PYTHON_VERSION="python3 -m"
if [ "$(python3 --version)" \< "Python 3.11" ]; then
dnf install -y python3.11 python3.11-pip git
export PYTHON_VERSION="/usr/bin/python3.11 -m"
else
dnf install -y python3-pip git
fi

cuda="cu124"

rocm="rocm6.2"

cpu="cpu"

vulkan=$cpu

asahi=$cpu

install_pytorch() {
version=${!1}
echo ${PYTHON_VERSION} pip install torch==${version} -f https://download.pytorch.org/whl/torch_stable.html
${PYTHON_VERSION} pip install torch==${version} -f https://download.pytorch.org/whl/torch_stable.html
}

clone_and_build_pragmatic() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add

set -exu -o pipefail

We want the build to fail if these commands fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I am still working on making the install smaller. Gotten CPU cut in 1/3 but little change in ROCM and CUDA.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we add the same flag to build_llama_and_whisper.sh?

Copy link
Collaborator

Choose a reason for hiding this comment

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

set -ex is there, it's just in the main function (we could add, -o pipefail, etc. if it suits). I tend to create main functions in shell scripts to encourage using scope and less global variable.

set -e alone covers a lot to be fair sometimes it's sufficient.

I do like to add -x at times also, makes CI easy to debug.

But set -e at least is a good idea.

if [ "$2" == "docling" ]; then
${PYTHON_VERSION} pip install docling --extra-index-url https://download.pytorch.org/whl/$1
fi
git clone https://github.com/redhat-et/PRAGmatic
cd PRAGmatic
git submodule update --init --recursive

${PYTHON_VERSION} pip install -r requirements.txt --prefix=/usr
${PYTHON_VERSION} pip install --prefix=/usr .
cd ..
}

clone_and_build_pragmatic ${!1} $2
rm -rf /var/cache/*dnf* /opt/rocm-*/lib/*/library/*gfx9* /root/.cache /root/buildinfo PRAGmatic
dnf -y clean all
ldconfig
Loading