this post was submitted on 08 Feb 2024
98 points (97.1% liked)
Linux
48389 readers
1085 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
FOSS apps (all on Flathub)
Some of the AI related apps I've been using that are both Free Software and offline (where it runs on your computer without using network services in the cloud) are:
OCR: "Frog" can take screenshots, select images, accept drag and drop, and you can paste an image from the clipboard. It'll read the text on the images and immediately have a text area with the result. https://flathub.org/apps/com.github.tenderowl.frog — it's powered by Tesseract. Note: The completely optional text-to-speech that Frog has does use an online service. But the rest is offline.
Speech to text: "Speech Note" does text to speech, speech to text, and translations... all locally on your computer, and it supports GPU acceleration (which isn't needed, but it makes it a little faster). https://flathub.org/apps/net.mkiol.SpeechNote — This is basically the all-in-one "Swiss army knife" of ML text processing. Thanks to being a Flatpak, you don't have to do anything special for the dependencies. It's all taken care of for you. It also has tons of different models (for different voices, different backends) all available from within the UI, which just needs a click for downloading.
Upscaling images: There are two that do something similar, using some of the same backends. A nice and simple one is "Upscaler". https://flathub.org/apps/io.gitlab.theevilskeleton.Upscaler Another one that's cross platform is "Upscayl" https://flathub.org/apps/org.upscayl.Upscayl — these both use ESRGAN and Waifu2x in the background.
Closed captioning: "Live Captions" uses an ML model to transcribe text realtime. It's wonderful for when a video doesn't have subtitles, or when you're participating in a video call (which might also not have CC). There's also a toggle mode that will transcribe based on microphone input. The default is to use system audio. https://flathub.org/apps/net.sapples.LiveCaptions
Web page translations: Firefox, for the past few releases, has the ability to translate web pages completely local in-browser. It does need to download a small model file (a quantized one around 20 megabytes per language pair), but this happens automatically on first use. All you need to do is click the translate icon (when it's auto-detected) or go to the menu and select "Translate page...". Firefox is located in your distribution already (and is usually installed by default in most Linux distributions) and is available as an official package from Mozilla on Flathub as well. Newer versions keep improving on this, improving speed (it's pretty quick already), improving accuracy, improving reliability (sometimes you have to try to translate a couple of times on some pages), and adding languages. But what's there in the release of Firefox is already great.
Chat and image generation (more advanced)
While all the above are graphical apps and on Flathub (some may have distro packages too), there are some additional AI/ML things you can run on Linux as well:
You can run Ollama in a container to make it even easier. Even a Podman container on your user account works. (You don't need to set it up as a system container.) The instructions for Docker work on Podman (just swap the
docker
command forpodman
instead).While the official instructions only list CPU (which is fine for some of the smaller models) and NVidia, it's also possible to use an AMD GPU too:
llama2
is the default ML; there are so many others available. Mixtral is a good one if you have enough vram on your GPU. Whatever you specify, it will auto-download and set it up for you. You only need to wait the first time. (The ROCm version of takes a while to download. Each model varies. The good thing is, it's all cached for subsequent uses.)If you want a web UI like ChatGPT, then you could also run this instead of the command line interaction command:
...and visit http://localhost:3000/
When done, run
podman stop ollama
andpodman stop ollama-webui
to free up resources from your GPU.There are also integrations for text editors and IDEs, similar to GitHub's CoPilot. Neovim has a few already. VS Code (or VS Codium) has some too (like twinny and privy).
Krita, GIMP, and Blender all have plugins that can interface with some of these too (usually using a SD Automatic111 API).
For Stable Diffusion on AMD, you need to have ROCm installed and might need to set or use an environment variable to make it work with your card. Something like:
HSA_OVERRIDE_GFX_VERSION=11.0.0
orHSA_OVERRIDE_GFX_VERSION=10.3.0
(depending on your GPU). Prefixing means just putting that at the beginning of the the command with a space and then the rest of the command. Setting it as a variable depends on your shell. You might need toexport
it for some (like for bash). Prefixing it is fine though, especially when you use ctrl+r to do a substrang search in your shell history (so you don't need to retype it or remember silly-long commands).As using these image generating apps pulls down a lot of Python libraries, I'd suggest considering setting up a separate user account instead of using your own, so the app doesn't have access to your local files (like stuff in ~/.ssh/, ~/.local/, your documents, etc.). Setting up containers for these is not so easy (yet), sadly. Some people have done it. And they do run in a toolbox or distrobox podman container... but toolbox and distrobox containers don't really contain so much, so you're better off using podman (with a "docker" container) directly or running it as a separate account for some type of isolation from your user account files.
Everything else above is at least contained (via containers or Flatpak) to some degree... but stuff locally via pip installs can do anything. And it's not just hypothetical either, for example: PyTorch nightly was compromised for a few days on Christmas of 2022.
There are some graphical apps on Flathub for connecting to Stable Diffusion and a ChatGPT AI (which ollama now has)... but in the course of setting them up, you basically have a web and/or text-based UI to interact with.
Huh, thanks to this kick-ass comment, I'm now running some different llama models locally on my machine.
For those wondering, all of them that I've tried (llama2, llama2-uncensored, and mistral) all respond really quickly and the text comes faster than I can read. Quicker wouldn't seem to be of any use for me so I'm happy.
Specs:
Works fine on Windows though WSL 2 on Ubuntu 22.04.
Yeah, some of the smaller models are even reasonable on my old laptop in CPU mode.
General rule of thumb: The larger the model, the better it is. But not necessarily. 😉 I've found
zephyr
andmistral
are both quite good for a tradeoff and work on CPU. Of the ones that really need more RAM and/or a GPU with a lot of vRAM,mixtral
seems like the best.Additional fun is to use a
Modalfile
(which is like aContainerfile
, but is a recipe for models instead of containers) to customize a local model on top of one of the existing ones.For a simple one to demonstrate, I have a system instruction to output everything in the form of the poem "This Is Just To Say", but customized per topic.
It really works best with
mixtral
(I've tried other ones, especially smaller ones):Yes, you just instruct the system with natural text like that and it (usually) abides. I tried it without the poem being referenced inline, and it mostly worked fine... but it works even better being mentioned in the file.
I have that saved in
~/Projects/ollama/
asModelfile.fun-plums
I run the server almost as above, but now also pass in my ollama project directory as a mounted volume with
z
(for SELinux mapping)... don't forget to have runsudo setsebool container_use_devices=true
first, else it won't work:(You can run this command if you already have the server running. It will replace it with the new one. This is for AMD. You'd want to use the NVidia or CPU container if you don't have an AMD card. The CPU container is the fasted to download. The version here is newer than the one for AMD that I listed above, so it might be a multi-gigabyte download if you don't have this new one yet. The important and new part is
~/Projects/ollama:/models:z
)Then, create the model. This will be almost instant if you already have the base model downloaded (in this case,
mixtral
), otherwise it will auto-download the base model:(The path to the model in this command is the internal path from the point of view within the container.)
Then, you run it like any other model.
Here's me running it, and bringing up the topic of leftover pizza.
You can also paste the text from the reader mode of an article and it'll summarize it with a poem based on that one. 🤣
For example, copying and pasting the text from https://www.theverge.com/2024/2/10/24068931/star-wars-phantom-menace-theater-showings-25th-anniversary-may resulted in:
This is interesting.
Since all the talk about LLMs and "AI" started, I've been hoping that someone would create a news app that is essentially self-hosted RSS server (like FreshRSS) + a personally trained LLM that would only serve me news it has learned I'm interested in. For example, I don't care about sports or celebrities and almost never want to see news about those topics. Conversely, I want news relevant to my geographical area, my area of work, and my hobby interests, etc.
Considering these can be run on consumer hardware, I think we're at the point where someone with the know-how just needs to connect the two.
I wonder if the news preferences could be loaded into a Modalfile so it can persist - as I understand it, this would be the only way preferences would survive separate chat sessions.
I love RSS but I have to be extremely choosy about which feeds I subscribe to because it can quickly become overwhelming given the number of articles posted daily.
Amazing thanks for breaking it down!
Thank you 😊
this is awesome! i wish those awesome tools were highlighted in flathub!