Skip to content

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.

Treat exhausted Windows virtual memory as out of memory for image generation

Bowen Xueb6f328f910a8
diff --git a/freevideo_engine/image_gen/failure.py b/freevideo_engine/image_gen/failure.py
index 6aeb6ef..4920049 100644
--- a/freevideo_engine/image_gen/failure.py
+++ b/freevideo_engine/image_gen/failure.py
@@ -11,6 +11,7 @@ import traceback
from .. import __version__
from ..disk_space import ran_out
from ..exit_diagnostics import clean_reading, clean_sample
+from ..diagnostic_resources import commit_exhausted
from ..failure_details import Redactor
@@ -55,6 +56,7 @@ _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 = '系统的虚拟内存不够,图像生成没能载入模型。关掉其他程序,或在系统设置里调大虚拟内存后再试。'
class FailureError(ValueError):
@@ -75,6 +77,8 @@ 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:
+ return 'no_memory'
for item in chain:
names = {cls.__name__ for cls in type(item).__mro__}
if isinstance(item, MemoryError) or 'OutOfMemoryError' in names or _MPS_MEMORY.search(str(item)):
diff --git a/freevideo_engine/image_gen/image_runner.py b/freevideo_engine/image_gen/image_runner.py
index e4e11ca..ed6d2cd 100644
--- a/freevideo_engine/image_gen/image_runner.py
+++ b/freevideo_engine/image_gen/image_runner.py
@@ -283,7 +283,13 @@ class ImageRunner:
from ..system import system_memory
memory = system_memory()
free = memory.get('physical_available_bytes') or memory['available_bytes']
- host_available = free + self.dit_stack.host_bytes + self.te_stack.host_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.
+ commit = memory.get('commit_available_bytes')
+ if commit is not None:
+ host_available = min(host_available, commit + held)
if self.full_card or self.mapped:
host_available = None
except Exception:
diff --git a/freevideo_engine/image_gen/service.py b/freevideo_engine/image_gen/service.py
index ed00e03..9595ca5 100644
--- a/freevideo_engine/image_gen/service.py
+++ b/freevideo_engine/image_gen/service.py
@@ -18,7 +18,8 @@ import uuid
from . import image_pack
from ..download_settings import observed_speed
-from .failure import (Context, ERRORS, FailureError, MESSAGE_ZH, NO_REPORT, STAGES, UNIFIED_MESSAGE_ZH,
+from ..diagnostic_resources import commit_exhausted
+from .failure import (COMMIT_MESSAGE_ZH, Context, ERRORS, FailureError, MESSAGE_ZH, NO_REPORT, STAGES, UNIFIED_MESSAGE_ZH,
classify_exception)
BODY_LIMIT = 64 * 1024
@@ -748,6 +749,8 @@ 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 not in NO_REPORT:
if video_busy is None:
try: