a known issue of ollama under ubuntu with nvidia cards, sometimes it will lose the access to gpu so turn to cpu.
use following script to restart ollama & nvidia driver so it will work again.
credits to: https://www.reddit.com/r/ollama/comments/1cxx49q/comment/lq6zq31/