Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Notes: a graphics card next to built-in graphics counts as the card with its own memory, and a model that fails to load on the card loads again with fewer layers there (#37)

christianmat309f23b621c6
diff --git a/app/src/engine/llm.ts b/app/src/engine/llm.ts
index 81fe29bc..1bd8eaf5 100644
--- a/app/src/engine/llm.ts
+++ b/app/src/engine/llm.ts
@@ -70,8 +70,13 @@ export function createLlm() {
// The model fills the graphics card first and keeps room for only a tiny context; on a card with little memory the
// notes' context then doesn't fit (InsufficientMemoryError, every summary failing). So: load again leaving room for
// the smallest context we accept, then with nothing on the card. A computer where it fits loads once, as before.
+ // A model that doesn't fit on the card at all can fail to load outright (#37): that gets the same fewer layers.
for (const gpuLayers of [undefined, { fitContext: { contextSize: size.min } }, 0] as const) {
- model = await l.loadModel(gpuLayers === undefined ? { modelPath } : { modelPath, gpuLayers })
+ try { model = await l.loadModel(gpuLayers === undefined ? { modelPath } : { modelPath, gpuLayers }) } catch (e) {
+ if (gpuLayers === 0) throw e
+ console.warn('the notes model did not load on the graphics card; loading it again with fewer layers there', (e as Error).message)
+ continue
+ }
try { context = await model.createContext({ contextSize: size, ...threads(l) }); break } catch (e) {
if (!(e instanceof InsufficientMemoryError) || gpuLayers === 0 || model.gpuLayers === 0) throw e
console.warn('the notes did not fit next to the model on the graphics card; loading it again with fewer layers there', e.message)
diff --git a/app/src/main/hardware.ts b/app/src/main/hardware.ts
index ef57f430..cb7e074f 100644
--- a/app/src/main/hardware.ts
+++ b/app/src/main/hardware.ts
@@ -14,7 +14,10 @@ export type GpuProbe = { gpuType: string | false; vramTotalGB: number; unifiedGB
*/
export function toHardware(sys: SysInfo, probe?: GpuProbe | null): Hardware {
const mac = sys.platform === 'darwin'
- const kind = mac ? 'unified' : !probe?.gpuType ? 'none' : probe.unifiedGB > 0 ? 'unified' : 'discrete'
+ // A card next to graphics built into the processor: node-llama-cpp adds the card's memory to the shared memory, but
+ // llama.cpp runs on the card, so it's a card with what's left once the shared part is taken out (#37)
+ const ownGB = probe ? probe.vramTotalGB - probe.unifiedGB : 0
+ const kind = mac ? 'unified' : !probe?.gpuType ? 'none' : probe.unifiedGB > 0 && ownGB < 2 ? 'unified' : 'discrete'
return {
os: sys.platform as OS,
arch: sys.arch,
@@ -22,7 +25,7 @@ export function toHardware(sys: SysInfo, probe?: GpuProbe | null): Hardware {
totalRamGB: Math.round((sys.totalRamBytes / 1e9) * 10) / 10,
freeDiskGB: Math.round(sys.freeDiskGB * 10) / 10,
gpu: mac ? { kind, name: sys.cpuModel, vramGB: 0 }
- : { kind, name: kind === 'none' ? '' : probe?.gpuNames[0] ?? '', vramGB: kind === 'none' ? 0 : Math.round((probe?.vramTotalGB ?? 0) * 10) / 10 },
+ : { kind, name: kind === 'none' ? '' : probe?.gpuNames[0] ?? '', vramGB: kind === 'none' ? 0 : Math.round((kind === 'discrete' ? ownGB : probe?.vramTotalGB ?? 0) * 10) / 10 },
...(!mac && sys.cores ? { cores: sys.cores } : {}),
}
}
diff --git a/app/test/hardware.test.ts b/app/test/hardware.test.ts
index f0c3cd04..3ed1b7ab 100644
--- a/app/test/hardware.test.ts
+++ b/app/test/hardware.test.ts
@@ -26,6 +26,11 @@ describe('graphics on Windows and Linux (the notes engine checks the card)', ()
it('graphics that share the memory', () => {
expect(toHardware(pc, { gpuType: 'vulkan', vramTotalGB: 16, unifiedGB: 16, gpuNames: ['Intel(R) Iris(R) Xe Graphics'] }).gpu.kind).toBe('unified')
})
+ it('a graphics card next to graphics built into the processor counts as the card, with its own memory (#37)', () => {
+ // node-llama-cpp adds the card's 12 GB to the shared memory the built-in graphics can use
+ expect(toHardware(pc, { gpuType: 'vulkan', vramTotalGB: 67.8, unifiedGB: 55.8, gpuNames: ['NVIDIA GeForce RTX 4070 Ti', 'AMD Radeon(TM) Graphics'] }).gpu)
+ .toEqual({ kind: 'discrete', name: 'NVIDIA GeForce RTX 4070 Ti', vramGB: 12 })
+ })
it('no usable graphics, or a check that failed: the processor only', () => {
expect(toHardware(pc, { gpuType: false, vramTotalGB: 0, unifiedGB: 0, gpuNames: [] }).gpu).toEqual({ kind: 'none', name: '', vramGB: 0 })
expect(toHardware(pc, null).gpu.kind).toBe('none')
diff --git a/app/test/llm.test.ts b/app/test/llm.test.ts
index dfc42df6..5ac3307f 100644
--- a/app/test/llm.test.ts
+++ b/app/test/llm.test.ts
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import { Gemma4ChatWrapper, type LlamaChatSessionOptions } from 'node-llama-cpp'
import { createLlm } from '../src/engine/llm'
-const fake = vi.hoisted(() => ({ architecture: 'gemma4', sessions: [] as unknown[], loads: [] as unknown[], disposed: 0, contextFails: 0, contextError: undefined as (() => Error) | undefined }))
+const fake = vi.hoisted(() => ({ architecture: 'gemma4', sessions: [] as unknown[], loads: [] as unknown[], disposed: 0, contextFails: 0, loadFails: 0, contextError: undefined as (() => Error) | undefined }))
vi.mock('node-llama-cpp', async (original) => {
const actual = await original<typeof import('node-llama-cpp')>()
const sequence = { contextTokens: [], tokenMeter: { usedInputTokens: 0 }, evaluateWithoutGeneratingNewTokens: async () => {} }
@@ -10,6 +10,7 @@ vi.mock('node-llama-cpp', async (original) => {
...actual,
getLlama: async () => ({ gpu: 'vulkan', loadModel: async (o: { gpuLayers?: unknown }) => {
fake.loads.push(o.gpuLayers)
+ if (fake.loadFails > 0 && o.gpuLayers !== 0) { fake.loadFails--; throw new Error('Failed to load model') }
return {
fileInfo: { metadata: { general: { architecture: fake.architecture } } }, gpuLayers: o.gpuLayers === 0 ? 0 : 20,
tokenize: () => [], dispose: async () => { fake.disposed++ },
@@ -29,7 +30,7 @@ vi.mock('node-llama-cpp', async (original) => {
}
})
-beforeEach(() => { fake.sessions.length = 0; fake.loads.length = 0; fake.disposed = 0; fake.contextFails = 0; fake.contextError = undefined })
+beforeEach(() => { fake.sessions.length = 0; fake.loads.length = 0; fake.disposed = 0; fake.contextFails = 0; fake.loadFails = 0; fake.contextError = undefined })
describe('model prompt wrapper', () => {
it.each(['gemma4', 'qwen3', 'gpt-oss'])('preload and answers use the same format for %s', async (architecture) => {
@@ -77,6 +78,17 @@ describe('too little room on the graphics card for the notes', () => {
fake.contextFails = 3
await expect(createLlm().load('fixture.gguf', 32768, 8192)).rejects.toThrow(/too large/)
})
+ it('a model too big for the card that fails to load at all loads again with fewer layers there (#37)', async () => {
+ fake.loadFails = 1
+ const llm = createLlm()
+ expect(await llm.load('fixture.gguf', 32768, 8192)).toMatchObject({ gpu: 'vulkan', gpuLayers: 20 })
+ expect(fake.loads).toEqual([undefined, { fitContext: { contextSize: 8192 } }])
+ })
+ it('falls back to the processor when the model fails to load on the card twice', async () => {
+ fake.loadFails = 2
+ expect(await createLlm().load('fixture.gguf', 32768, 8192)).toMatchObject({ gpu: false, gpuLayers: 0 })
+ expect(fake.loads).toEqual([undefined, { fitContext: { contextSize: 8192 } }, 0])
+ })
it('another error is not retried', async () => {
fake.contextFails = 1; fake.contextError = () => new Error('bad file')
await expect(createLlm().load('fixture.gguf', 32768, 8192)).rejects.toThrow('bad file')