How to Change Ollama Model Save Location on Windows: Step-by-Step Guide 2024

Ollama

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.

Step-by-Step Guide

1. Open the Environment Variables Window

  1. Press Win + X to open the Power User menu.
  2. Select System from the menu.
    • Ollama
  3. In the System window, click on Advanced system settings on the left sidebar.
    • Advance System setting
  4. In the System Properties window, click on the Environment Variables... button at the bottom.
    • Environment variables

2. Create a New Environment Variable for Ollama

  1. In the Environment Variables window, look for the System variables section.
  2. Click on the New... button under the System variables section.
  3. 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 enter D:\OllamaModels.
  • Click OK to save the new environment variable.
Ollama Environment Variable

3. Verify the New Save Location

  1. Restart the Ollama to ensure it recognizes the new environment variable.
  2. Wait for about 30 seconds to ensure the server has restarted completely.
  3. The new directory specified should now automatically contain a folder named models\blobs.

4. Download a Model to Confirm the Change

  1. Go to the Ollama website and download a new model.
    • e.g. run this command in cmd ollama run phi3
    • ollama run phi3
  2. 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.