Skip to content

Run Ollama on Windows: A Comprehensive Guide (with Images)

Hey there! Want to run cool large language models (LLMs) on your own Windows computer, even without an internet connection? Then you definitely need to check out Ollama!

Don't worry if you're not a tech expert; this guide is tailored just for you. We'll walk you through the download, installation, and configuration process step by step, and show you how to verify that it's working correctly. You'll be up and running with local AI large language models in no time!

What will we be doing? Simply put, these steps:

  1. "Invite" it from the official website (download the installer)
  2. Give it a home and set some "rules" (configure environment variables, especially where to store models)
  3. Start it up and let it get to "work" (run the Ollama service)
  4. Check everything to make sure it's OK (verify the installation)

Ready? Let's Go!

Step 1: Download and Install Ollama

  1. Head straight to the official website for the download:

    On the download page, the big "Download for Windows" button should be pretty obvious. Click it! Your browser will start downloading a file called OllamaSetup.exe.

    Ollama Official Website Download

  2. "Brainless" Installation: Once the download is complete, find OllamaSetup.exe and double-click it. In the window that pops up, just click "Install". Then, patiently wait for the installation progress bar to finish. It will automatically prepare everything you need.

    Ollama Installation Interface

  3. Installation Complete - It Might Start Automatically: After installation, Ollama will usually start quietly in the background. You can find the Ollama icon in the taskbar notification area (where the time and network icons are) in the lower right corner of your screen. Right-click on it to select "Quit Ollama" to close it, or click "Logs" to see its runtime log.

    Ollama Taskbar Icon

Step 2: Configure Environment Variables (This Step is Crucial!)

After installing Ollama, we strongly recommend that you take a few minutes to configure the environment variables. This will allow you to better "command" Ollama, for example, to tell it where the model files should be stored.

What are "environment variables"?

Simply put, they are like "sticky notes" attached to your computer system, containing configuration information. Programs (like Ollama) can read these "notes" to know how to run, where to put things, and so on.

Some Commonly Used "Sticky Notes" for Ollama:

Variable Name (Note Title)Explanation (Note Content)Our Recommendation
OLLAMA_MODELSLocation of the model repository! By default, it puts the downloaded models in your user folder on the C drive (like C:\Users\YourUsername\.ollama\models). We strongly recommend moving it to another drive (like D or E)! Otherwise, the C drive will run out of space as the models get larger!For example, put it in E:\ollama\models (remember to create the E:\ollama folder first)
OLLAMA_HOSTWho can access Ollama? The default is 127.0.0.1, which means only your own computer can use it. If you want other devices on your local network (such as phones, tablets, or other computers) to connect to it, change it to 0.0.0.0.Set to 0.0.0.0 if you want local network sharing, otherwise the default is fine
OLLAMA_PORTThe "door number" of the Ollama service. The default is 11434. If this "door number" is occupied by another program, Ollama will not start. You can change it to an unused number (such as 8080).Default 11434, change it if there is a conflict
OLLAMA_ORIGINSWhich "visitors" (HTTP clients) are allowed to knock on the door. Generally, you don't need to set this specifically. To save trouble, you can set it to *, which means everyone is welcome.Set to * for local use
OLLAMA_KEEP_ALIVEHow long can the model "standby" after being loaded into memory? The default is 5m (5 minutes). If no one uses it after that time, the model will be unloaded from memory and reloaded next time. You can set it to a pure number (in seconds), 0 to "leave" immediately after use, or a negative number to "linger". Want faster response? We recommend setting it longer, like 24h (24 hours).Set to 24h for speed
OLLAMA_NUM_PARALLELHow many requests can be processed simultaneously. The default is 1. You can increase it appropriately if your computer configuration is good.The default is generally sufficient depending on your computer's performance
OLLAMA_MAX_LOADED_MODELSThe maximum number of models that can "live" in memory at the same time. The default is 1. If you frequently switch between different models, you can increase this, but it will consume more memory.Adjust if you have enough memory and need it
OLLAMA_DEBUGDo you want to see super detailed runtime logs? You can set it to 1 when debugging.Set to 1 when you need to troubleshoot problems
OLLAMA_MAX_QUEUEThe maximum length of the request queue. The default is 512. Generally, you don't need to change it.Default is fine

How to set these "sticky notes" (environment variables)?

  1. Find the Settings:

    • The fastest way: Search for "environment variables" in the Windows search box, then click "Edit the system environment variables".
    • Or: Right-click "This PC" -> "Properties" -> "Advanced system settings" -> "Environment Variables".
    • Or: Control Panel -> System and Security -> System -> Advanced system settings -> Environment Variables.
    • You can also: Press Win + R, enter sysdm.cpl, press Enter, go to the "Advanced" tab, and click "Environment Variables".
  2. Create a New "Sticky Note": In the "Environment Variables" window that pops up, find the "System variables" area below (if you only want the settings to apply to the current user, you can select the "User variables" area above), and click "New".

  3. Write the "Note Title" and "Content":

    • Enter the name from the table above in "Variable name", such as OLLAMA_MODELS.
    • Enter the value you want in "Variable value", such as E:\ollama\models.
    • Important Note: For path settings like OLLAMA_MODELS, make sure that the E:\ollama folder has already been created, or at least that the E: drive exists. Ollama may help you create the models subfolder, but to be safe, it's best to have the parent directory in place first.

    New System Variable

  4. Save the "Sticky Note": Click "OK".

  5. Repeat Adding: If you need to set other environment variables (such as OLLAMA_KEEP_ALIVE), repeat steps 2-4.

  6. "OK" All the Way: Click "OK" to close all the settings windows you opened.

  7. Make the Settings Take Effect: Restart Ollama (if it's running, exit and then start it again), or reopen a command prompt/PowerShell window. This will allow the new environment variables to be recognized.

Check if the Settings are Correct:

  1. Open Command Prompt (CMD) or PowerShell. (Remember to open a new one!)

  2. Enter echo %OLLAMA_MODELS% and press Enter. If the path you just set is displayed below (such as E:\ollama\models), then you're done!

    Verify Environment Variables

Step 3: Start the Ollama Service

Although it may have started automatically after installation, we sometimes need to control it manually. Or, if you have disabled automatic startup, you need to start it manually.

  1. Open Command Prompt (CMD) or PowerShell.

  2. Enter ollama serve and press Enter.

    bash
    ollama serve

    Having Trouble?

    If you see an error like this:

    Error: listen tcp 127.0.0.1:11434: bind: Only one usage of each socket address...

    This means that the "door number" 11434 is already in use! The most common reason is that Ollama is set to start automatically when you install it, so it's already running in the background. When you manually start it again, there is a conflict.

    What to do?

    • Method 1 (Recommended): Close the Ollama that is already running.

      1. Summon Task Manager by pressing Ctrl + Shift + Esc.
      2. If your Task Manager has a "Startup apps" or similar tab, find "Ollama" there, right-click on it, and select "Disable". This will prevent it from running automatically next time you start your computer. (Do this now, we will talk about it in detail later) Disable Ollama Startup (This image may need to be updated to the Task Manager startup tab interface)
      3. Switch to the "Processes" or "Details" tab, find all processes named ollama.exe, select them, and click "End task" in the lower right corner.
    • Method 2 (Not Recommended Unless You Understand the Consequences): Give Ollama a new "door number".

      1. Follow the method in step 2 to set the OLLAMA_PORT environment variable, giving it a port number that you are sure is not in use.
  3. After resolving the port conflict, try running the ollama serve command again. If there are no errors, it means the Ollama service has started successfully.

Make Sure It's Really "Listening":

  1. Open another Command Prompt (CMD) or PowerShell.

  2. Enter netstat -aon | findstr 11434 and press Enter. (If you changed the port, replace 11434 with the port number you changed it to)

  3. If you see output like TCP 127.0.0.1:11434 ... LISTENING, that's correct! It means Ollama is waiting to receive commands on port 11434.

    bash
    netstat -aon | findstr 11434

    The output will look something like this:

    TCP    127.0.0.1:11434        0.0.0.0:0              LISTENING       17556

    The last number (like 17556) is the Ollama process ID (PID).

  4. If you're curious, you can use tasklist | findstr "17556" (replace the number with the PID you see) to see who this process is.

    bash
    tasklist | findstr "17556"

    You should be able to see the ollama.exe information.

Step 4: Verify the Installation, Run a Model and Try It!

  1. Open Command Prompt (CMD) or PowerShell.

  2. Enter ollama -h and press Enter. If a bunch of Ollama help text comes out, congratulations, the installation is basically successful!

    bash
    ollama -h

    You should see output similar to this:

    Large language model runner
    
    Usage:
      ollama [flags]
      ollama [command]
    
    Available Commands:
      serve       Start ollama
      create      Create a model from a Modelfile
      show        Show information for a model
      run         Run a model
      pull        Pull a model from a registry
      push        Push a model to a registry
      list        List models
      ps          List running models
      cp          Copy a model
      rm          Remove a model
      help        Help about any command
      ... (There may be more)

Time to make it do something! Run the first model:

  1. Visit the Ollama Model Library and find a model that you like. For example, llama3 (Meta's new model, very popular) or qwen:7b (Alibaba's Qwen 7 billion parameter version).

  2. In the command prompt or PowerShell, enter ollama run model name, for example:

    bash
    ollama run llama3

    Or

    bash
    ollama run qwen:7b

    Then press Enter.

  3. Ollama will automatically start downloading the model files (if you set OLLAMA_MODELS, it will download to the folder you specified).

    • Be patient! The first time you run a model, you need to download it. The files are usually quite large (a few GB is normal), and the download speed depends on your internet speed. You can see the download progress bar.
  4. Once the download is complete, the model will start, and you can chat with it directly in the command line! Ask it anything and see its reaction. Want to exit the chat? Press Ctrl + D.

    Ollama Running Llama3 Model

Step 5: Don't Want Automatic Startup? Turn It Off!

Ollama defaults to adding itself to the Windows startup items during installation. If you don't think it's necessary to have it run automatically every time you start your computer (for example, if you want to control it manually, or if you already have a lot of startup items), you can turn it off.

  • As of the date of this article (approximately mid-2024), the cancellation method is as follows (the interface may vary slightly depending on the Windows version):
  1. Summon Task Manager again (Ctrl + Shift + Esc).

  2. Find the "Startup apps" (or just "Startup") tab.

  3. Find "ollama.exe" (or just "Ollama Application") in the list.

  4. Right-click on it and select "Disable". Done! It won't come out automatically next time you start your computer.

    Disable Ollama Startup (This image is the Task Manager startup tab interface and is very appropriate)

Stuck? Check Out These Common Issues

  • Ollama Won't Start?
    • The most likely reason: The port is in use (see the solution in step 3).
    • Check if the environment variables (step 2) are set correctly, and make sure you haven't made any mistakes in the paths.
    • If all else fails, check the Ollama logs (right-click the taskbar icon -> Logs), which may contain clues.
  • Model Downloads are Extremely Slow?
    • Check if your network is not performing well.
    • (Advanced Tip) You can try configuring a domestic mirror source, but this is a bit more complex and beginners can ignore it for now.
  • Ollama Feels Laggy When Running?
    • See if your computer configuration is a bit weak. Running large models is quite memory and graphics card intensive (if using GPU acceleration).
    • Try setting OLLAMA_KEEP_ALIVE longer (e.g., 24h) to avoid repeated loading and unloading of the model.
    • Are too many models running at the same time? Or are there too many concurrent requests? (Check the OLLAMA_MAX_LOADED_MODELS and OLLAMA_NUM_PARALLEL settings)

Alright! At this point, you should have successfully installed and configured Ollama on Windows, and even chatted with your first AI model! Doesn't it feel rewarding?