Jeffser / Alpaca

An Ollama client made with GTK4 and Adwaita
GNU General Public License v3.0
116 stars 18 forks source link

Why package weights ~300 MiB? #81

Closed tsilvs closed 1 month ago

tsilvs commented 1 month ago

Isn't that too big for a text processing app?

Ollama weights ~10 MiB.

Jeffser commented 1 month ago

Ollama doesn't weight 10MiB, it weights almost 300MiB

Jeffser commented 1 month ago

image

tsilvs commented 1 month ago

Yeah, sorry, I looked at .rpm installer package, not the runner

tsilvs commented 1 month ago

@Jeffser wait! Found it!

There is an OpenSUSE RPM of Ollama (in "Factory" builds repo).

Maintained by dimstar @DimStar77

And the /usr/bin/ollama binary in it weights only 30 MiBs!

image

Will test it later on OpenSUSE MicroOS VM or distrobox. Have to find out if it downloads anything additional, or is it really that small. Probably some kind of good dependency optimisation / treeshaking build flag?

Jeffser commented 4 weeks ago

it is probably an installer for Ollama, not Ollama itself, you see, I need the actual binary so I can sandbox it in Flatpak, using the install scripts from Ollama might work, but it's more work and at the end of the day of the day it ends up weighing the same

oritwoen commented 3 weeks ago

On Arch Linux, ollama weighs 54mb after unpacking and it is not an installer but a binary.

The difference in weight results from the fact that in Linux official repositories, ollama uses dynamic linking libraries that are already included in a given system.

Ollama directly from https://github.com/ollama/ollama/releases has a bundle of all libraries to make it compatible with various Linux systems and independent.

Jeffser commented 3 weeks ago

Makes sense, I still won't change it, if the user is able to download models they can download a 300mb binary, I'm not sure how Flatpak interacts with system libraries and stuff like that, there are some binaries that are included with every flatpak but they are very basic

oritwoen commented 3 weeks ago

As for me, it's cool @Jeffser, it's your decision as a maintainer and we have nothing to do with it.

I just mentioned it as an interesting fact for the thread.

Besides, if someone wants to use the app, it won't bother him whether it's flatpak or something else. And even if it bothers someone, there is nothing stopping them from compiling the app on their own computer.

The PKGBUILD I sent you creates a binary of 0.39MB instead of 300MB and that's it. With native compilation, it seems that ollama is not bundled anyway. And with native compilation only the "external instance" of ollama works.

Zrzut ekranu z 2024-06-04 22-23-51

tsilvs commented 3 weeks ago

@Jeffser @oritwoen

RPM

ollama 0.1.38 .rpm from OpenSUSE repo (more links @pkgs.org) lists these dependencies:

Arch

It's complicated... As I understand, the package itself is not an already built binary. I mysef can't run `objdump -x /usr/bin/ollama` - I don't have an Arch environment right now. [`ollama` `0.1.41` from Arch `extra` repo](https://archlinux.org/packages/extra/x86_64/ollama/) lists these: + `git` (for getting sources?) + `clblast` (something C++ related?) + `cmake` (for building `llama` from `.cpp` sources) + `cuda` (for Nvidia GPU support) + `rocm-hip-sdk` (for AMD GPU support) + `rocm-opencl-sdk` (for AMD GPU support) + `go` (for building `ollama` from `.go` sources) @oritwoen can you clarify what it does? It builds `ollama` on user's device before installation? ## Determining Arch package SO deps from sources It probably means that we will have to look at [dependency declarations in `llama` sources](https://github.com/ggerganov/llama.cpp): + [`CMakePresets.json`](https://github.com/ggerganov/llama.cpp/blob/5921b8f089d3b7bda86aac5a66825df6a6c10603/CMakePresets.json) + [`CMakeLists.txt`](https://github.com/ggerganov/llama.cpp/blob/5921b8f089d3b7bda86aac5a66825df6a6c10603/CMakeLists.txt) + [`Makefile`](https://github.com/ggerganov/llama.cpp/blob/5921b8f089d3b7bda86aac5a66825df6a6c10603/Makefile) + [`cmake`](https://github.com/ggerganov/llama.cpp/tree/5921b8f089d3b7bda86aac5a66825df6a6c10603/cmake) And at at [dependency declarations in `ollama` sources](https://github.com/ollama/ollama): + [`go.mod`](https://github.com/ollama/ollama/blob/476fb8e89242720a7cdd57400ba928de4dde9cc1/go.mod)

Flathub

As mentioned in dependency management guide, flatpaks can access their own shared dependencies installed as runtimes. If I understood it correctly, Freedesktop, GNOME & KDE runtimes should already contain necessary glibc, gcc & cxxabi shared objects.