@@ -117,6 +117,80 @@ install-opentabletdriver:
117117 systemctl enable --user --now arch-opentabletdriver.service && \
118118 distrobox enter -n arch -- bash -c 'distrobox-export --app otd-gui'
119119
120+ # This installs ollama, a way to run various open LLMs locally on the CPU or GPU
121+ install-ollama :
122+ # !/usr/bin/env bash
123+ echo 'Follow the prompts and check the tutorial : '
124+ echo
125+ GPU_CHOICES =()
126+ # Detect nvidia drivers
127+ if which nvidia-smi > /dev/null 2>&1; then
128+ GPU_CHOICES+ =("Nvidia (CUDA)")
129+ fi
130+ # Detect radeon hardware
131+ if lspci | grep ' VGA ' | grep -sq Radeon; then
132+ GPU_CHOICES+ =("AMD (ROCm)")
133+ fi
134+ GPU_SELECTION =$(printf '%s\n' "${GPU_CHOICES[@]}" | gum choose --select-if-one --header "Select the type of graphics card you have" )
135+ echo "Selected ${GPU_SELECTION}!"
136+ case "$GPU_SELECTION" in
137+ "Nvidia (CUDA)")
138+ IMAGE =latest
139+ CUSTOM_ARGS="AddDevice=nvidia.com/gpu =all"
140+ ;;
141+
142+ "AMD (ROCm)")
143+ IMAGE =rocm
144+ read -r -d '' CUSTOM_ARGS <<-'EOF'
145+ AddDevice =/dev/dri
146+ AddDevice =/dev/kfd
147+ EOF
148+ ;;
149+ esac
150+
151+ read -r -d '' QUADLET <<-EOF
152+ [Unit]
153+ Description =The Ollama container
154+ After =local-fs.target
155+
156+ [Service]
157+ Restart =always
158+ TimeoutStartSec =60
159+ # Ensure there's a userland podman.sock
160+ ExecStartPre =/bin/systemctl --user enable podman.socket
161+ # Ensure that the dir exists
162+ ExecStartPre =-mkdir -p %h/.ollama
163+
164+ [Container]
165+ ContainerName =ollama
166+ PublishPort =11434:11434
167+ RemapUsers =keep-id
168+ RunInit =yes
169+ NoNewPrivileges =no
170+ Volume =%h/.ollama:/.ollama
171+ PodmanArgs=--userns =keep-id
172+ PodmanArgs=--group-add =keep-groups
173+ PodmanArgs=--ulimit =host
174+ PodmanArgs=--security-opt=label =disable
175+ PodmanArgs=--cgroupns =host
176+
177+ Image =docker.io/ollama/ollama:${IMAGE}
178+ ${CUSTOM_ARGS}
179+
180+ [Install]
181+ RequiredBy =default.target
182+ EOF
183+ if [ ! -f ~/.config/containers/systemd/ollama.container ]; then
184+ mkdir -p ~/.config/containers/systemd
185+ echo "${QUADLET}" > ~/.config/containers/systemd/ollama.container
186+ else
187+ echo "Ollama container already exists, skipping..."
188+ fi
189+ systemctl --user daemon-reload
190+ systemctl --user start ollama.service
191+ echo "Please install the ollama cli via \`brew install ollama\`"
192+ echo "If you do not have brew yet, please install it via \`ujust install-brew\`"
193+
120194# Create fedora distrobox if it doesn't exist
121195[private]
122196distrobox-check-fedora :
0 commit comments