Just as simply as this:
sudo systemctl edit ollama.service
Then add the following lines (to set to 64k tokens context size):
[Service]Environment="OLLAMA_CONTEXT_LENGTH=64000"
Save and exit, then restart Ollama:
sudo service ollama restart
And you’re done:
ollama psNAME ID SIZE PROCESSOR CONTEXT UNTILgpt-oss:20b 17052f91a42e 15 GB 100% GPU 64000 4 minutes from now
Note: Tested on Ubuntu 24.04 with Ollama 0.15
That’s it, Enjoy!