-
-
Notifications
You must be signed in to change notification settings - Fork 175
/
bluefin-tools.just
99 lines (90 loc) · 3.44 KB
/
bluefin-tools.just
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# vim: set ft=make :
########################
### bluefin-tools.just
########################
## Standardized verbs
# configure- = configure something that is pre-installed on the image
# install- = install something, no uninstall or configuration provided
# setup- = install something and also provide configuration and/or uninstallation options
# toggle- = turn something on/off, logic can be automatic or manual selection
# fix- = apply fix/patch/workaround for something
# foo = no verb is used for shortcuts or something deemed important enough to use a super memorable name
# Run pytorch
pytorch:
echo 'Follow the prompts and check the tutorial: https://docs.anaconda.com/free/anaconda/jupyter-notebooks/'
podman pull docker.io/continuumio/miniconda3
podman run -i -t -p 8888:8888 docker.io/continuumio/miniconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir \
/opt/notebooks && /opt/conda/bin/jupyter notebook \
--notebook-dir=/opt/notebooks --ip='*' --port=8888 \
--no-browser --allow-root"
# Run Tensorflow
tensorflow:
echo 'Follow the prompts and check the tutorial: https://www.tensorflow.org/tutorials/quickstart/beginner'
podman pull docker.io/tensorflow/tensorflow:latest
podman run -it -p 8888:8888 docker.io/tensorflow/tensorflow:latest-jupyter # Start Jupyter server
# Setup a local Ollama instance in a container. Detect hardware, offer a choice if needed.
ollama:
#!/usr/bin/env bash
echo 'Follow the prompts and check the tutorial: '
echo
GPU_CHOICES=()
# Detect nvidia drivers
if which nvidia-smi > /dev/null 2>&1; then
GPU_CHOICES+=("Nvidia (CUDA)")
fi
# Detect radeon hardware
if lspci | grep ' VGA ' | grep -sq Radeon; then
GPU_CHOICES+=("AMD (ROCm)")
fi
GPU_SELECTION=$(printf '%s\n' "${GPU_CHOICES[@]}" | gum choose --select-if-one --header "Select the type of graphics card you have")
echo "Selected ${GPU_SELECTION}!"
case "$GPU_SELECTION" in
"Nvidia (CUDA)")
IMAGE=latest
CUSTOM_ARGS="AddDevice=nvidia.com/gpu=all"
;;
"AMD (ROCm)")
IMAGE=rocm
read -r -d '' CUSTOM_ARGS <<-'EOF'
AddDevice=/dev/dri
AddDevice=/dev/kfd
EOF
;;
esac
read -r -d '' QUADLET <<-EOF
[Unit]
Description=The Ollama container
After=local-fs.target
[Service]
Restart=always
TimeoutStartSec=60
# Ensure there's a userland podman.sock
ExecStartPre=/bin/systemctl --user enable podman.socket
# Ensure that the dir exists
ExecStartPre=-mkdir -p %h/.ollama
[Container]
ContainerName=ollama
PublishPort=11434:11434
RemapUsers=keep-id
RunInit=yes
NoNewPrivileges=no
Volume=%h/.ollama:/.ollama
PodmanArgs=--userns=keep-id
PodmanArgs=--group-add=keep-groups
PodmanArgs=--ulimit=host
PodmanArgs=--security-opt=label=disable
PodmanArgs=--cgroupns=host
Image=docker.io/ollama/ollama:${IMAGE}
${CUSTOM_ARGS}
[Install]
RequiredBy=default.target
EOF
if [ ! -f ~/.config/containers/systemd/ollama.container ]; then
mkdir -p ~/.config/containers/systemd
echo "${QUADLET}" > ~/.config/containers/systemd/ollama.container
else
echo "Ollama container already exists, skipping..."
fi
systemctl --user daemon-reload
systemctl --user start ollama.service
echo "Please install the ollama cli via \`brew install ollama\`"