Skip to content

Instantly share code, notes, and snippets.

@neuhaus
Last active May 2, 2025 12:29
Show Gist options
  • Save neuhaus/2fc66f9b1ebaa08ff95a527b91556113 to your computer and use it in GitHub Desktop.
Save neuhaus/2fc66f9b1ebaa08ff95a527b91556113 to your computer and use it in GitHub Desktop.
Restart ollama docker container if it no longer detects the nvidia GPU
#!/bin/sh
# restart ollama docker container if GPU is no longer recognized.
# call this script once per minute with cron.
if docker logs --since 63s ollama 2>&1 | grep -q "ggml_cuda_init: failed to initialize CUDA: no CUDA-capable device is detected"; then
docker restart ollama
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment