When you install a model for Ollama on your Windows PC, the model files are saved in the default directory under your user profile C:\Users\YourUserName\.ollama\models
. However, if you have a separate drive dedicated to storage and want to save the model files there instead, you can change the default save location by setting an environment variable. This guide will walk you through the steps to achieve this.
Table of Contents
Step-by-Step Guide
1. Open the Environment Variables Window
- Press
Win + X
to open the Power User menu. - Select
System
from the menu. - In the System window, click on
Advanced system settings
on the left sidebar. - In the System Properties window, click on the
Environment Variables...
button at the bottom.
2. Create a New Environment Variable for Ollama
- In the Environment Variables window, look for the System variables section.
- Click on the
New...
button under the System variables section. - In the New System Variable dialog:
- For Variable name, enter
OLLAMA_MODELS
. (Make sure the variable name is in uppercase.) - For Variable value, enter the path where you want to save the model files. For example, if you want to save them in the D drive under a folder named
OllamaModels
, you would enterD:\OllamaModels
. - Click
OK
to save the new environment variable.
3. Verify the New Save Location
- Restart the Ollama to ensure it recognizes the new environment variable.
- Wait for about 30 seconds to ensure the server has restarted completely.
- The new directory specified should now automatically contain a folder named
models\blobs
.
4. Download a Model to Confirm the Change
- Go to the Ollama website and download a new model.
- e.g. run this command in cmd
ollama run phi3
- e.g. run this command in cmd
- Check the new directory (e.g.,
D:\OllamaModels\models\blobs
) to see if the model files are being saved there.
Notes
- Ensure you restart the Ollama server after setting the environment variable for the changes to take effect.
- Make sure the directory path you enter in the environment variable exists and is accessible.
- To read more about Ollama click here
We hope this guide was helpful. If you have any questions or run into issues, feel free to reach out.