ollama
ollama copied to clipboard
Download/Archive and move models offline
What are you trying to do?
I would like to be able to move ollama models between environments that are offline. There does not seem to be a supported official way to do this.
How should we solve this?
An ollama archive command would be great! Then the user could just ollama pull from the path the archive is saved in.
What is the impact of not solving this?
I am currently able to kinda work around by sending the ./ollama folder to a zip file on a machine that has internet access then copying it over. I must only do one model at a time or else the zips start to get impractical as I dont have a way to resolve multiple models.
I am worried about trying to import a new model into an existing environment as copying over the ./ollama folder seems sketchy as is.
Anything else?
Any advice or other workarounds would be appreciated. Thanks yall.
Hey @Solomin0 , you should be able to just copy/tar/rsync the models/
directory and it will work. You need both the blobs/
and manifests/
directory. If you want to put the models in a different directory you can use the OLLAMA_MODELS
env command when starting ollama serve
.
This last part is covered in the FAQ. I'm wondering if we should add something to include how to copy the models?
thanks @pdevine. When copying the blobs/manifests directories for model A I have that working fine. How could I go about introducing model B to the directories without overriding model A I guess is where I am struggling to maintain both.
You can copy them in; the blobs are content addressable (which is why they're called sha256-<hash>
) so there's no chance that something bad will happen unless you have a corrupt file (you can check for this by running sha2 -256
on the blob and it should have the same sha256 hash as the file name).
What platform are you on? There are lots of tools (like tar) which make this really easy.
@pdevine I am working on linux. unpacking my tar
tar -xvf models/ollama_models/ollama_models_jan.tar.gz -C /root/.ollama
My understanding was that unpacking is destructive similar to cp
but it seems more similar to mv
is that correct?
@Solomin0 That should work fine. It won't blow away any files which weren't also in the tar archive when you're unpacking it, although it will overwrite anything if there is a name collision. With the blobs that won't matter because it will just overwrite with the exact same data.
Great thanks!
Hey @pdevine I had to put this down for a bit but I am back and having issues. I am copying the models folder using
tar -czvf /workspace/outbox_tars/examplename_hash_size.tar.gz /models
Then i copy the tar from the initial docker container to my new one. In the new docker container I run the untar command
tar -xzvf examplename_hash_size.tar.gz -C /root/.ollama/
This looks like it works (it places in all the blob files and the manifest) but ollama list/ ollama run does not work and just returns a blank list. I am a bit stuck here any suggestions would be appreciated.
@Solomin0 are you running off of main by any chance? This change just got merged which I think should fix that.
This was it thanks! I had just built my dockers a couple hours too early I guess lol.