Skip to content

Commit

Permalink
Build cuda image
Browse files Browse the repository at this point in the history
Signed-off-by: Liora Milbaum <[email protected]>
  • Loading branch information
lmilbaum committed Apr 11, 2024
1 parent 96555a1 commit 417e672
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
50 changes: 41 additions & 9 deletions .github/workflows/model_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ jobs:
matrix:
include:
- image_name: llamacpp_python
image_tag: latest
model: mistral
type: base
- image_name: llamacpp_python
image_tag: latest-cuda
model: mistral
type: cuda
- image_name: whispercpp
image_tag: latest
model: whisper-small
type: base
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -45,14 +53,25 @@ jobs:
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Build Image
id: build_image
- name: Build Image (base)
id: build_image_base
if: matrix.type == 'base'
uses: redhat-actions/[email protected]
with:
image: ${{ env.REGISTRY }}/${{ github.repository_owner}}/${{ matrix.image_name }}
platforms: linux/amd64, linux/arm64
tags: latest
containerfiles: ./model_servers/${{ matrix.image_name }}/base/Containerfile
tags: ${{ matrix.image_tag }}
containerfiles: ./model_servers/${{ matrix.image_name }}/${{ matrix.type }}/Containerfile
context: model_servers/${{ matrix.image_name }}/

- name: Build Image (cuda)
id: build_image_cuda
if: matrix.type == 'cuda'
uses: redhat-actions/[email protected]
with:
image: ${{ env.REGISTRY }}/${{ github.repository_owner}}/${{ matrix.image_name }}
tags: ${{ matrix.image_tag }}
containerfiles: ./model_servers/${{ matrix.image_name }}/${{ matrix.type }}/Containerfile
context: model_servers/${{ matrix.image_name }}/

- name: Download model
Expand All @@ -68,11 +87,17 @@ jobs:
working-directory: ./model_servers/${{ matrix.image_name }}/
run: make install

- name: Install cuda dependencies
if: matrix.type == 'cuda'
working-directory: ./model_servers/${{ matrix.image_name }}/
run: sudo apt-get install cuda-drivers-418

- name: Run tests
working-directory: ./model_servers/${{ matrix.image_name }}/
run: make test
env:
IMAGE_NAME: ${{ matrix.image_name }}
IMAGE_TAG: ${{ matrix.image_tag }}

- name: Login to Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand All @@ -82,11 +107,18 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image
id: push_image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- name: Push image (base)
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.type == 'base'
uses: redhat-actions/[email protected]
with:
image: ${{ steps.build_image_base.outputs.image }}
tags: ${{ steps.build_image_base.outputs.tags }}
registry: ${{ env.REGISTRY }}

- name: Push image (cuda)
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.type == 'cuda'
uses: redhat-actions/[email protected]
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
image: ${{ steps.build_image_cuda.outputs.image }}
tags: ${{ steps.build_image_cuda.outputs.tags }}
registry: ${{ env.REGISTRY }}
1 change: 0 additions & 1 deletion model_servers/llamacpp_python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ download-model-tiny-llama:
download-model-llama:
curl -H "Cache-Control: no-cache" -s -S -L -f $(LLAMA_MODEL_URL) -z $(RELATIVE_MODELS_PATH)/$(TINY_LLAMA_MODEL_NAME) -o $(RELATIVE_MODELS_PATH)/$(TINY_LLAMA_MODEL_NAME).tmp && mv -f $(RELATIVE_MODELS_PATH)/$(TINY_LLAMA_MODEL_NAME).tmp $(RELATIVE_MODELS_PATH)/$(TINY_LLAMA_MODEL_NAME) 2>/dev/null || rm -f $(RELATIVE_MODELS_PATH)/$(TINY_LLAMA_MODEL_NAME).tmp $(RELATIVE_MODELS_PATH)/$(TINY_LLAMA_MODEL_NAME)


.PHONY: mistral
mistral:
curl -H "Cache-Control: no-cache" -s -S -L -f $(MISTRAL_MODEL_URL) -z $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME) -o $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp && mv -f $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME) 2>/dev/null || rm -f $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME)
Expand Down
5 changes: 2 additions & 3 deletions model_servers/llamacpp_python/cuda/Containerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM quay.io/opendatahub/workbench-images:cuda-ubi9-python-3.9-20231206
WORKDIR /locallm
COPY src .
RUN pip install --upgrade pip
ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on"
ENV FORCE_CMAKE=1
RUN pip install --no-cache-dir --upgrade -r /locallm/requirements.txt
ENTRYPOINT [ "sh", "run.sh" ]
RUN pip install --no-cache-dir -r ./requirements.txt
ENTRYPOINT [ "sh", "run.sh" ]
2 changes: 1 addition & 1 deletion model_servers/llamacpp_python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

MS = pytest_container.Container(
url=f"containers-storage:{os.environ['REGISTRY']}/containers/{os.environ['IMAGE_NAME']}",
url=f"containers-storage:{os.environ['REGISTRY']}/containers/{os.environ['IMAGE_NAME']}:{os.environ['IMAGE_TAG']}",
volume_mounts=[
pytest_container.container.BindMount(
container_path="/locallm/models/model.gguf",
Expand Down

0 comments on commit 417e672

Please sign in to comment.