Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Carry the host-memory shortage from the image worker to the page
Bowen Xue548a933384b8
diff --git a/freevideo_engine/diagnostic_resources.py b/freevideo_engine/diagnostic_resources.pyindex c53a765..6444a85 100644--- a/freevideo_engine/diagnostic_resources.py+++ b/freevideo_engine/diagnostic_resources.py@@ -52,13 +52,17 @@ def commit_exhausted(error):Rust-backed file readers raise a plain OSError carrying only the localizedsystem message plus "(os error 1455)", so the numeric attributes are unset.+ A different numeric code wins over the text, which may be a file name."""seen = set()while isinstance(error, BaseException) and id(error) not in seen:seen.add(id(error))- if getattr(error, 'winerror', None) == 1455 or re.search(r'(?:os error|winerror)\s*1455\b', str(error), re.I):+ code = getattr(error, 'winerror', None)+ if code == 1455:return True- error = error.__cause__ or error.__context__+ if code is None and re.search(r'(?:os error|winerror)\s*1455\b', str(error), re.I):+ return True+ error = error.__cause__ or (None if error.__suppress_context__ else error.__context__)return Falsediff --git a/freevideo_engine/image_gen/failure.py b/freevideo_engine/image_gen/failure.pyindex 4920049..9101364 100644--- a/freevideo_engine/image_gen/failure.py+++ b/freevideo_engine/image_gen/failure.py@@ -56,7 +56,12 @@ _MPS_MEMORY = re.compile(r'MPS backend out of memory', re.I)_LIMIT = 16 * 1024# On a Mac the GPU's memory is the machine's: the same failure, in its words.UNIFIED_MESSAGE_ZH = {'no_memory': '内存不够,最小尺寸也没能生成。关掉其他程序后再试。'}-COMMIT_MESSAGE_ZH = '系统的虚拟内存不够,图像生成没能载入模型。关掉其他程序,或在系统设置里调大虚拟内存后再试。'+HOST_MESSAGE_ZH = '电脑内存或虚拟内存不够,模型没能载入。关掉其他程序,或调大系统的虚拟内存后再试。'+++def host_memory_shortage(error):+ """The machine's own memory ran out, not the card's."""+ return commit_exhausted(error)class FailureError(ValueError):@@ -77,7 +82,7 @@ def classify_exception(error, *, stage='start', cancelled=False):seen.add(id(error))chain.append(error)error = error.__cause__ or (None if error.__suppress_context__ else error.__context__)- if commit_exhausted(chain[0]) if chain else False:+ if chain and commit_exhausted(chain[0]):return 'no_memory'for item in chain:names = {cls.__name__ for cls in type(item).__mro__}diff --git a/freevideo_engine/image_gen/image_runner.py b/freevideo_engine/image_gen/image_runner.pyindex 70862b3..e4e11ca 100644--- a/freevideo_engine/image_gen/image_runner.py+++ b/freevideo_engine/image_gen/image_runner.py@@ -283,15 +283,7 @@ class ImageRunner:from ..system import system_memorymemory = system_memory()free = memory.get('physical_available_bytes') or memory['available_bytes']- held = self.dit_stack.host_bytes + self.te_stack.host_bytes- host_available = free + held- # Windows charges every committed page to the paging file, so free RAM alone- # can promise more than the commit limit leaves. A system-managed paging file- # also grows on demand, so the working margin is not held against the headroom:- # only a request whose unpinned weights cannot fit in it is refused early.- commit = memory.get('commit_available_bytes')- if commit is not None:- host_available = min(host_available, commit + held + image_policy.MIN_HOST_WORKING)+ host_available = free + self.dit_stack.host_bytes + self.te_stack.host_bytesif self.full_card or self.mapped:host_available = Noneexcept Exception:diff --git a/freevideo_engine/image_gen/service.py b/freevideo_engine/image_gen/service.pyindex 9595ca5..3255b9f 100644--- a/freevideo_engine/image_gen/service.py+++ b/freevideo_engine/image_gen/service.py@@ -18,8 +18,7 @@ import uuidfrom . import image_packfrom ..download_settings import observed_speed-from ..diagnostic_resources import commit_exhausted-from .failure import (COMMIT_MESSAGE_ZH, Context, ERRORS, FailureError, MESSAGE_ZH, NO_REPORT, STAGES, UNIFIED_MESSAGE_ZH,+from .failure import (Context, HOST_MESSAGE_ZH, host_memory_shortage, ERRORS, FailureError, MESSAGE_ZH, NO_REPORT, STAGES, UNIFIED_MESSAGE_ZH,classify_exception)BODY_LIMIT = 64 * 1024@@ -749,8 +748,9 @@ class Service:result['message_zh'] = MESSAGE_ZH[code]if context.machine.get('device_backend') == 'mps' and code in UNIFIED_MESSAGE_ZH:result['message_zh'] = UNIFIED_MESSAGE_ZH[code]- if code == 'no_memory' and error is not None and commit_exhausted(error):- result['message_zh'] = COMMIT_MESSAGE_ZH+ if code == 'no_memory' and (isinstance(row, dict) and row.get('memory') == 'host'+ or error is not None and host_memory_shortage(error)):+ result.update(memory='host', message_zh=HOST_MESSAGE_ZH)if code not in NO_REPORT:if video_busy is None:try:diff --git a/freevideo_engine/image_gen/worker.py b/freevideo_engine/image_gen/worker.pyindex 469acf6..f9c565a 100644--- a/freevideo_engine/image_gen/worker.py+++ b/freevideo_engine/image_gen/worker.py@@ -9,7 +9,7 @@ import sysimport threadingimport time-from .failure import Context, classify_exception, exception_details, safe_plan+from .failure import Context, classify_exception, exception_details, host_memory_shortage, safe_planclass Inbox:@@ -170,6 +170,8 @@ def serve(pack_dir, *, device='cuda', idle_seconds=45., stream=None, output=Noneresult = dict(phase='error', code=code, stage=context.timing.stage, reloaded=reload,seconds=context.timing.seconds(), stages=context.timing.snapshot(), plan=plan,error=exception_details(error, context.redactor, code))+ if code == 'no_memory' and host_memory_shortage(error):+ result['memory'] = 'host'try:result.update(attention_report(runner, context.redactor))except Exception:diff --git a/web/image_generation.js b/web/image_generation.jsindex f98d334..8bba343 100644--- a/web/image_generation.js+++ b/web/image_generation.js@@ -176,6 +176,9 @@ export function imageGenError(code, info, t) {};const say = (en, zh) => t(...memoryWords([en, zh], info?.unified));if (code === 'pack_missing') return imagePackUnavailableMessage(info, t);+ if (code === 'no_memory' && info?.memory === 'host')+ return t('Not enough system memory or virtual memory to load the model. Close other programs, or enlarge the system virtual memory, then try again.',+ '电脑内存或虚拟内存不够,模型没能载入。关掉其他程序,或调大系统的虚拟内存后再试。');if (code === 'no_memory') {// Where it ran out decides what helps: the reference pictures are read at a fixed size,// so a smaller canvas does not change that stage.@@ -211,7 +214,7 @@ export const REPORT_LABELS = Object.freeze({// Shared by the editor and the other image entry points. Only the opaque report// ID goes in the request; raw service messages are never shown in the page.-export function renderImageFailure(host, {error, report_id, stage, fitted, info} = {}, t,+export function renderImageFailure(host, {error, report_id, stage, fitted, info, memory} = {}, t,{productVersion = () => null, fetchApi = globalThis.fetch.bind(globalThis)} = {}) {host.replaceChildren();if (!error || error === 'cancelled') return null;@@ -222,7 +225,7 @@ export function renderImageFailure(host, {error, report_id, stage, fitted, info}}const card = doc.createElement('div'); card.className = 'fv-result-links';const reason = doc.createElement('div'); reason.className = 'fv-image-failure-reason';- reason.setAttribute('role', 'status'); reason.textContent = imageGenError(error, {stage, fitted, unified: info?.unified_memory}, t);+ reason.setAttribute('role', 'status'); reason.textContent = imageGenError(error, {stage, fitted, memory, unified: info?.unified_memory}, t);card.append(reason); host.append(card);if (!report_id) return card;const fetchReport = async () => {