[GH-ISSUE #14027] OLLAMA_CONTEXT_LENGTH Linux environment variable not working #9167

Closed
opened 2026-04-12 22:00:46 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @jasonculligan on GitHub (Feb 2, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/14027

What is the issue?

Setting the OLLAMA_CONTEXT_LENGTH lLinux bash environment variable via /etc/environment does not affect the actual context window when models are run.

$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
OLLAMA_CONTEXT_LENGTH=8192

Confirm that the variable is set:

$ echo $OLLAMA_CONTEXT_LENGTH
8192

Run a model:

$ ollama run gpt-oss:20b
>>> Send a message (/? for help)

Open a new window and check the output of ollama ps

$ ollama ps
NAME           ID              SIZE     PROCESSOR    CONTEXT    UNTIL                   
gpt-oss:20b    17052f91a42e    14 GB    100% GPU     4096       About a minute from now 

Note that the default context window of 4096 is still set and the $OLLAMA_CONTEXT_LENGTH variable, though correctly set, is ignored.

Relevant log output

As above

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.15.4

Originally created by @jasonculligan on GitHub (Feb 2, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/14027 ### What is the issue? Setting the OLLAMA_CONTEXT_LENGTH lLinux bash environment variable via /etc/environment does not affect the actual context window when models are run. ```console $ cat /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" OLLAMA_CONTEXT_LENGTH=8192 ``` Confirm that the variable is set: ```console $ echo $OLLAMA_CONTEXT_LENGTH 8192 ``` Run a model: ```console $ ollama run gpt-oss:20b >>> Send a message (/? for help) ``` Open a new window and check the output of `ollama ps` ```console $ ollama ps NAME ID SIZE PROCESSOR CONTEXT UNTIL gpt-oss:20b 17052f91a42e 14 GB 100% GPU 4096 About a minute from now ``` Note that the default context window of 4096 is still set and the $OLLAMA_CONTEXT_LENGTH variable, though correctly set, is ignored. ### Relevant log output ```shell As above ``` ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.15.4
GiteaMirror added the bug label 2026-04-12 22:00:46 -05:00
Author
Owner

@rick-github commented on GitHub (Feb 2, 2026):

You have to set the variable in the environment of the server.

<!-- gh-comment-id:3835730410 --> @rick-github commented on GitHub (Feb 2, 2026): You have to set the variable in the environment of the server.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#9167