Created
June 17, 2024 10:23
-
-
Save t18n/96a8c345ee72d76ec5873de5ee58394f to your computer and use it in GitHub Desktop.
A script that allow to sync ollama models between computers. Useful for dotfiles backups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create a list of existing Ollama models | |
existingModels=$(ollama list | awk '{if(NR>1) print $1}') | |
# Create a list of Ollama models to pull | |
models=( | |
llama3:8b | |
phi3:mini | |
phi3:medium | |
phi3:medium-128k | |
aya:8b | |
gemma:7b | |
) | |
contains_element() { | |
local element | |
for element in "${@:2}"; do | |
if [[ "$element" == "$1" ]]; then | |
return 0 | |
fi | |
done | |
return 1 | |
} | |
for model in "${existingModels[@]}"; do | |
if ! contains_element "$model" "${models[@]}"; then | |
echo "Purging $model" | |
ollama rm $model | |
fi | |
done | |
# Install all new models | |
for model in ${models[@]}; do | |
echo "Pulling model $model" | |
ollama pull $model | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Edit your
models
list, runchmod +x ./sync-models.sh
and./sync-models.sh
to run the script.