Portrait of Michael Limberger

Michael Limberger

Need me? Email mike@limberger.ca

AI

Troubleshooting

When it breaks

Common problems and how to fix them. Start with the Ollama terminal. Most problems show up there first.

Connection refused

The Ollama server is not running.

Show me.

ollama serve

Keep this terminal open while you work. Ollama needs to be running to accept requests.

Model not found

You are trying to use a model that is not downloaded.

Show me.

ollama pull ministral
ollama list

The request times out

Vision models are slower than text models. They need time to process images.

Increase the timeout in your code (we used 120 seconds). Check system resources and close other apps. Try a smaller model (minicpm-v is lighter than ministral). Make sure you have enough RAM. 16 GB and up is recommended for larger models.

The response ignores the format

The model is ignoring your structured prompt.

Try a different model. Some follow instructions better. Simplify your prompt and ask fewer questions. Be more explicit: "Answer ONLY with YES or NO." Lower the temperature to 0.1 for more consistent output. Make sure your prompt ends with the expected format.

Empty or garbled

Check Ollama logs in the terminal where it is running. Try a simpler prompt first to verify the model works. Verify your Base64 encoding is correct. Make sure the image is not corrupted.

Image too large, or memory errors

The image file is too big, or you are hitting terminal character limits.

Resize images before encoding. 768 px max dimension is usually fine. Check that images are under 20 MB. Use a more efficient format (JPEG instead of PNG for photos).

To resize on macOS:

sips --resampleHeightWidthMax 768 image.png --out resized.png

Check the terminal character limit:

getconf ARG_MAX

Check your Base64 string size:

base64 -i image.png | perl -pe's~\s~~g' | wc -c

If the count is over 800,000 characters, resize first.

JSON will not parse

The response is not valid JSON. Check if Ollama is returning an error message instead. Make sure stream is set to false. Streaming returns a different format. Use jq -r to see the raw response before parsing.

curl is unhappy

Usual culprits: missing quotes around the JSON, a variable that is not expanding (use double quotes for $IMAGE_B64), a wrong endpoint URL, or Ollama not running.

Test with a simple request first:

curl http://localhost:11434/api/tags

Same image, different answers

Lower temperature to 0.1 for more deterministic output. Make the prompt more specific. Accept that AI has some randomness. Run multiple times and vote.

Still stuck

Check the Ollama terminal for error messages. Most problems show up there before they show up in your code.

Ollama GitHub issues: github.com/ollama/ollama/issues. (The old Techalicious forum is historical only; that site is gone.)