Skip to content

Commit

Permalink
feat: add vulkan images (#22)
Browse files Browse the repository at this point in the history
* feat: add vulkan images

Signed-off-by: lstocchi <[email protected]>

* fix: remove archs from name and convert dockerfile in multi-staged

Signed-off-by: lstocchi <[email protected]>

* fix: update image name

Signed-off-by: lstocchi <[email protected]>

* fix: merge all jobs into one

Signed-off-by: lstocchi <[email protected]>

---------

Signed-off-by: lstocchi <[email protected]>
  • Loading branch information
lstocchi authored Jul 29, 2024
1 parent 946b290 commit ef689a9
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 16 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/build-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ jobs:
build:
name: Build image
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- containerfile: "./chat/base/Containerfile"
build-image-name: "ai-lab-playground-chat"
archs: amd64, arm64
- containerfile: "./chat/vulkan/amd64/Containerfile"
build-image-name: "ai-lab-playground-chat-vulkan"
archs: amd64
- containerfile: "./chat/vulkan/arm64/Containerfile"
build-image-name: "ai-lab-playground-chat-vulkan"
archs: arm64
fail-fast: false

steps:
- uses: actions/checkout@v4
Expand All @@ -41,13 +54,13 @@ jobs:
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ai-lab-playground-chat
image: ${{ matrix.build-image-name }}
tags: nightly ${{ github.sha }}
containerfiles: |
./chat/Containerfile
${{ matrix.containerfile }}
context: ./chat
oci: true
archs: amd64, arm64
archs: ${{ matrix.archs }}

- name: Echo Outputs
run: |
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ jobs:
build:
name: Build image
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- containerfile: "./chat/base/Containerfile"
build-image-name: "ai-lab-playground-chat"
archs: amd64, arm64
- containerfile: "./chat/vulkan/amd64/Containerfile"
build-image-name: "ai-lab-playground-chat-vulkan"
archs: amd64
- containerfile: "./chat/vulkan/arm64/Containerfile"
build-image-name: "ai-lab-playground-chat-vulkan"
archs: arm64
fail-fast: false

steps:
- uses: actions/checkout@v4
Expand All @@ -37,13 +50,13 @@ jobs:
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ai-studio-playground-chat
image: ${{ matrix.build-image-name }}
tags: ${{ github.sha }}
containerfiles: |
./chat/Containerfile
${{ matrix.containerfile }}
context: ./chat
oci: true
archs: amd64, arm64
archs: ${{ matrix.archs }}

- name: Echo Outputs
run: |
Expand Down
32 changes: 22 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,26 @@ env:

jobs:

build:
build_and_release:
name: Build and Release ${{ matrix.build-image-name }}
runs-on: ubuntu-22.04

strategy:
matrix:
include:
- containerfile: "./chat/base/Containerfile"
build-image-name: "ai-lab-playground-chat"
archs: amd64, arm64
- containerfile: "./chat/vulkan/amd64/Containerfile"
build-image-name: "ai-lab-playground-chat-vulkan"
archs: amd64
- containerfile: "./chat/vulkan/arm64/Containerfile"
build-image-name: "ai-lab-playground-chat-vulkan"
archs: arm64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}

- name: Generate tag utilities
id: TAG_UTIL
run: |
Expand Down Expand Up @@ -76,14 +88,14 @@ jobs:
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ai-lab-playground-chat
image: ${{ matrix.build-image-name }}
tags: latest ${{ steps.TAG_UTIL.outputs.imageVersion }} ${{ steps.TAG_UTIL.outputs.imageVersionShort }}
labels: io.podman.ai-lab.version=${{ steps.TAG_UTILS.outputs.imageVersion }}
labels: io.podman.ai-lab.version=${{ steps.TAG_UTIL.outputs.imageVersion }}
containerfiles: |
./chat/Containerfile
${{ matrix.containerfile }}
context: ./chat
oci: true
archs: amd64, arm64
archs: ${{ matrix.archs }}

- name: Login to ghcr.io
uses: redhat-actions/podman-login@v1
Expand All @@ -99,14 +111,14 @@ jobs:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/${{ github.repository_owner }}/podman-desktop-extension-ai-lab-playground-images

- name: id
run: echo the release id is ${{ needs.tag.outputs.releaseId}}
run: echo the release id is ${{ steps.create_release.outputs.id}}

- name: Publish release
uses: StuYarrow/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
id: ${{ steps.create_release.outputs.id}}

File renamed without changes.
1 change: 1 addition & 0 deletions chat/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
llama-cpp-python[server]==0.2.84
pip==24.0
51 changes: 51 additions & 0 deletions chat/vulkan/amd64/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright (C) 2024 Red Hat, Inc.
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0

# Stage 1: Build dependencies
FROM registry.access.redhat.com/ubi9/python-311:1-66 AS builder
USER 0
RUN dnf install -y python3-dnf-plugin-versionlock && \
dnf install -y mesa-vulkan-drivers-23.3.3-1.el9.x86_64 && \
dnf versionlock mesa-vulkan-drivers-23.3.3-1.el9.x86_64 && \
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
dnf install -y git cmake ninja-build gcc gcc-c++ && \
dnf copr enable -y ligenix/enterprise-sandbox epel-9-x86_64 && \
dnf install -y vulkan-headers vulkan-tools && \
dnf clean all

WORKDIR /locallm
COPY requirements.txt ./
RUN pip install --upgrade pip
ENV CMAKE_ARGS="-DLLAMA_VULKAN=on"
ENV FORCE_CMAKE=1
RUN pip install --target=/locallm --no-cache-dir --upgrade -r requirements.txt

# Stage 2: Create final image with minimal content
FROM registry.access.redhat.com/ubi9/python-311:1-66
COPY --from=builder /locallm/ /locallm
COPY --from=builder /usr/bin/vkcube* /usr/bin/
COPY --from=builder /usr/bin/vulkaninfo /usr/bin/vulkaninfo
COPY --from=builder /usr/lib/ /usr/lib/
COPY --from=builder /usr/lib64/ /usr/lib64/
COPY --from=builder /usr/share/vulkan /usr/share/vulkan
COPY --from=builder /usr/include/vulkan /usr/include/vulkan
COPY --from=builder /etc/ /etc/
USER 1001
WORKDIR /locallm
COPY requirements.txt ./
COPY run.sh ./
ENTRYPOINT [ "sh", "run.sh" ]
54 changes: 54 additions & 0 deletions chat/vulkan/arm64/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Copyright (C) 2024 Red Hat, Inc.
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0

# Stage 1: Build dependencies
FROM registry.access.redhat.com/ubi9/python-311:1-66 AS builder
USER 0
WORKDIR /locallm
RUN dnf install -y python3-dnf-plugin-versionlock && \
dnf install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
dnf copr enable -y slp/mesa-krunkit epel-9-aarch64 && \
dnf install -y mesa-vulkan-drivers-23.3.3-101.el9.aarch64 && \
dnf versionlock mesa-vulkan-drivers-23.3.3-101.el9.aarch64 && \
dnf install -y git cmake ninja-build gcc gcc-c++ vulkan-loader-devel vulkan-tools && \
dnf clean all
COPY requirements.txt ./
RUN pip install --upgrade pip
ENV CMAKE_ARGS="-DLLAMA_VULKAN=on"
ENV FORCE_CMAKE=1
RUN pip install --target=/locallm --no-cache-dir --upgrade -r requirements.txt

# Stage 2: Create final image with minimal content
FROM registry.access.redhat.com/ubi9/python-311:1-66
COPY --from=builder /locallm/ /locallm
COPY --from=builder /usr/bin/vkcube* /usr/bin/
COPY --from=builder /usr/bin/vulkaninfo /usr/bin/vulkaninfo
COPY --from=builder /usr/lib/ /usr/lib/
COPY --from=builder /usr/lib64/libdrm* /usr/lib64/
COPY --from=builder /usr/lib64/libvulkan* /usr/lib64/
COPY --from=builder /usr/lib64/libVkLayer* /usr/lib64/
COPY --from=builder /usr/lib64/libxshmfence* /usr/lib64/
COPY --from=builder /usr/lib64/libwayland* /usr/lib64/
COPY --from=builder /usr/lib64/llvm16 /usr/lib64/llvm16
COPY --from=builder /usr/share/vulkan /usr/share/vulkan
COPY --from=builder /usr/include/vulkan /usr/include/vulkan
COPY --from=builder /etc/ /etc/
USER 1001
WORKDIR /locallm
COPY run.sh ./
ENTRYPOINT [ "sh", "run.sh" ]

0 comments on commit ef689a9

Please sign in to comment.