From 5c1d731ac091679b22f7c0ba2d6a486bf0634632 Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Wed, 12 Feb 2025 12:39:35 +0000 Subject: [PATCH] Only run dnf commands on platforms that have dnf Other refactorings, fixes Signed-off-by: Eric Curtin --- README.md | 4 +- .../scripts/build_llama_and_whisper.sh | 49 +++++++++++-------- docs/ramalama-list.1.md | 4 +- docs/ramalama.1.md | 2 +- test/system/050-pull.bats | 18 +++---- 5 files changed, 42 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 74616766..cbe22f2a 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ RamaLama uses the Ollama registry transport by default. Use the RAMALAMA_TRANSPO Individual model transports can be modifies when specifying a model via the `huggingface://`, `oci://`, or `ollama://` prefix. -`ramalama pull huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf` +`ramalama pull huggingface://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf` To make it easier for users, RamaLama uses shortname files, which container alias names for fully specified AI Models allowing users to specify the shorter @@ -172,7 +172,7 @@ You can `list` all models pulled into local storage. $ ramalama list NAME MODIFIED SIZE ollama://smollm:135m 16 hours ago 5.5M -huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf 14 hours ago 460M +huggingface://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf 14 hours ago 460M ollama://moondream:latest 6 days ago 791M ollama://phi4:latest 6 days ago 8.43 GB ollama://tinyllama:latest 1 week ago 608.16 MB diff --git a/container-images/scripts/build_llama_and_whisper.sh b/container-images/scripts/build_llama_and_whisper.sh index 48cad908..de94f479 100755 --- a/container-images/scripts/build_llama_and_whisper.sh +++ b/container-images/scripts/build_llama_and_whisper.sh @@ -1,25 +1,33 @@ #!/bin/bash +available() { + command -v "$1" >/dev/null +} + +dnf_install_intel_gpu() { + local intel_rpms=("intel-oneapi-mkl-sycl-devel" "intel-oneapi-dnnl-devel" \ + "intel-oneapi-compiler-dpcpp-cpp" "intel-level-zero" \ + "oneapi-level-zero" "oneapi-level-zero-devel" "intel-compute-runtime") + dnf install -y "${rpm_list[@]}" "${intel_rpms[@]}" + + # shellcheck source=/dev/null + . /opt/intel/oneapi/setvars.sh +} + dnf_install() { local rpm_list=("python3" "python3-pip" "python3-argcomplete" \ "python3-dnf-plugin-versionlock" "gcc-c++" "cmake" "vim" \ "procps-ng" "git" "dnf-plugins-core" "libcurl-devel") local vulkan_rpms=("vulkan-headers" "vulkan-loader-devel" "vulkan-tools" \ "spirv-tools" "glslc" "glslang") - local blas_rpms=("openblas-devel") - local intel_rpms=("intel-oneapi-mkl-sycl-devel" "intel-oneapi-dnnl-devel" \ - "intel-oneapi-compiler-dpcpp-cpp" "intel-level-zero" \ - "oneapi-level-zero" "oneapi-level-zero-devel" "intel-compute-runtime") - - # All the UBI-based ones if [ "$containerfile" = "ramalama" ] || [ "$containerfile" = "rocm" ] || \ - [ "$containerfile" = "vulkan" ]; then + [ "$containerfile" = "vulkan" ]; then # All the UBI-based ones 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 + 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" @@ -29,26 +37,25 @@ dnf_install() { 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[@]}" + dnf install -y "openblas-devel" fi - fi - if [ "$containerfile" = "asahi" ]; then + if [ "$containerfile" = "rocm" ]; then + dnf install -y rocm-dev hipblas-devel rocblas-devel + fi + elif [ "$containerfile" = "asahi" ]; then dnf copr enable -y @asahi/fedora-remix-branding 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 elif [ "$containerfile" = "cuda" ]; then dnf install -y "${rpm_list[@]}" gcc-toolset-12 # shellcheck disable=SC1091 . /opt/rh/gcc-toolset-12/enable + elif [ "$containerfile" = "intel-gpu" ]; then + dnf_install_intel_gpu fi - if [ "$containerfile" = "intel-gpu" ]; then - dnf install -y "${rpm_list[@]}" "${intel_rpms[@]}" - source /opt/intel/oneapi/setvars.sh - fi + dnf -y clean all } cmake_check_warnings() { @@ -120,17 +127,18 @@ main() { local containerfile="$1" local install_prefix - local uname_m="$(uname -m)" + local uname_m + uname_m="$(uname -m)" set_install_prefix local common_flags configure_common_flags common_flags+=("-DGGML_CCACHE=OFF" "-DCMAKE_INSTALL_PREFIX=$install_prefix") - dnf_install + available dnf && dnf_install clone_and_build_whisper_cpp common_flags+=("-DLLAMA_CURL=ON") case "$containerfile" in ramalama) - if [ "$uname_m" = "x86_64" ] || [ "$uname_m" = "aarch64" ] ;then + if [ "$uname_m" = "x86_64" ] || [ "$uname_m" = "aarch64" ]; then common_flags+=("-DGGML_KOMPUTE=ON" "-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON") else common_flags+=("-DGGML_BLAS=ON" "-DGGML_BLAS_VENDOR=OpenBLAS") @@ -139,7 +147,6 @@ main() { esac clone_and_build_llama_cpp - dnf -y clean all rm -rf /var/cache/*dnf* /opt/rocm-*/lib/*/library/*gfx9* ldconfig # needed for libraries } diff --git a/docs/ramalama-list.1.md b/docs/ramalama-list.1.md index 51bb2c59..d1da45f6 100644 --- a/docs/ramalama-list.1.md +++ b/docs/ramalama-list.1.md @@ -32,7 +32,7 @@ List all Models downloaded to users homedir $ ramalama list NAME MODIFIED SIZE ollama://smollm:135m 16 hours ago 5.5M -huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf 14 hours ago 460M +huggingface://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf 14 hours ago 460M ollama://granite-code:3b 5 days ago 1.9G ollama://granite-code:latest 1 day ago 1.9G ollama://moondream:latest 6 days ago 791M @@ -41,7 +41,7 @@ ollama://moondream:latest 6 days ago List all Models in json format ``` $ ramalama list --json -{"models": [{"name": "oci://quay.io/mmortari/gguf-py-example/v1/example.gguf", "modified": 427330, "size": "4.0K"}, {"name": "huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf", "modified": 427333, "size": "460M"}, {"name": "ollama://smollm:135m", "modified": 420833, "size": "5.5M"}, {"name": "ollama://mistral:latest", "modified": 433998, "size": "3.9G"}, {"name": "ollama://granite-code:latest", "modified": 2180483, "size": "1.9G"}, {"name": "ollama://tinyllama:latest", "modified": 364870, "size": "609M"}, {"name": "ollama://tinyllama:1.1b", "modified": 364866, "size": "609M"}]} +{"models": [{"name": "oci://quay.io/mmortari/gguf-py-example/v1/example.gguf", "modified": 427330, "size": "4.0K"}, {"name": "huggingface://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf", "modified": 427333, "size": "460M"}, {"name": "ollama://smollm:135m", "modified": 420833, "size": "5.5M"}, {"name": "ollama://mistral:latest", "modified": 433998, "size": "3.9G"}, {"name": "ollama://granite-code:latest", "modified": 2180483, "size": "1.9G"}, {"name": "ollama://tinyllama:latest", "modified": 364870, "size": "609M"}, {"name": "ollama://tinyllama:1.1b", "modified": 364866, "size": "609M"}]} ``` ## SEE ALSO diff --git a/docs/ramalama.1.md b/docs/ramalama.1.md index 08519290..5d698c31 100644 --- a/docs/ramalama.1.md +++ b/docs/ramalama.1.md @@ -63,7 +63,7 @@ Modify individual model transports by specifying the `huggingface://`, `oci://`, URL support means if a model is on a web site or even on your local system, you can run it directly. -ramalama pull `huggingface://`afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf +ramalama pull `huggingface://`Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf ramalama run `file://`$HOME/granite-7b-lab-Q4_K_M.gguf diff --git a/test/system/050-pull.bats b/test/system/050-pull.bats index 46eb3752..a536b7e3 100644 --- a/test/system/050-pull.bats +++ b/test/system/050-pull.bats @@ -31,20 +31,20 @@ load setup_suite # bats test_tags=distro-integration @test "ramalama pull huggingface" { - run_ramalama pull hf://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf + run_ramalama pull hf://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf run_ramalama list - is "$output" ".*afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k" "image was actually pulled locally" - run_ramalama rm hf://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf + is "$output" ".*Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS" "image was actually pulled locally" + run_ramalama rm hf://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf - run_ramalama pull huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf + run_ramalama pull huggingface://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf run_ramalama list - is "$output" ".*afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k" "image was actually pulled locally" - run_ramalama rm huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf + is "$output" ".*Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS" "image was actually pulled locally" + run_ramalama rm huggingface://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf - RAMALAMA_TRANSPORT=huggingface run_ramalama pull afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf + RAMALAMA_TRANSPORT=huggingface run_ramalama pull Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf run_ramalama list - is "$output" ".*afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k" "image was actually pulled locally" - run_ramalama rm huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf + is "$output" ".*Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS" "image was actually pulled locally" + run_ramalama rm huggingface://Felladrin/gguf-smollm-360M-instruct-add-basics/smollm-360M-instruct-add-basics.IQ2_XXS.gguf run_ramalama pull hf://TinyLlama/TinyLlama-1.1B-Chat-v1.0 run_ramalama list