Skip to content

Commit

Permalink
Merge pull request #597 from rhatdan/pragmatic
Browse files Browse the repository at this point in the history
Begin process of packaging PRAGmatic
  • Loading branch information
rhatdan authored Feb 5, 2025
2 parents 965bdf2 + c166c0a commit 032efae
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
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() {
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

0 comments on commit 032efae

Please sign in to comment.