[GH-ISSUE #1165] Provide command to export downloaded models #589

Closed
opened 2026-04-12 10:17:40 -05:00 by GiteaMirror · 10 comments
Owner

Originally created by @biandayu on GitHub (Nov 17, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/1165

Is there any way to import and export downloaded models? In this way, there is no need to use ollama pull to download again on another local machine.

Thanks

Originally created by @biandayu on GitHub (Nov 17, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/1165 Is there any way to import and export downloaded models? In this way, there is no need to use ollama pull to download again on another local machine. Thanks
Author
Owner

@horw commented on GitHub (Nov 17, 2023):

Hi @biandayu, I used it on Ubuntu.
Important files are saved in the .ollama folder, so you can simply copy it to your new device.
The full path is:
/home/UserName/.ollama/models/
There are two folders:
manifests and blob.
The manifests folder contains metadata for the models, and the blob folder contains the models themselves.

<!-- gh-comment-id:1815813028 --> @horw commented on GitHub (Nov 17, 2023): Hi @biandayu, I used it on Ubuntu. Important files are saved in the `.ollama` folder, so you can simply copy it to your new device. The full path is: `/home/UserName/.ollama/models/` There are two folders: `manifests` and `blob`. The `manifests` folder contains metadata for the models, and the `blob` folder contains the models themselves.
Author
Owner

@horw commented on GitHub (Nov 17, 2023):

BTW, maybe using a custom PATH or import/export models command would be helpful for users? If the maintainer agrees, I can try to implement it.

<!-- gh-comment-id:1815818871 --> @horw commented on GitHub (Nov 17, 2023): BTW, maybe using a custom PATH or import/export models command would be helpful for users? If the maintainer agrees, I can try to implement it.
Author
Owner

@biandayu commented on GitHub (Nov 17, 2023):

Thanks @horw, I use it on WSL(ubuntu).
The model files are in /usr/share/ollama/.ollama. I've tried copy them to a new PC. The ollama list command does display the newly copied models, but when using the ollama run command to run the model, ollama starts to download again.

<!-- gh-comment-id:1815850159 --> @biandayu commented on GitHub (Nov 17, 2023): Thanks @horw, I use it on WSL(ubuntu). The model files are in /usr/share/ollama/.ollama. I've tried copy them to a new PC. The ollama list command does display the newly copied models, but when using the ollama run command to run the model, ollama starts to download again.
Author
Owner

@horw commented on GitHub (Nov 17, 2023):

What about this directory, /home/UserName/.ollama/models/? Do you have any files here?

<!-- gh-comment-id:1815929277 --> @horw commented on GitHub (Nov 17, 2023): What about this directory, `/home/UserName/.ollama/models/`? Do you have any files here?
Author
Owner

@biandayu commented on GitHub (Nov 17, 2023):

There is no such files & dir under HOME.

home

<!-- gh-comment-id:1815936999 --> @biandayu commented on GitHub (Nov 17, 2023): There is no such files & dir under HOME. ![home](https://github.com/jmorganca/ollama/assets/52662468/4d69fc52-7e8b-43d1-a063-0672cefadff2)
Author
Owner

@horw commented on GitHub (Nov 17, 2023):

I just checked the code, and Ollama actually has an option to set up a custom path for the models directory using the OLLAMA_MODELS environment variable. On the other hand, if you don't set it up, it will look to the HOME environment variable.

// modelsDir returns the value of the OLLAMA_MODELS environment variable or the user's home directory if OLLAMA_MODELS is not set.
// The models directory is where Ollama stores its model files and manifests.
func modelsDir() (string, error) {
	if models, exists := os.LookupEnv("OLLAMA_MODELS"); exists {
		return models, nil
	}
	home, err := os.UserHomeDir()
	if err != nil {
		return "", err
	}
	return filepath.Join(home, ".ollama", "models"), nil
}
<!-- gh-comment-id:1815951368 --> @horw commented on GitHub (Nov 17, 2023): I just checked the code, and Ollama actually has an option to set up a custom path for the models directory using the OLLAMA_MODELS environment variable. On the other hand, if you don't set it up, it will look to the HOME environment variable. ```go // modelsDir returns the value of the OLLAMA_MODELS environment variable or the user's home directory if OLLAMA_MODELS is not set. // The models directory is where Ollama stores its model files and manifests. func modelsDir() (string, error) { if models, exists := os.LookupEnv("OLLAMA_MODELS"); exists { return models, nil } home, err := os.UserHomeDir() if err != nil { return "", err } return filepath.Join(home, ".ollama", "models"), nil } ```
Author
Owner

@horw commented on GitHub (Nov 17, 2023):

You can check this one:
41434a7cdc/docs/faq.md (how-can-i-change-where-ollama-stores-models)

<!-- gh-comment-id:1815954378 --> @horw commented on GitHub (Nov 17, 2023): You can check this one: https://github.com/jmorganca/ollama/blob/41434a7cdcf33918ae2d37eb23d819ef7361e843/docs/faq.md#how-can-i-change-where-ollama-stores-models
Author
Owner

@conradax commented on GitHub (Dec 21, 2023):

What is the correct way to copy ollama models to another machine?

I copied the entire ~/.ollama folder to another machine, ollama list lists nothing and ollama serve side got errors.
Is there a way to get some log or verbose output of ollama serve?

I'm dont know much about go. seems it gets error when checking manifest of the model:
(The code is from version 0.1.17, the log in details below is from version 0.1.16, so the line number is a bit off, 711->715)
a607d922f0/server/routes.go (L707-L721)

details

The ~/.ollama folder is copied from plwgwin to plwgThink14pW10.

On plwgThink14pW10, I ran ollama serve, in another terminal window i ran ollama list, exactly how i use it on plwgwin.
in ollama serve window prints:

conradax@plwgThink14pW10:~$ ./ollama-linux-amd64 start
2023/12/21 22:55:10 images.go:737: total blobs: 0
2023/12/21 22:55:10 images.go:744: total unused blobs removed: 0
2023/12/21 22:55:10 routes.go:871: Listening on 127.0.0.1:11434 (version 0.1.16)
2023/12/21 22:55:10 routes.go:891: warning: gpu support may not be enabled, check that you have installed GPU drivers: nvidia-smi command failed
[GIN] 2023/12/21 - 22:55:33 | 200 |          66µs |       127.0.0.1 | HEAD     "/"
2023/12/21 22:55:33 routes.go:711: skipping file: /home/conradax/.ollama/models/manifests
2023/12/21 22:55:33 routes.go:711: skipping file: /home/conradax/.ollama/models/manifests
2023/12/21 22:55:33 routes.go:711: skipping file: /home/conradax/.ollama/models/manifests
[GIN] 2023/12/21 - 22:55:33 | 200 |      2.1274ms |       127.0.0.1 | GET      "/api/tags"

and i got nothing in ollama list terminal:

conradax@plwgThink14pW10:~$ ./ollama-linux-amd64 list
NAME    ID      SIZE    MODIFIED
conradax@plwgThink14pW10:~$

and this is what it prints on plwgwin:

conradax@plwgwin:~$ ./ollama-linux-amd64 list
NAME                    ID              SIZE    MODIFIED
llama2-chinese:13b      990f930d55c5    7.4 GB  2 days ago
llama2-uncensored:7b    44040b922233    3.8 GB  2 days ago
mixtral:8x7b            99a9202f8a7a    26 GB   2 days ago
conradax@plwgwin:~$

more info about two system:

conradax@plwgwin:~$ uname -a
Linux plwgwin 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# host: Windows Server 2022 Standard 21H2 20348.2159 (In Promox VE)

conradax@plwgThink14pW10:~$ uname -a
Linux plwgThink14pW10 4.4.0-19041-Microsoft #3570-Microsoft Fri Sep 29 17:00:00 PST 2023 x86_64 x86_64 x86_64 GNU/Linux
# host: Windows 10 Professional 22H2 19045.3570

  • username and path are same on both machine
  • v0.1.16 and v0.1.17 are both not working, the only difference is the line number of error msg.
  • I also tried adding 2>&1 but didn't get different output.
<!-- gh-comment-id:1866623975 --> @conradax commented on GitHub (Dec 21, 2023): What is the correct way to copy ollama models to another machine? I copied the entire `~/.ollama` folder to another machine, `ollama list` lists nothing and `ollama serve` side got errors. Is there a way to get some log or verbose output of `ollama serve`? I'm dont know much about go. seems it gets error when checking manifest of the model: (The code is from version 0.1.17, the log in details below is from version 0.1.16, so the line number is a bit off, 711->715) https://github.com/jmorganca/ollama/blob/a607d922f0bd514e709b2392be9d5d5d2df3028a/server/routes.go#L707-L721 <details> <summary>details</summary> The `~/.ollama` folder is copied from `plwgwin` to `plwgThink14pW10`. On `plwgThink14pW10`, I ran `ollama serve`, in another terminal window i ran `ollama list`, exactly how i use it on `plwgwin`. in `ollama serve` window prints: ```shell conradax@plwgThink14pW10:~$ ./ollama-linux-amd64 start 2023/12/21 22:55:10 images.go:737: total blobs: 0 2023/12/21 22:55:10 images.go:744: total unused blobs removed: 0 2023/12/21 22:55:10 routes.go:871: Listening on 127.0.0.1:11434 (version 0.1.16) 2023/12/21 22:55:10 routes.go:891: warning: gpu support may not be enabled, check that you have installed GPU drivers: nvidia-smi command failed [GIN] 2023/12/21 - 22:55:33 | 200 | 66µs | 127.0.0.1 | HEAD "/" 2023/12/21 22:55:33 routes.go:711: skipping file: /home/conradax/.ollama/models/manifests 2023/12/21 22:55:33 routes.go:711: skipping file: /home/conradax/.ollama/models/manifests 2023/12/21 22:55:33 routes.go:711: skipping file: /home/conradax/.ollama/models/manifests [GIN] 2023/12/21 - 22:55:33 | 200 | 2.1274ms | 127.0.0.1 | GET "/api/tags" ``` and i got nothing in `ollama list` terminal: ```shell conradax@plwgThink14pW10:~$ ./ollama-linux-amd64 list NAME ID SIZE MODIFIED conradax@plwgThink14pW10:~$ ``` and this is what it prints on `plwgwin`: ```shell conradax@plwgwin:~$ ./ollama-linux-amd64 list NAME ID SIZE MODIFIED llama2-chinese:13b 990f930d55c5 7.4 GB 2 days ago llama2-uncensored:7b 44040b922233 3.8 GB 2 days ago mixtral:8x7b 99a9202f8a7a 26 GB 2 days ago conradax@plwgwin:~$ ``` more info about two system: ```shell conradax@plwgwin:~$ uname -a Linux plwgwin 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux # host: Windows Server 2022 Standard 21H2 20348.2159 (In Promox VE) conradax@plwgThink14pW10:~$ uname -a Linux plwgThink14pW10 4.4.0-19041-Microsoft #3570-Microsoft Fri Sep 29 17:00:00 PST 2023 x86_64 x86_64 x86_64 GNU/Linux # host: Windows 10 Professional 22H2 19045.3570 ``` * username and path are same on both machine * v0.1.16 and v0.1.17 are both not working, the only difference is the line number of error msg. * I also tried adding ` 2>&1` but didn't get different output. </details>
Author
Owner

@xunx911 commented on GitHub (Jan 2, 2024):

@conradax 我在使用pycharm远程主机上传时遇到了同样的问题,然后我以命令行使用sftp上传就解决了

<!-- gh-comment-id:1874022058 --> @xunx911 commented on GitHub (Jan 2, 2024): @conradax 我在使用pycharm远程主机上传时遇到了同样的问题,然后我以命令行使用sftp上传就解决了
Author
Owner

@jmorganca commented on GitHub (Feb 20, 2024):

Merging this with https://github.com/ollama/ollama/issues/335

<!-- gh-comment-id:1953335080 --> @jmorganca commented on GitHub (Feb 20, 2024): Merging this with https://github.com/ollama/ollama/issues/335
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#589