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.
A missing or failing nvidia-smi falls back to the CUDA driver reading
Bowen Xue65b3edcd76e7
diff --git a/freevideo_engine/bootstrap.py b/freevideo_engine/bootstrap.pyindex bf04997..414a287 100644--- a/freevideo_engine/bootstrap.py+++ b/freevideo_engine/bootstrap.py@@ -301,16 +301,46 @@ def digest(path, algorithm='sha256', git_blob=False):def inventory(gpu=None):- smi = nvidia_smi()query = 'index,uuid,name,compute_cap,memory.total,memory.free,driver_version,pci.bus_id'- result = subprocess_output.run_external([smi, '--query-gpu=' + query, '--format=csv,noheader,nounits'],- check=True, capture_output=True, timeout=20)- rows = [dict(zip(query.split(','), map(str.strip, row))) for row in csv.reader(result.stdout.splitlines())]selector = gpu if gpu is not None else os.environ.get('CUDA_VISIBLE_DEVICES', '0').split(',')[0]- matches = [r for r in rows if r['index'] == selector or r['uuid'] == selector]- if len(matches) != 1:- raise ValueError('Select one physical GPU by nvidia-smi index or full UUID with --gpu. MIG is not supported.')- selected = matches[0]+ detection = {}+ try:+ smi = nvidia_smi()+ result = subprocess_output.run_external([smi, '--query-gpu=' + query, '--format=csv,noheader,nounits'],+ check=True, capture_output=True, timeout=20)+ rows = [dict(zip(query.split(','), map(str.strip, row))) for row in csv.reader(result.stdout.splitlines())]+ if not rows or any(set(row) != set(query.split(',')) for row in rows):+ raise ValueError('nvidia-smi returned an incomplete GPU inventory')+ # Unsupported numeric fields are also a failed observation, not proof+ # that the user has no GPU. Only the selected row has to be readable;+ # another GPU reporting N/A must not block an installation that worked.+ matches = [r for r in rows if r['index'] == selector or r['uuid'] == selector]+ if len(matches) == 1:+ row = matches[0]+ float(row['memory.total']), float(row['memory.free'])+ int(row['driver_version'].split('.')[0])+ capability = tuple(map(int, row['compute_cap'].split('.')))+ if len(capability) != 2 or capability[0] <= 0 or not 0 <= capability[1] <= 9:+ raise ValueError('nvidia-smi returned an unknown compute capability: ' + row['compute_cap'])+ except (OSError, RuntimeError, ValueError, subprocess.SubprocessError) as error:+ from . import cuda_inventory+ try:+ fallback = cuda_inventory.probe(selector)+ except (OSError, RuntimeError, ValueError, subprocess.SubprocessError) as fallback_error:+ raise RuntimeError('GPU detection failed. nvidia-smi: %s; CUDA: %s. '+ 'Check device access and the NVIDIA driver, then retry setup.' %+ (error, fallback_error)) from fallback_error+ selected, rows = fallback['selected_gpu'], fallback['gpus']+ detection = dict(cuda_driver_api_version=fallback['cuda_driver_api_version'],+ warnings=[cuda_inventory.WARNING],+ gpu_detection=dict(source='cuda-driver', nvidia_smi_error=str(error),+ nvidia_smi_returncode=getattr(error, 'returncode', None),+ nvidia_smi_stderr=getattr(error, 'stderr', None)))+ logging.getLogger(__name__).info('%s nvidia-smi: %s', cuda_inventory.WARNING, error)+ else:+ if len(matches) != 1:+ raise ValueError('Select one physical GPU by nvidia-smi index or full UUID with --gpu. MIG is not supported.')+ selected = matches[0]try:capability = tuple(map(int, selected['compute_cap'].split('.')))if len(capability) != 2:@@ -332,7 +362,7 @@ def inventory(gpu=None):'swap_free_bytes': ram.get('swap_free_bytes'), 'system_memory': ram,'compiler': shutil.which('cl' if platform.system() == 'Windows' else 'g++'), 'git': usable_git(),**({} if platform.system() == 'Windows' else {'make': shutil.which('make')}),- 'git_found': shutil.which('git')}+ 'git_found': shutil.which('git'), **detection}# Windows reuses a detected Git from 2.35, the oldest tested there, and@@ -522,6 +552,7 @@ def plan(args, *, local_progress=None, stage=None):if not args.hardware_json and (platform.system() not in ('Linux', 'Windows') or platform.machine().lower() not in ('x86_64', 'amd64')):raise RuntimeError('One-click setup supports Linux x86_64 and native Windows x64.')snapshot = json.loads(args.hardware_json.read_text(encoding='utf-8')) if args.hardware_json else inventory(args.gpu)+ warnings.extend(snapshot.get('warnings', []))hardware = Hardware.from_dict(snapshot['hardware'])errors = []if snapshot.get('machine', '').lower() not in ('x86_64', 'amd64') or hardware.system not in ('Linux', 'Windows'):@@ -535,7 +566,8 @@ def plan(args, *, local_progress=None, stage=None):driver = str(snapshot['selected_gpu']['driver_version']).strip()# An unreadable version is left to the later checks instead of blocking setup.major = re.match(r'\d+', driver)- if major and int(major.group()) < 580:+ cuda_api = snapshot.get('cuda_driver_api_version')+ if cuda_api < 13000 if cuda_api is not None else (major and int(major.group()) < 580):# The card names the graphics card too; brackets would end its pattern early.model = re.sub(r'[()\r\n]', '', str(snapshot['selected_gpu'].get('name') or '')).strip()errors.append('NVIDIA driver %s%s is older than 580, the minimum for the CUDA 13 encoder; update the driver first.'diff --git a/freevideo_engine/cuda_inventory.py b/freevideo_engine/cuda_inventory.pynew file mode 100644index 0000000..193de98--- /dev/null+++ b/freevideo_engine/cuda_inventory.py@@ -0,0 +1,97 @@+"""Stdlib-only setup fallback when the NVML command cannot report GPU details.++Run in a child: its temporary CUDA context must exit before installation starts.+CUDA ordinals are not nvidia-smi indices; only UUIDs identify multi-GPU selections.+"""+import ctypes as C+import json+import os+import sys+import uuid++from . import processes, subprocess_output+++WARNING = ('NVIDIA GPU information could not be read with nvidia-smi. CUDA detected the GPU; '+ 'you can continue. Setup will test it before marking it ready.')+++def probe(selector=None):+ env = dict(os.environ)+ # Enumerate physical devices, then select by stable UUID in the worker too.+ env.pop('CUDA_VISIBLE_DEVICES', None)+ result = subprocess_output.run_python(processes.module_command(__name__, '0' if selector is None else selector),+ env=env, capture_output=True, timeout=30)+ if result.returncode:+ raise RuntimeError(result.stderr.strip() or 'CUDA GPU detection exited with code %d' % result.returncode)+ return json.loads(result.stdout)+++def local_probe(selector=None):+ driver = C.WinDLL('nvcuda.dll') if sys.platform == 'win32' else C.CDLL('libcuda.so.1')++ def call(name, types, *args):+ function = getattr(driver, name)+ function.argtypes, function.restype = types, C.c_int+ status = function(*args)+ if status:+ raise RuntimeError('%s failed (CUDA error %d)' % (name, status))++ integer = C.POINTER(C.c_int)+ call('cuInit', [C.c_uint], 0)+ version, count = C.c_int(), C.c_int()+ call('cuDriverGetVersion', [integer], C.byref(version))+ call('cuDeviceGetCount', [integer], C.byref(count))+ rows = []+ for ordinal in range(count.value):+ device, major, minor = C.c_int(), C.c_int(), C.c_int()+ call('cuDeviceGet', [integer, C.c_int], C.byref(device), ordinal)+ name, pci = C.create_string_buffer(256), C.create_string_buffer(32)+ identity = C.create_string_buffer(16)+ call('cuDeviceGetName', [C.c_void_p, C.c_int, C.c_int], name, len(name), device)+ call('cuDeviceGetPCIBusId', [C.c_void_p, C.c_int, C.c_int], pci, len(pci), device)+ call('cuDeviceGetUuid', [C.c_void_p, C.c_int], identity, device)+ if hasattr(driver, 'cuDeviceGetUuid_v2'):+ instance = C.create_string_buffer(16)+ call('cuDeviceGetUuid_v2', [C.c_void_p, C.c_int], instance, device)+ if instance.raw != identity.raw:+ raise RuntimeError('MIG is not supported by setup. Select a physical GPU.')+ call('cuDeviceGetAttribute', [integer, C.c_int, C.c_int], C.byref(major), 75, device)+ call('cuDeviceGetAttribute', [integer, C.c_int, C.c_int], C.byref(minor), 76, device)+ rows.append({'index': '', 'cuda_ordinal': ordinal, 'uuid': 'GPU-' + str(uuid.UUID(bytes=identity.raw)),+ 'name': name.value.decode('utf-8', errors='replace'), 'pci.bus_id': pci.value.decode('ascii'),+ 'compute_cap': '%d.%d' % (major.value, minor.value), 'driver_version': ''})+ if not rows:+ raise RuntimeError('CUDA found no accessible GPUs. Check the NVIDIA driver and device access, then retry setup.')+ if selector and selector.startswith('MIG-'):+ raise ValueError('MIG is not supported by setup. Select a physical GPU.')+ if selector and selector.startswith('GPU-'):+ matches = [row for row in rows if row['uuid'] == selector]+ elif len(rows) == 1 and selector in (None, '0'):+ matches = rows+ else:+ raise ValueError('nvidia-smi indices are unavailable. Select a full GPU UUID with --gpu: '+ + ', '.join(row['uuid'] + ' (' + row['name'] + ')' for row in rows))+ if len(matches) != 1:+ raise ValueError('The selected GPU UUID was not found by CUDA: ' + str(selector))+ selected = matches[0]+ device = C.c_int()+ call('cuDeviceGet', [integer, C.c_int], C.byref(device), selected['cuda_ordinal'])+ context = C.c_void_p()+ call('cuDevicePrimaryCtxRetain', [C.POINTER(C.c_void_p), C.c_int], C.byref(context), device)+ try:+ call('cuCtxSetCurrent', [C.c_void_p], context)+ free, total = C.c_size_t(), C.c_size_t()+ call('cuMemGetInfo_v2', [C.POINTER(C.c_size_t), C.POINTER(C.c_size_t)], C.byref(free), C.byref(total))+ selected.update({'memory.total': str(total.value / 2**20), 'memory.free': str(free.value / 2**20)})+ finally:+ call('cuDevicePrimaryCtxRelease_v2', [C.c_int], device)+ return dict(selected_gpu=selected, gpus=rows, cuda_driver_api_version=version.value)+++if __name__ == '__main__':+ try:+ print(json.dumps(local_probe(sys.argv[1] if len(sys.argv) > 1 else None)))+ except (OSError, RuntimeError, ValueError, AttributeError) as error:+ print(str(error), file=sys.stderr)+ sys.exit(1)