mirror of
https://github.com/YaoFANGUK/video-subtitle-remover.git
synced 2026-05-18 11:37:35 +08:00
GPU加速和批处理优化、更新README
Some checks failed
Docker Build and Push / check-secrets (push) Successful in 3s
Docker Build and Push / build-and-push (cpu, latest) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 11.8) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 12.6) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 12.8) (push) Has been skipped
Docker Build and Push / build-and-push (directml, latest) (push) Has been skipped
Build Windows CPU / build (push) Has been cancelled
Build Windows CUDA 11.8 / build (push) Has been cancelled
Build Windows CUDA 12.6 / build (push) Has been cancelled
Build Windows CUDA 12.8 / build (push) Has been cancelled
Build Windows DirectML / build (push) Has been cancelled
Some checks failed
Docker Build and Push / check-secrets (push) Successful in 3s
Docker Build and Push / build-and-push (cpu, latest) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 11.8) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 12.6) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 12.8) (push) Has been skipped
Docker Build and Push / build-and-push (directml, latest) (push) Has been skipped
Build Windows CPU / build (push) Has been cancelled
Build Windows CUDA 11.8 / build (push) Has been cancelled
Build Windows CUDA 12.6 / build (push) Has been cancelled
Build Windows CUDA 12.8 / build (push) Has been cancelled
Build Windows DirectML / build (push) Has been cancelled
- STTN Auto/Det: 统一 torch.no_grad 包裹,减少重复上下文切换开销 - STTN Auto: 添加 FramePrefetcher 帧预读取,根据 GPU 显存动态调整 batch size - Lama Inpaint: 新增 _inpaint_batch 批量推理,多帧合并一次 GPU 推理 - ProPainter: copy.deepcopy 替换为浅拷贝,每个区域处理后 gc.collect - HardwareAccelerator: 新增 get_available_vram_mb 显存查询方法 - README: 添加应用 Logo,同步英文版 README_en.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,27 @@ class HardwareAccelerator:
|
||||
def set_enabled(self, enable):
|
||||
self.__enabled = enable
|
||||
|
||||
def get_available_vram_mb(self):
|
||||
"""获取可用 GPU 显存(MB),无 GPU 返回 0"""
|
||||
if not self.__enabled:
|
||||
return 0
|
||||
if self.__cuda:
|
||||
try:
|
||||
free_vram = torch.cuda.mem_get_info()[0] # (free, total)
|
||||
return free_vram / (1024 * 1024)
|
||||
except Exception:
|
||||
return 0
|
||||
if self.__mps:
|
||||
try:
|
||||
# MPS 没有直接查询接口,使用系统内存作为参考
|
||||
import subprocess
|
||||
result = subprocess.run(['sysctl', '-n', 'hw.memsize'], capture_output=True, text=True)
|
||||
total_mem = int(result.stdout.strip()) / (1024 * 1024)
|
||||
return total_mem * 0.5 # 保守估计可用一半
|
||||
except Exception:
|
||||
return 0
|
||||
return 0
|
||||
|
||||
@property
|
||||
def device(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user