Export/Backup Ollama Model

The following commands help to export/backup the ollama models which allows to quick restore the models or setup an offline machine using file transfer.

Pull a model from registry

ollama pull llava:7b

Export the model

mkdir -p llava_7b_backup

cd llava_7b_backup

ollama show --modelfile llava:7b > Modelfile

cat Modelfile | grep -E '^FROM' | cut -d ' ' -f 2 | xargs -I {} cp {} .

cat Modelfile | grep '# FROM' | cut -d ' ' -f 3 | xargs -I {} echo 'ollama create {} -f Modelfile' > readme.txt

sed -i '' -E 's/^FROM.*blobs/FROM ./g' Modelfile

Import the model 

cd llava_7b_backup

ollama create llava:7b -f Modelfile

Run the model

ollama run llava:7b

Remove the model

ollama rm llava:7b

Comments

Popular posts from this blog

JSON with curl and jq

Import self signed in Linux for Chrome / Chromium headless testing

Colima - Drop In replacement for Docker Desktop for Mac and Linux