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.
"""Keep ComfyUI process configuration out of managed engine children."""
import os
import shutil
from pathlib import Path
import sys
def with_private_compiler(root, env):
"""Without a system compiler, tools that build at run time (Triton) use the one FreeVideo installed."""
private = Path(root) / 'tools' / 'gcc-bin' / 'gcc'
if os.name != 'nt' and 'CC' not in env and private.exists() and not shutil.which('gcc', path=env.get('PATH')):
env['CC'] = str(private)
return env
EXECUTOR_DEVICE = 'FREEVIDEO_EXECUTOR_DEVICE'
POOL_CONTROL = 'FREEVIDEO_POOL_CONTROL'
def executor_device(environ=None):
return (os.environ if environ is None else environ).get(EXECUTOR_DEVICE, '')
def control_process(environ=None):
env = os.environ if environ is None else environ
return not executor_device(env) and env.get(POOL_CONTROL) == '1'
def configure_control(command, environment):
"""Configure before Comfy imports Torch; leave the single-device launch intact."""
from .gpu_pool import pool_enabled
if executor_device(environment) or not pool_enabled(environment):
return command, environment
env = dict(environment, FREEVIDEO_POOL_CONTROL='1', FREEVIDEO_BACKGROUND_COMPILE='off',
FREEVIDEO_PROMPT_PRESTART='off')
return [*command, '--cpu'], env
def isolated_environment(root, source, environ=None):
"""Remove inherited Python/package targets only in the engine's child."""
from .proxy import inherited
from .download_settings import read
env = inherited(environ)
proxy_mode = read(Path(root) / 'download-settings.json')['proxy_mode']
prefixes = [env.get(name) for name in ('VIRTUAL_ENV', 'CONDA_PREFIX')]
prefixes.append(sys.prefix)
# Do not remove /usr/bin when Comfy itself uses a system interpreter.
prefixes = [Path(p).resolve() for p in prefixes if p and Path(p).resolve() not in
(Path('/usr'), Path('/usr/local'), Path('/'))]
for name in ('PATH', 'LD_LIBRARY_PATH'):
if name not in env:
continue
kept = []
for entry in env[name].split(os.pathsep):
if not entry:
continue
path = Path(entry).resolve()
if not any(path == prefix or prefix in path.parents for prefix in prefixes):
kept.append(entry)
env[name] = os.pathsep.join(kept)
for name in list(env):
if (name.startswith(('PYTHON', 'CONDA_', 'UV_', 'PIP_')) and name != 'PIP_PROXY' or name == 'VIRTUAL_ENV'
or name.startswith('FREEVIDEO_BOOTSTRAP_') or name in
('FREEVIDEO_PYTHON', 'FREEVIDEO_FORCE_BOOTSTRAP', 'FREEVIDEO_RUNTIME_LOCK_FD',
'FREEVIDEO_RUNTIME_LOCK_HANDLE')):
env.pop(name, None)
env.update(FREEVIDEO_HOME=str(root), FREEVIDEO_PROXY_MODE=proxy_mode, PYTHONPATH=str(source), PYTHONNOUSERSITE='1',
PYTHONUTF8='1', PYTHONIOENCODING='utf-8', NO_COLOR='1', FREEVIDEO_UI_EVENTS='1')
with_private_compiler(root, env)
from .triton_compat import temporary_environment
# Pruning sys.prefix above also prunes the frozen launcher's static curl.
# Restore its fallback for managed Python after isolating Python packages.
from .linux_bundle import child_environment
return temporary_environment(root, child_environment(env))