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

WIP: Add ramalama image built on Fedora using Fedora's rocm packages #596

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions container-images/rocm-fedora-gfx10/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM registry.fedoraproject.org/fedora:latest

RUN dnf update -y --refresh && dnf clean all

COPY ../scripts /scripts
RUN chmod +x /scripts/*.sh && \
/scripts/build_llama_and_whisper.sh "rocm" && \
rm -fr /usr/lib64/rocm/gfx8* /usr/lib64/rocm/gfx9* /usr/lib64/rocm/gfx11*

ENV WHISPER_CPP_SHA=${WHISPER_CPP_SHA}
ENV LLAMA_CPP_SHA=${LLAMA_CPP_SHA}
13 changes: 13 additions & 0 deletions container-images/rocm-fedora-gfx11/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM registry.fedoraproject.org/fedora:latest

RUN dnf update -y --refresh && dnf clean all

COPY ../scripts /scripts
RUN chmod +x /scripts/*.sh && \
/scripts/build_llama_and_whisper.sh "rocm" && \
rm -fr /usr/lib64/rocm/gfx8* /usr/lib64/rocm/gfx9* /usr/lib64/rocm/gfx10* && \
ln -s /usr/lib64/rocm/gfx1103/lib/rocblas/library/TensileLibrary_lazy_gfx1103.dat \
/usr/lib64/rocblas/library/TensileLibrary_lazy_gfx1103.dat

ENV WHISPER_CPP_SHA=${WHISPER_CPP_SHA}
ENV LLAMA_CPP_SHA=${LLAMA_CPP_SHA}
11 changes: 11 additions & 0 deletions container-images/rocm-fedora-gfx8/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM registry.fedoraproject.org/fedora:latest

RUN dnf update -y --refresh && dnf clean all

COPY ../scripts /scripts
RUN chmod +x /scripts/*.sh && \
/scripts/build_llama_and_whisper.sh "rocm" && \
rm -fr /usr/lib64/rocm/gfx9* /usr/lib64/rocm/gfx10* /usr/lib64/rocm/gfx11*

ENV WHISPER_CPP_SHA=${WHISPER_CPP_SHA}
ENV LLAMA_CPP_SHA=${LLAMA_CPP_SHA}
11 changes: 11 additions & 0 deletions container-images/rocm-fedora-gfx9/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM registry.fedoraproject.org/fedora:latest

RUN dnf update -y --refresh && dnf clean all

COPY ../scripts /scripts
RUN chmod +x /scripts/*.sh && \
/scripts/build_llama_and_whisper.sh "rocm" && \
rm -fr /usr/lib64/rocm/gfx8* /usr/lib64/rocm/gfx10* /usr/lib64/rocm/gfx11*

ENV WHISPER_CPP_SHA=${WHISPER_CPP_SHA}
ENV LLAMA_CPP_SHA=${LLAMA_CPP_SHA}
46 changes: 33 additions & 13 deletions container-images/scripts/build_llama_and_whisper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
source /etc/os-release

dnf_install() {
local rpm_list=("python3" "python3-pip" "python3-argcomplete" \
Expand All @@ -14,19 +15,26 @@ dnf_install() {
# All the UBI-based ones
if [ "$containerfile" = "ramalama" ] || [ "$containerfile" = "rocm" ] || \
[ "$containerfile" = "vulkan" ]; then
local url="https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm"
dnf install -y "$url"
crb enable # this is in epel-release, can only install epel-release via url
dnf --enablerepo=ubi-9-appstream-rpms install -y "${rpm_list[@]}"
# x86_64 and aarch64 means kompute
if [ "${ID}" = "fedora" ]; then
dnf install -y "${rpm_list[@]}"
else
local url="https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm"
dnf install -y "$url"
crb enable # this is in epel-release, can only install epel-release via url
dnf --enablerepo=ubi-9-appstream-rpms install -y "${rpm_list[@]}"
# x86_64 and aarch64 means kompute
if [ "$uname_m" = "x86_64" ] || [ "$uname_m" = "aarch64" ] ;then
dnf copr enable -y slp/mesa-krunkit "epel-9-$uname_m"
url="https://mirror.stream.centos.org/9-stream/AppStream/$uname_m/os/"
dnf config-manager --add-repo "$url"
url="http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official"
curl --retry 8 --retry-all-errors -o \
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official "$url"
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
fi
fi

if [ "$uname_m" = "x86_64" ] || [ "$uname_m" = "aarch64" ] ;then
dnf copr enable -y slp/mesa-krunkit "epel-9-$uname_m"
url="https://mirror.stream.centos.org/9-stream/AppStream/$uname_m/os/"
dnf config-manager --add-repo "$url"
url="http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official"
curl --retry 8 --retry-all-errors -o \
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official "$url"
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
dnf install -y mesa-vulkan-drivers "${vulkan_rpms[@]}"
else
dnf install -y "${blas_rpms[@]}"
Expand All @@ -38,7 +46,11 @@ dnf_install() {
dnf install -y asahi-repos
dnf install -y mesa-vulkan-drivers "${vulkan_rpms[@]}" "${rpm_list[@]}"
elif [ "$containerfile" = "rocm" ]; then
dnf install -y rocm-dev hipblas-devel rocblas-devel
if [ "${ID}" = "fedora" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Much nicer :)

dnf install -y rocm-core-devel hipblas-devel rocblas-devel rocm-hip-devel
else
dnf install -y rocm-dev hipblas-devel rocblas-devel
fi
elif [ "$containerfile" = "cuda" ]; then
dnf install -y "${rpm_list[@]}" gcc-toolset-12
# shellcheck disable=SC1091
Expand Down Expand Up @@ -74,7 +86,15 @@ configure_common_flags() {
common_flags=("-DGGML_NATIVE=OFF")
case "$containerfile" in
rocm)
if [ "${ID}" = "fedora" ]; then
common_flags+=("-DCMAKE_HIP_COMPILER_ROCM_ROOT=/usr")
common_flags+=("-DGGML_HIP=ON" "-DAMDGPU_TARGETS=${AMDGPU_TARGETS:-gfx1010,gfx1030,gfx1032,gfx1100,gfx1101,gfx1102,gfx1103}")
fi
common_flags+=("-DGGML_HIP=ON" "-DAMDGPU_TARGETS=${AMDGPU_TARGETS:-gfx1010,gfx1030,gfx1032,gfx1100,gfx1101,gfx1102}")
if [ "${ID}" = "fedora" ]; then
common_flags+=("-DCMAKE_HIP_COMPILER_ROCM_ROOT=/usr")
common_flags+=("-DGGML_HIP=ON" "-DAMDGPU_TARGETS=${AMDGPU_TARGETS:-gfx1010,gfx1030,gfx1032,gfx1100,gfx1101,gfx1102,gfx1103}")
fi
;;
cuda)
common_flags+=("-DGGML_CUDA=ON" "-DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined")
Expand Down
Loading