ollama - ✅(Solved) Fix After update to v0.18.2, the server does not start anymore [1 pull requests, 5 comments, 5 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#14952Fetched 2026-04-08 01:02:06
View on GitHub
Comments
5
Participants
5
Timeline
19
Reactions
0
Author
Timeline (top)
commented ×5marked_as_duplicate ×4referenced ×3subscribed ×3

Error Message

Exception 0xc0000005 0x8 0x7ffa9b36cb12 0x7ffa9b36cb12 PC=0x7ffa9b36cb12 signal arrived during external code execution

runtime.cgocall(0x7ff63bb7feb0, 0xc000047da0) runtime/cgocall.go:167 +0x3e fp=0xc000047d78 sp=0xc000047d10 pc=0x7ff63ac0243e github.com/ollama/ollama/x/imagegen/mlx._Cfunc_mlx_random_key(0xc0000902e0, 0x19d057faff6) _cgo_gotypes.go:1976 +0x50 fp=0xc000047da0 sp=0xc000047d78 pc=0x7ff63b24a8d0 github.com/ollama/ollama/x/imagegen/mlx.RandomKey.func1(...) github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1870 github.com/ollama/ollama/x/imagegen/mlx.RandomKey(0x19d057faff6) github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1870 +0x5d fp=0xc000047dd8 sp=0xc000047da0 pc=0x7ff63b253f9d github.com/ollama/ollama/x/imagegen/mlx.init.0() github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1848 +0xa9 fp=0xc000047e28 sp=0xc000047dd8 pc=0x7ff63b253da9 runtime.doInit1(0x7ff63ce9c1b0) runtime/proc.go:7350 +0xdd fp=0xc000047f50 sp=0xc000047e28 pc=0x7ff63abe343d runtime.doInit(...) runtime/proc.go:7317 runtime.main() runtime/proc.go:254 +0x325 fp=0xc000047fe0 sp=0xc000047f50 pc=0x7ff63abd4e85 runtime.goexit({}) runtime/asm_amd64.s:1700 +0x1 fp=0xc000047fe8 sp=0xc000047fe0 pc=0x7ff63ac0d9a1

goroutine 2 gp=0xc0000028c0 m=nil [force gc (idle)]: runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?) runtime/proc.go:435 +0xce fp=0xc000089fa8 sp=0xc000089f88 pc=0x7ff63ac0598e runtime.goparkunlock(...) runtime/proc.go:441 runtime.forcegchelper() runtime/proc.go:348 +0xb8 fp=0xc000089fe0 sp=0xc000089fa8 pc=0x7ff63abd50f8 runtime.goexit({}) runtime/asm_amd64.s:1700 +0x1 fp=0xc000089fe8 sp=0xc000089fe0 pc=0x7ff63ac0d9a1 created by runtime.init.7 in goroutine 1 runtime/proc.go:336 +0x1a

goroutine 3 gp=0xc000002c40 m=nil [GC sweep wait]: runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?) runtime/proc.go:435 +0xce fp=0xc00008bf80 sp=0xc00008bf60 pc=0x7ff63ac0598e runtime.goparkunlock(...) runtime/proc.go:441 runtime.bgsweep(0xc000098000) runtime/mgcsweep.go:276 +0x94 fp=0xc00008bfc8 sp=0xc00008bf80 pc=0x7ff63abbde74 runtime.gcenable.gowrap1() runtime/mgc.go:204 +0x25 fp=0xc00008bfe0 sp=0xc00008bfc8 pc=0x7ff63abb2285 runtime.goexit({}) runtime/asm_amd64.s:1700 +0x1 fp=0xc00008bfe8 sp=0xc00008bfe0 pc=0x7ff63ac0d9a1 created by runtime.gcenable in goroutine 1 runtime/mgc.go:204 +0x66

goroutine 4 gp=0xc000002e00 m=nil [GC scavenge wait]: runtime.gopark(0xc000098000?, 0x7ff63c4402e8?, 0x1?, 0x0?, 0xc000002e00?) runtime/proc.go:435 +0xce fp=0xc00009ff78 sp=0xc00009ff58 pc=0x7ff63ac0598e runtime.goparkunlock(...) runtime/proc.go:441 runtime.(*scavengerState).park(0x7ff63cfb2520) runtime/mgcscavenge.go:425 +0x49 fp=0xc00009ffa8 sp=0xc00009ff78 pc=0x7ff63abbb909 runtime.bgscavenge(0xc000098000) runtime/mgcscavenge.go:653 +0x3c fp=0xc00009ffc8 sp=0xc00009ffa8 pc=0x7ff63abbbe7c runtime.gcenable.gowrap2() runtime/mgc.go:205 +0x25 fp=0xc00009ffe0 sp=0xc00009ffc8 pc=0x7ff63abb2225 runtime.goexit({}) runtime/asm_amd64.s:1700 +0x1 fp=0xc00009ffe8 sp=0xc00009ffe0 pc=0x7ff63ac0d9a1 created by runtime.gcenable in goroutine 1 runtime/mgc.go:205 +0xa5

goroutine 5 gp=0xc000003340 m=nil [finalizer wait]: runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?) runtime/proc.go:435 +0xce fp=0xc0000a1e30 sp=0xc0000a1e10 pc=0x7ff63ac0598e runtime.runfinq() runtime/mfinal.go:196 +0x107 fp=0xc0000a1fe0 sp=0xc0000a1e30 pc=0x7ff63abb1207 runtime.goexit({}) runtime/asm_amd64.s:1700 +0x1 fp=0xc0000a1fe8 sp=0xc0000a1fe0 pc=0x7ff63ac0d9a1 created by runtime.createfing in goroutine 1 runtime/mfinal.go:166 +0x3d rax 0x64 rbx 0x7ffa9b43098c rcx 0xa96761286e10000 rdx 0x1964ea90000 rdi 0x196f6ef0860 rsi 0x0 rbp 0x239bcff7c9 rsp 0x239bcff260 r8 0x7ffffffffffffffc r9 0x239bba7000 r10 0x80fcf8fefcfefefe r11 0x1964eda9ff0 r12 0xffffffffffffffff r13 0x5d r14 0x239bcff900 r15 0x0 rip 0x7ffa9b36cb12 rflags 0x10202 cs 0x33 fs 0x53 gs 0x2b

PR fix notes

PR #15371: mlx: delay initialization to prevent access violation on systems without compatible GPU

Description (problem / solution / changelog)

Problem

On Windows (and potentially Linux) systems without NVIDIA GPUs, ollama crashes immediately on startup with Exception 0xc0000005 (access violation) in _Cfunc_mlx_random_key. This affects users with Intel and AMD GPUs.

The crash happens because the MLX package's init() function runs unconditionally on import. It calls mlx_random_key which attempts GPU operations via the CUDA backend. On systems without CUDA-capable hardware, this causes an OS-level access violation that bypasses the safe error handler added in #14777 — that handler catches MLX-reported errors, but not Windows structured exceptions.

The root cause was introduced in #14642 which removed the //go:build mlx constraint, making the MLX package compile and initialize on all platforms by default.

Fix

  • Remove init() entirely — no MLX code runs at package import time
  • Consolidate all initialization into InitMLX() behind sync.Once for thread safety
  • Add GPU backend availability check (mlx_cuda_is_available / mlx_metal_is_available) before calling RandomKey, as defense in depth
  • Update the image generation engine (x/imagegen/cmd/engine/main.go) to call InitMLX() explicitly

This means the vast majority of users (who use ollama for text LLMs, not MLX image generation) never execute any MLX code at all.

Testing

  • Manually tested on Windows 11 Home (AMD64, no NVIDIA GPU): ollama v0.20.2 crashes on startup; with this patch applied, ollama starts and runs normally with MLX gracefully unavailable.
  • MLX image generation path is unchanged — InitMLX() performs the same initialization steps, just on-demand instead of at import.

Fixes #14952

Changed files

  • x/imagegen/cmd/engine/main.go (modified, +2/-3)
  • x/imagegen/mlx/mlx.go (modified, +67/-56)

Code Example

Exception 0xc0000005 0x8 0x7ffa9b36cb12 0x7ffa9b36cb12
PC=0x7ffa9b36cb12
signal arrived during external code execution

runtime.cgocall(0x7ff63bb7feb0, 0xc000047da0)
	runtime/cgocall.go:167 +0x3e fp=0xc000047d78 sp=0xc000047d10 pc=0x7ff63ac0243e
github.com/ollama/ollama/x/imagegen/mlx._Cfunc_mlx_random_key(0xc0000902e0, 0x19d057faff6)
	_cgo_gotypes.go:1976 +0x50 fp=0xc000047da0 sp=0xc000047d78 pc=0x7ff63b24a8d0
github.com/ollama/ollama/x/imagegen/mlx.RandomKey.func1(...)
	github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1870
github.com/ollama/ollama/x/imagegen/mlx.RandomKey(0x19d057faff6)
	github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1870 +0x5d fp=0xc000047dd8 sp=0xc000047da0 pc=0x7ff63b253f9d
github.com/ollama/ollama/x/imagegen/mlx.init.0()
	github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1848 +0xa9 fp=0xc000047e28 sp=0xc000047dd8 pc=0x7ff63b253da9
runtime.doInit1(0x7ff63ce9c1b0)
	runtime/proc.go:7350 +0xdd fp=0xc000047f50 sp=0xc000047e28 pc=0x7ff63abe343d
runtime.doInit(...)
	runtime/proc.go:7317
runtime.main()
	runtime/proc.go:254 +0x325 fp=0xc000047fe0 sp=0xc000047f50 pc=0x7ff63abd4e85
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc000047fe8 sp=0xc000047fe0 pc=0x7ff63ac0d9a1

goroutine 2 gp=0xc0000028c0 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	runtime/proc.go:435 +0xce fp=0xc000089fa8 sp=0xc000089f88 pc=0x7ff63ac0598e
runtime.goparkunlock(...)
	runtime/proc.go:441
runtime.forcegchelper()
	runtime/proc.go:348 +0xb8 fp=0xc000089fe0 sp=0xc000089fa8 pc=0x7ff63abd50f8
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc000089fe8 sp=0xc000089fe0 pc=0x7ff63ac0d9a1
created by runtime.init.7 in goroutine 1
	runtime/proc.go:336 +0x1a

goroutine 3 gp=0xc000002c40 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	runtime/proc.go:435 +0xce fp=0xc00008bf80 sp=0xc00008bf60 pc=0x7ff63ac0598e
runtime.goparkunlock(...)
	runtime/proc.go:441
runtime.bgsweep(0xc000098000)
	runtime/mgcsweep.go:276 +0x94 fp=0xc00008bfc8 sp=0xc00008bf80 pc=0x7ff63abbde74
runtime.gcenable.gowrap1()
	runtime/mgc.go:204 +0x25 fp=0xc00008bfe0 sp=0xc00008bfc8 pc=0x7ff63abb2285
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc00008bfe8 sp=0xc00008bfe0 pc=0x7ff63ac0d9a1
created by runtime.gcenable in goroutine 1
	runtime/mgc.go:204 +0x66

goroutine 4 gp=0xc000002e00 m=nil [GC scavenge wait]:
runtime.gopark(0xc000098000?, 0x7ff63c4402e8?, 0x1?, 0x0?, 0xc000002e00?)
	runtime/proc.go:435 +0xce fp=0xc00009ff78 sp=0xc00009ff58 pc=0x7ff63ac0598e
runtime.goparkunlock(...)
	runtime/proc.go:441
runtime.(*scavengerState).park(0x7ff63cfb2520)
	runtime/mgcscavenge.go:425 +0x49 fp=0xc00009ffa8 sp=0xc00009ff78 pc=0x7ff63abbb909
runtime.bgscavenge(0xc000098000)
	runtime/mgcscavenge.go:653 +0x3c fp=0xc00009ffc8 sp=0xc00009ffa8 pc=0x7ff63abbbe7c
runtime.gcenable.gowrap2()
	runtime/mgc.go:205 +0x25 fp=0xc00009ffe0 sp=0xc00009ffc8 pc=0x7ff63abb2225
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc00009ffe8 sp=0xc00009ffe0 pc=0x7ff63ac0d9a1
created by runtime.gcenable in goroutine 1
	runtime/mgc.go:205 +0xa5

goroutine 5 gp=0xc000003340 m=nil [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	runtime/proc.go:435 +0xce fp=0xc0000a1e30 sp=0xc0000a1e10 pc=0x7ff63ac0598e
runtime.runfinq()
	runtime/mfinal.go:196 +0x107 fp=0xc0000a1fe0 sp=0xc0000a1e30 pc=0x7ff63abb1207
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc0000a1fe8 sp=0xc0000a1fe0 pc=0x7ff63ac0d9a1
created by runtime.createfing in goroutine 1
	runtime/mfinal.go:166 +0x3d
rax     0x64
rbx     0x7ffa9b43098c
rcx     0xa96761286e10000
rdx     0x1964ea90000
rdi     0x196f6ef0860
rsi     0x0
rbp     0x239bcff7c9
rsp     0x239bcff260
r8      0x7ffffffffffffffc
r9      0x239bba7000
r10     0x80fcf8fefcfefefe
r11     0x1964eda9ff0
r12     0xffffffffffffffff
r13     0x5d
r14     0x239bcff900
r15     0x0
rip     0x7ffa9b36cb12
rflags  0x10202
cs      0x33
fs      0x53
gs      0x2b
RAW_BUFFERClick to expand / collapse

What is the issue?

Yesterday I worked with ollama without issues both on a simple GPU in my laptop's CPU and on an nVidia Titan V attached as an eGPU.

This morning I installed the update to v0.18.2, and now the server will not start anymore.

I tried to roll back to 0.18.1 and 0.17 versions, to no avail.

The server log is:

Relevant log output

Exception 0xc0000005 0x8 0x7ffa9b36cb12 0x7ffa9b36cb12
PC=0x7ffa9b36cb12
signal arrived during external code execution

runtime.cgocall(0x7ff63bb7feb0, 0xc000047da0)
	runtime/cgocall.go:167 +0x3e fp=0xc000047d78 sp=0xc000047d10 pc=0x7ff63ac0243e
github.com/ollama/ollama/x/imagegen/mlx._Cfunc_mlx_random_key(0xc0000902e0, 0x19d057faff6)
	_cgo_gotypes.go:1976 +0x50 fp=0xc000047da0 sp=0xc000047d78 pc=0x7ff63b24a8d0
github.com/ollama/ollama/x/imagegen/mlx.RandomKey.func1(...)
	github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1870
github.com/ollama/ollama/x/imagegen/mlx.RandomKey(0x19d057faff6)
	github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1870 +0x5d fp=0xc000047dd8 sp=0xc000047da0 pc=0x7ff63b253f9d
github.com/ollama/ollama/x/imagegen/mlx.init.0()
	github.com/ollama/ollama/x/imagegen/mlx/mlx.go:1848 +0xa9 fp=0xc000047e28 sp=0xc000047dd8 pc=0x7ff63b253da9
runtime.doInit1(0x7ff63ce9c1b0)
	runtime/proc.go:7350 +0xdd fp=0xc000047f50 sp=0xc000047e28 pc=0x7ff63abe343d
runtime.doInit(...)
	runtime/proc.go:7317
runtime.main()
	runtime/proc.go:254 +0x325 fp=0xc000047fe0 sp=0xc000047f50 pc=0x7ff63abd4e85
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc000047fe8 sp=0xc000047fe0 pc=0x7ff63ac0d9a1

goroutine 2 gp=0xc0000028c0 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	runtime/proc.go:435 +0xce fp=0xc000089fa8 sp=0xc000089f88 pc=0x7ff63ac0598e
runtime.goparkunlock(...)
	runtime/proc.go:441
runtime.forcegchelper()
	runtime/proc.go:348 +0xb8 fp=0xc000089fe0 sp=0xc000089fa8 pc=0x7ff63abd50f8
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc000089fe8 sp=0xc000089fe0 pc=0x7ff63ac0d9a1
created by runtime.init.7 in goroutine 1
	runtime/proc.go:336 +0x1a

goroutine 3 gp=0xc000002c40 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	runtime/proc.go:435 +0xce fp=0xc00008bf80 sp=0xc00008bf60 pc=0x7ff63ac0598e
runtime.goparkunlock(...)
	runtime/proc.go:441
runtime.bgsweep(0xc000098000)
	runtime/mgcsweep.go:276 +0x94 fp=0xc00008bfc8 sp=0xc00008bf80 pc=0x7ff63abbde74
runtime.gcenable.gowrap1()
	runtime/mgc.go:204 +0x25 fp=0xc00008bfe0 sp=0xc00008bfc8 pc=0x7ff63abb2285
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc00008bfe8 sp=0xc00008bfe0 pc=0x7ff63ac0d9a1
created by runtime.gcenable in goroutine 1
	runtime/mgc.go:204 +0x66

goroutine 4 gp=0xc000002e00 m=nil [GC scavenge wait]:
runtime.gopark(0xc000098000?, 0x7ff63c4402e8?, 0x1?, 0x0?, 0xc000002e00?)
	runtime/proc.go:435 +0xce fp=0xc00009ff78 sp=0xc00009ff58 pc=0x7ff63ac0598e
runtime.goparkunlock(...)
	runtime/proc.go:441
runtime.(*scavengerState).park(0x7ff63cfb2520)
	runtime/mgcscavenge.go:425 +0x49 fp=0xc00009ffa8 sp=0xc00009ff78 pc=0x7ff63abbb909
runtime.bgscavenge(0xc000098000)
	runtime/mgcscavenge.go:653 +0x3c fp=0xc00009ffc8 sp=0xc00009ffa8 pc=0x7ff63abbbe7c
runtime.gcenable.gowrap2()
	runtime/mgc.go:205 +0x25 fp=0xc00009ffe0 sp=0xc00009ffc8 pc=0x7ff63abb2225
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc00009ffe8 sp=0xc00009ffe0 pc=0x7ff63ac0d9a1
created by runtime.gcenable in goroutine 1
	runtime/mgc.go:205 +0xa5

goroutine 5 gp=0xc000003340 m=nil [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	runtime/proc.go:435 +0xce fp=0xc0000a1e30 sp=0xc0000a1e10 pc=0x7ff63ac0598e
runtime.runfinq()
	runtime/mfinal.go:196 +0x107 fp=0xc0000a1fe0 sp=0xc0000a1e30 pc=0x7ff63abb1207
runtime.goexit({})
	runtime/asm_amd64.s:1700 +0x1 fp=0xc0000a1fe8 sp=0xc0000a1fe0 pc=0x7ff63ac0d9a1
created by runtime.createfing in goroutine 1
	runtime/mfinal.go:166 +0x3d
rax     0x64
rbx     0x7ffa9b43098c
rcx     0xa96761286e10000
rdx     0x1964ea90000
rdi     0x196f6ef0860
rsi     0x0
rbp     0x239bcff7c9
rsp     0x239bcff260
r8      0x7ffffffffffffffc
r9      0x239bba7000
r10     0x80fcf8fefcfefefe
r11     0x1964eda9ff0
r12     0xffffffffffffffff
r13     0x5d
r14     0x239bcff900
r15     0x0
rip     0x7ffa9b36cb12
rflags  0x10202
cs      0x33
fs      0x53
gs      0x2b

OS

Windows 11 Pro

GPU

GPU on Intel Core Ultra7 155H

CPU

Intel Core Ultra7 155H

Ollama version

v0.18.2

extent analysis

Fix Plan

The issue seems to be related to a compatibility problem with the new version of ollama. To fix this, we can try the following steps:

  • Reinstall the previous version of ollama that was working (v0.18.1).
  • If the issue persists, try updating the GPU drivers to the latest version.
  • If the issue is still not resolved, try setting the GOARCH environment variable to amd64 before running ollama.

Here's an example of how to set the GOARCH environment variable:

set GOARCH=amd64

Alternatively, you can try running ollama with the following command:

GOARCH=amd64 ollama

If none of these steps work, you may need to try a different version of ollama or seek further assistance from the ollama community.

Verification

To verify that the fix worked, try running ollama again and check the server logs for any errors. If the issue is resolved, you should be able to start the server without any errors.

Extra Tips

  • Make sure to check the ollama documentation for any specific requirements or compatibility issues with your system configuration.
  • If you're using a virtual environment, try reinstalling ollama outside of the virtual environment to see if the issue persists.
  • You can also try checking the ollama GitHub page for any open issues related to your problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING