[GH-ISSUE #9717] server panic when run gemma-3-27b-it-GGUF #6350

Closed
opened 2026-04-12 17:51:51 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @Sisphyus on GitHub (Mar 13, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9717

What is the issue?

(gemma) root@node19:/mnt/nvme2n1/gemma# ollama -v
ollama version is 0.6.0
(gemma) root@node19:/mnt/nvme2n1/gemma# ollama list
NAME ID SIZE MODIFIED
hf.co/unsloth/gemma-3-27b-it-GGUF:Q4_K_M 3a14687fd09d 16 GB 2 hours ago

test code

import requests
import base64
import json

def parse_image_with_gemma(image_path, prompt, ollama_url="http://localhost:8889/v1/chat/completions", model_name="hf.co/unsloth/gemma-3-27b-it-GGUF:Q4_K_M"):
    """
    Sends an image and prompt to the Ollama API for processing.
    """
    try:
        with open(image_path, "rb") as image_file:
            encoded_image = base64.b64encode(image_file.read()).decode("utf-8")

        payload = {
            "model": model_name,
            "messages": [
                {
                    "role": "user",
                    "content": [
                        {"type": "text", "text": prompt},
                        {
                            "type": "image_url",
                            "image_url": {"url": f"data:image/jpeg;base64,{encoded_image}"},
                        },
                    ],
                }
            ],
        }

        response = requests.post(ollama_url, json=payload, stream=True)
        response.raise_for_status() # Raise an exception for bad status codes.
        for line in response.iter_lines():
            if line:
                body = json.loads(line)
                print(body['response'], end='', flush=True)
                if 'done' in body and body['done']:
                    break
    except requests.exceptions.RequestException as e:
        print(f"Error during request: {e}")
    except FileNotFoundError:
        print(f"Error: Image file not found at {image_path}")
    except json.JSONDecodeError:
        print("Error: invalid json response")

# Example usage
image_path = "/mnt/nvme2n1/gemma/test.jpg"
prompt = "Describe what is in this image."
parse_image_with_gemma(image_path, prompt)

Relevant log output

[GIN] 2025/03/13 - 15:53:23 | 500 |  216.479399ms |       127.0.0.1 | POST     "/v1/chat/completions"
time=2025-03-13T15:53:24.713+08:00 level=INFO source=server.go:3634 msg="http: panic serving 127.0.0.1:34336: runtime error: integer divide by zero\ngoroutine 1321 [running]:\nnet/http.(*conn).serve.func1()\n\tnet/http/server.go:1947 +0xbe\npanic({0x5635f73af260?, 0x5635f7ca81c0?})\n\truntime/panic.go:787 +0x132\ngithub.com/ollama/ollama/model/models/gemma3.(*VisionModel).Forward(0xc0cf0e2870?, {0x5635f7506c00?, 0xc0cf0e2870?}, {0x5635f750f210?, 0xc0033aa630?})\n\tgithub.com/ollama/ollama/model/models/gemma3/model_vision.go:88 +0x399\ngithub.com/ollama/ollama/model/models/gemma3.(*Model).EncodeMultimodal(0xc000798070, {0x5635f7506c00, 0xc0cf0e2870}, {0xc12338c000, 0x227ec, 0x227ee})\n\tgithub.com/ollama/ollama/model/models/gemma3/model.go:106 +0x18e\ngithub.com/ollama/ollama/runner/ollamarunner.(*Server).inputs(0xc000034d80, {0x5635f7506c00, 0xc0cf0e2870}, {0xc000318320, 0xa0}, {0xc0cf0e2840, 0x1, 0xc0035d5650?})\n\tgithub.com/ollama/ollama/runner/ollamarunner/runner.go:191 +0x3d2\ngithub.com/ollama/ollama/runner/ollamarunner.(*Server).NewSequence(0xc000034d80, {0xc000318320, 0xa0}, {0xc0cf0e2840, 0x1, 0x1}, {0x8000, {0xc01ec6a3a0, 0x2, 0x2}, ...})\n\tgithub.com/ollama/ollama/runner/ollamarunner/runner.go:103 +0xd5\ngithub.com/ollama/ollama/runner/ollamarunner.(*Server).completion(0xc000034d80, {0x5635f74fd4f8, 0xc0cf0f6000}, 0xc003397b80)\n\tgithub.com/ollama/ollama/runner/ollamarunner/runner.go:602 +0x54f\nnet/http.HandlerFunc.ServeHTTP(0xc000762780?, {0x5635f74fd4f8?, 0xc0cf0f6000?}, 0xc0035d5b60?)\n\tnet/http/server.go:2294 +0x29\nnet/http.(*ServeMux).ServeHTTP(0x5635f61ca125?, {0x5635f74fd4f8, 0xc0cf0f6000}, 0xc003397b80)\n\tnet/http/server.go:2822 +0x1c4\nnet/http.serverHandler.ServeHTTP({0x5635f74f9b10?}, {0x5635f74fd4f8?, 0xc0cf0f6000?}, 0x1?)\n\tnet/http/server.go:3301 +0x8e\nnet/http.(*conn).serve(0xc001bfc3f0, {0x5635f74ff5a8, 0xc00078db90})\n\tnet/http/server.go:2102 +0x625\ncreated by net/http.(*Server).Serve in goroutine 1\n\tnet/http/server.go:3454 +0x485"

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.6.0

Originally created by @Sisphyus on GitHub (Mar 13, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9717 ### What is the issue? (gemma) root@node19:/mnt/nvme2n1/gemma# ollama -v ollama version is 0.6.0 (gemma) root@node19:/mnt/nvme2n1/gemma# ollama list NAME ID SIZE MODIFIED hf.co/unsloth/gemma-3-27b-it-GGUF:Q4_K_M 3a14687fd09d 16 GB 2 hours ago test code ``` import requests import base64 import json def parse_image_with_gemma(image_path, prompt, ollama_url="http://localhost:8889/v1/chat/completions", model_name="hf.co/unsloth/gemma-3-27b-it-GGUF:Q4_K_M"): """ Sends an image and prompt to the Ollama API for processing. """ try: with open(image_path, "rb") as image_file: encoded_image = base64.b64encode(image_file.read()).decode("utf-8") payload = { "model": model_name, "messages": [ { "role": "user", "content": [ {"type": "text", "text": prompt}, { "type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{encoded_image}"}, }, ], } ], } response = requests.post(ollama_url, json=payload, stream=True) response.raise_for_status() # Raise an exception for bad status codes. for line in response.iter_lines(): if line: body = json.loads(line) print(body['response'], end='', flush=True) if 'done' in body and body['done']: break except requests.exceptions.RequestException as e: print(f"Error during request: {e}") except FileNotFoundError: print(f"Error: Image file not found at {image_path}") except json.JSONDecodeError: print("Error: invalid json response") # Example usage image_path = "/mnt/nvme2n1/gemma/test.jpg" prompt = "Describe what is in this image." parse_image_with_gemma(image_path, prompt) ``` ### Relevant log output ```shell [GIN] 2025/03/13 - 15:53:23 | 500 | 216.479399ms | 127.0.0.1 | POST "/v1/chat/completions" time=2025-03-13T15:53:24.713+08:00 level=INFO source=server.go:3634 msg="http: panic serving 127.0.0.1:34336: runtime error: integer divide by zero\ngoroutine 1321 [running]:\nnet/http.(*conn).serve.func1()\n\tnet/http/server.go:1947 +0xbe\npanic({0x5635f73af260?, 0x5635f7ca81c0?})\n\truntime/panic.go:787 +0x132\ngithub.com/ollama/ollama/model/models/gemma3.(*VisionModel).Forward(0xc0cf0e2870?, {0x5635f7506c00?, 0xc0cf0e2870?}, {0x5635f750f210?, 0xc0033aa630?})\n\tgithub.com/ollama/ollama/model/models/gemma3/model_vision.go:88 +0x399\ngithub.com/ollama/ollama/model/models/gemma3.(*Model).EncodeMultimodal(0xc000798070, {0x5635f7506c00, 0xc0cf0e2870}, {0xc12338c000, 0x227ec, 0x227ee})\n\tgithub.com/ollama/ollama/model/models/gemma3/model.go:106 +0x18e\ngithub.com/ollama/ollama/runner/ollamarunner.(*Server).inputs(0xc000034d80, {0x5635f7506c00, 0xc0cf0e2870}, {0xc000318320, 0xa0}, {0xc0cf0e2840, 0x1, 0xc0035d5650?})\n\tgithub.com/ollama/ollama/runner/ollamarunner/runner.go:191 +0x3d2\ngithub.com/ollama/ollama/runner/ollamarunner.(*Server).NewSequence(0xc000034d80, {0xc000318320, 0xa0}, {0xc0cf0e2840, 0x1, 0x1}, {0x8000, {0xc01ec6a3a0, 0x2, 0x2}, ...})\n\tgithub.com/ollama/ollama/runner/ollamarunner/runner.go:103 +0xd5\ngithub.com/ollama/ollama/runner/ollamarunner.(*Server).completion(0xc000034d80, {0x5635f74fd4f8, 0xc0cf0f6000}, 0xc003397b80)\n\tgithub.com/ollama/ollama/runner/ollamarunner/runner.go:602 +0x54f\nnet/http.HandlerFunc.ServeHTTP(0xc000762780?, {0x5635f74fd4f8?, 0xc0cf0f6000?}, 0xc0035d5b60?)\n\tnet/http/server.go:2294 +0x29\nnet/http.(*ServeMux).ServeHTTP(0x5635f61ca125?, {0x5635f74fd4f8, 0xc0cf0f6000}, 0xc003397b80)\n\tnet/http/server.go:2822 +0x1c4\nnet/http.serverHandler.ServeHTTP({0x5635f74f9b10?}, {0x5635f74fd4f8?, 0xc0cf0f6000?}, 0x1?)\n\tnet/http/server.go:3301 +0x8e\nnet/http.(*conn).serve(0xc001bfc3f0, {0x5635f74ff5a8, 0xc00078db90})\n\tnet/http/server.go:2102 +0x625\ncreated by net/http.(*Server).Serve in goroutine 1\n\tnet/http/server.go:3454 +0x485" ``` ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.6.0
GiteaMirror added the bug label 2026-04-12 17:51:51 -05:00
Author
Owner

@ItzCrazyKns commented on GitHub (Mar 13, 2025):

The GGUF files provided by Ollama have the image encoder model in them as well with default keys so Ollama can get the weights for image processing but the models on Hugging Face have a separate image encoder/projector so Ollama can't find those keys in the GGUF file and you see the error.

<!-- gh-comment-id:2721344206 --> @ItzCrazyKns commented on GitHub (Mar 13, 2025): The GGUF files provided by Ollama have the image encoder model in them as well with default keys so Ollama can get the weights for image processing but the models on Hugging Face have a separate image encoder/projector so Ollama can't find those keys in the GGUF file and you see the error.
Author
Owner

@dmatora commented on GitHub (Mar 14, 2025):

@ItzCrazyKns is there a way to get Q6 working in ollama? Q4 is too dumb, Q8 is too large to use full context in on 2x24Gb GPUs

<!-- gh-comment-id:2723747806 --> @dmatora commented on GitHub (Mar 14, 2025): @ItzCrazyKns is there a way to get Q6 working in ollama? Q4 is too dumb, Q8 is too large to use full context in on 2x24Gb GPUs
Author
Owner

@karaketir16 commented on GitHub (Mar 14, 2025):

The GGUF files provided by Ollama have the image encoder model in them as well with default keys so Ollama can get the weights for image processing but the models on Hugging Face have a separate image encoder/projector so Ollama can't find those keys in the GGUF file and you see the error.

@ItzCrazyKns

How can I download GGUF provided by Ollama so that I can run them on a machine without an internet connection?

<!-- gh-comment-id:2724941963 --> @karaketir16 commented on GitHub (Mar 14, 2025): > The GGUF files provided by Ollama have the image encoder model in them as well with default keys so Ollama can get the weights for image processing but the models on Hugging Face have a separate image encoder/projector so Ollama can't find those keys in the GGUF file and you see the error. @ItzCrazyKns How can I download GGUF provided by Ollama so that I can run them on a machine without an internet connection?
Author
Owner

@karaketir16 commented on GitHub (Mar 15, 2025):

How can I download GGUF provided by Ollama so that I can run them on a machine without an internet connection?

https://github.com/amirrezaDev1378/ollama-model-direct-download/

Okay, it is a great tool. But linux path seems incorrect for me, I have converted installing part to python.

https://gist.github.com/karaketir16/684a4d79465bc0a61eb613765c380f1e

<!-- gh-comment-id:2726569153 --> @karaketir16 commented on GitHub (Mar 15, 2025): > How can I download GGUF provided by Ollama so that I can run them on a machine without an internet connection? https://github.com/amirrezaDev1378/ollama-model-direct-download/ Okay, it is a great tool. But linux path seems incorrect for me, I have converted installing part to python. https://gist.github.com/karaketir16/684a4d79465bc0a61eb613765c380f1e
Author
Owner

@soldivelot commented on GitHub (Mar 22, 2025):

i have a abliterated llm from mlabonne/gemma-3-27b-it-abliterated-GGUF and a clip model from ggml-org/gemma-3-27b-it-GGUF, is there a tool to convert them to ollama's format?
is this format related to the new vision engine?

<!-- gh-comment-id:2745338384 --> @soldivelot commented on GitHub (Mar 22, 2025): i have a abliterated llm from mlabonne/gemma-3-27b-it-abliterated-GGUF and a clip model from ggml-org/gemma-3-27b-it-GGUF, is there a tool to convert them to ollama's format? is this format related to the new vision engine?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#6350