diff --git a/00E.OBS透明通道-StreamFX.url b/00E.OBS透明通道-StreamFX.url deleted file mode 100644 index e44cc72..0000000 --- a/00E.OBS透明通道-StreamFX.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,11 -[InternetShortcut] -IDList= -URL=https://github.com/Xaymar/obs-StreamFX diff --git a/00F.OBS透明通道-着色器文件.url b/00F.OBS透明通道-着色器文件.url deleted file mode 100644 index cc8014f..0000000 --- a/00F.OBS透明通道-着色器文件.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,11 -[InternetShortcut] -IDList= -URL=https://github.com/shugen002/shader/blob/master/merge%20alpha2.hlsl diff --git a/01A.构建运行环境(默认源).bat b/01A.构建运行环境(默认源).bat index 0837ecb..4e6fba0 100644 --- a/01A.构建运行环境(默认源).bat +++ b/01A.构建运行环境(默认源).bat @@ -28,6 +28,7 @@ call conda create -y -n ezvtb_rt_venv python=3.10 call conda activate ezvtb_rt_venv call conda env list +call conda install -y nvidia/label/cuda-12.6.3::cuda-nvcc-dev_win-64 call conda install -y conda-forge::pycuda call python -m pip install --upgrade pip wheel diff --git a/01B.构建运行环境(国内源).bat b/01B.构建运行环境(国内源).bat index 7a0eedc..1e20ea1 100644 --- a/01B.构建运行环境(国内源).bat +++ b/01B.构建运行环境(国内源).bat @@ -28,6 +28,7 @@ call conda create -y -n ezvtb_rt_venv python=3.10 call conda activate ezvtb_rt_venv call conda env list +call conda install -y nvidia/label/cuda-12.6.3::cuda-nvcc-dev_win-64 call conda install -y pycuda -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ call python -m pip install --upgrade pip wheel -i https://mirrors.aliyun.com/pypi/simple/ diff --git a/PerformanceTest.md b/PerformanceTest.md new file mode 100644 index 0000000..1d048ea --- /dev/null +++ b/PerformanceTest.md @@ -0,0 +1,123 @@ +# 测试环境 +### 基于 +* Release版本v0.3 +* 测试平台为windows10 22H2 +* CPU Intel 10400f +* GPU Nvidia 3060 12G, Nvidia 1660 Super 6G, ARC A770 16G,RX580 8G. + +### 测试定量 +* Jpeg compression 和 Input Simplify 设为 medium +* 使用debug input 和 debug output +* 不使用eyebrow参数 +* 帧数限制60fps +* 英伟达显卡使用TensorRT测试 + +观察开始后约5-10秒的数值记录, 即不考虑长期缓存效果(没时间测) + +# 测试结果 +请注意测试结果仅限参考显卡大概性能,具体性能取决于用户周边配置和显卡驱动。 + +GPU | model | VRAM Cache | RAM Cache | Interpolation | SR | Frame Rate | GPU Usage +:---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: +A770 | sepe_half | N/A | No | No | No | 33fps | 97% +A770 | sepe_full | N/A | No | No | No | 48fps | 97% +A770 | stan_half | N/A | No | No | No | 27fps | 97% +A770 | stan_full | N/A | No | No | No | 29fps | 97% +A770 | sepe_half | N/A | 2GB | No | No | 30fps | 82% +A770 | sepe_full | N/A | 2GB | No | No | 43fps | 78% +A770 | stan_half | N/A | 2GB | No | No | 30fps | 82% +A770 | stan_full | N/A | 2GB | No | No | 23fps | 85% +A770 | sepe_full | N/A | No | No | x2_half | 17fps | 97% +A770 | sepe_full | N/A | No | No | x4_half | 29fps | 97% +A770 | sepe_full | N/A | No | No | x4_full | 25fps | 93% +A770 | sepe_full | N/A | No | x2_half | No | 60fps | 93% +A770 | sepe_full | N/A | No | x3_half | No | 60fps | 85% +A770 | sepe_full | N/A | No | x4_half | No | 60fps | 81% +-- | -- | --| --|--|--|--|-- +RX580 | sepe_full | N/A | No | No | No | 12fps | 98% +RX580 | stan_full | N/A | No | No | No | 15fps | 98% +RX580 | sepe_full | N/A | 2GB | No | No | 11fps | 93% +RX580 | stan_full | N/A | 2GB | No | No | 13fps | 93% +RX580 | stan_full | N/A | No | No | x2_half | 10fps | 97% +RX580 | stan_full | N/A | No | No | x2_full | 10fps | 97% +RX580 | stan_full | N/A | No | No | x4_half | 11fps | 98% +RX580 | stan_full | N/A | No | No | x4_full | 11fps | 98% +RX580 | stan_full | N/A | No | x2_half | no | 22fps | 98% +RX580 | stan_full | N/A | No | x2_full | no | 22fps | 98% +RX580 | stan_full | N/A | No | x3_half | no | 28fps | 98% +RX580 | stan_full | N/A | No | x3_full | no | 28fps | 98% +RX580 | stan_full | N/A | No | x4_half | no | 33fps | 98% +RX580 | stan_full | N/A | No | x4_full | no | 33fps | 98% +-- | -- | --| --|--|--|--|-- +1660s | sepe_half | No | No | No | No | 38fps | 95% +1660s | sepe_full | No | No | No | No | 28fps | 95% +1660s | stan_half | No | No | No | No | 21fps | 96% +1660s | stan_full | No | No | No | No | 12fps | 98% +1660s | sepe_half | 2GB | No | No | No | 39fps | 95% +1660s | sepe_full | 2GB | No | No | No | 28fps | 95% +1660s | stan_half | 2GB | No | No | No | 29fps | 96% +1660s | stan_full | 2GB | No | No | No | 12fps | 96% +1660s | sepe_half | 2GB | 2GB | No | No | 40fps | 75% +1660s | sepe_full | 2GB | 2GB | No | No | 24fps | 80% +1660s | stan_half | 2GB | 2GB | No | No | 26fps | 83% +1660s | stan_full | 2GB | 2GB | No | No | 12fps | 92% +1660s | sepe_half | No | No | No | x2_half | 23fps | 96% +1660s | sepe_half | No | No | No | x2_full | 18fps | 96% +1660s | sepe_half | No | No | No | x4_half | 23fps | 96% +1660s | sepe_half | No | No | No | x4_full | 26fps | 97% +1660s | sepe_half | No | No | x2_half | No | 63fps | 75% +1660s | sepe_half | No | No | x2_full | No | 63fps | 80% +1660s | sepe_half | No | No | x3_half | No | 63fps | 65% +1660s | sepe_half | No | No | x3_full | No | 64fps | 66% +1660s | sepe_half | No | No | x4_half | No | 64fps | 53% +1660s | sepe_half | No | No | x4_full | No | 64fps | 60% +-- | -- | --| --|--|--|--|-- +3060 | sepe_half | No | No | No | No | 63fps | 62% +3060 | sepe_full | No | No | No | No | 59fps | 93% +3060 | stan_half | No | No | No | No | 63fps | 80% +3060 | stan_full | No | No | No | No | 31fps | 96% +3060 | sepe_half | 2GB | No | No | No | 63fps | 60% +3060 | sepe_full | 2GB | No | No | No | 60fps | 93% +3060 | stan_half | 2GB | No | No | No | 63fps | 76% +3060 | stan_full | 2GB | No | No | No | 33fps | 96% +3060 | sepe_half | 2GB | 2GB | No | No | 63fps | 58% +3060 | sepe_full | 2GB | 2GB | No | No | 46fps | 70% +3060 | stan_half | 2GB | 2GB | No | No | 43fps | 62% +3060 | stan_full | 2GB | 2GB | No | No | 27fps | 80% +3060 | sepe_half | No | No | No | x2_half | 53fps | 85% +3060 | sepe_half | No | No | No | x2_full | 30fps | 94% +3060 | sepe_half | No | No | No | x4_half | 49fps | 90% +3060 | sepe_half | No | No | No | x4_full | 45fps | 90% +3060 | sepe_half | No | No | x2_half | No | 64fps | 45% +3060 | sepe_half | No | No | x2_full | No | 63fps | 50% +3060 | sepe_half | No | No | x3_half | No | 64fps | 35% +3060 | sepe_half | No | No | x3_full | No | 64fps | 42% +3060 | sepe_half | No | No | x4_half | No | 64fps | 30% +3060 | sepe_half | No | No | x4_full | No | 64fps | 40% + +# 已知问题: +* A770: rife插帧全精度会出现奇怪结果, waifu2x 超分的全精度会输出全绿色 +* RX580 tha3 模型半精度会输出奇怪结果 +* 3060 有时出现奇怪运行时占用上升,猜测为插拔显卡导致的驱动问题。 + +# DirectML 思考 +DirectML 允许所有 Windows 显卡设备以及 AIPC 的 NPU 运行此项目,但由于不同设备的 Kernel 在不同精度下实现区别和驱动兼容问题, +导致 DirectML 的运行结果在某个模型的某些精度出现不可用的扭曲结果,且运行性能与对模型的常识理解不相符。 + +例如适用于本项目插帧的RIFE模型的调用封装经历过一轮迭代, +由原先的n次输入(N=1,C,H,W)独立图像调用RIFE模型生成n个独立结果, +改为输入(N=n,C,H,W)的叠加图像一次性调用RIFE模型得到叠加结果, +此改动下模型获得了稍小的显存占用且在TensorRT实现中获得一定性能提升(虽然改动本意并不在此)。 +接着在笔者环境中的因特尔 A770 显卡 DirectML 在RIFE模型迭代后全精度推理结果由原先的符合预期变为扭曲图像, +半精度迭代后模型不仅保持推理结果符合预期,且相较模型迭代前得到了一定性能提升。 + +再例如笔者测试某 AMD 核显运行时发现其运行THA3的半精度模型时会因为此设备无法运行其中的某个kernel而将kernel运算单独卸载到cpu进行, +但保留了其他大部分能在核显上运行的kernel,由此推理模型需要结果在两个设备间反复,带来了极大的性能倒退。 + +目前阶段,受限于Python OnnxRuntime api 的支持匮乏(相较C++),使用 python 运行 Directml 无法避免上述问题, +在代码层面无法在运行前做出是否适配的条件判断,也无法在出现kernel卸载到cpu性能剧降时raise错误将运行打断。 + +所以,DirectML运行本项目的任意模型出现奇怪结果,或不符合预期的性能倒退,都应该属于意料之中 +换个模型精度,观察调试输出是否有DirectML黄字警告 通常可以解决大部分问题。 +具体某个硬件在DirectML的运行异常修复,已远超本项目的目标范围,请自行验证失效kernel,向硬件厂商和微软求助并期待驱动更新带来解决 +(建议买张N卡吧别折腾自己了)。 diff --git a/README.md b/README.md index cc166c5..5582797 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,16 @@ Updates: * 为A卡和I卡提供DirectML支持,人人都能玩。 * 引入[RIFE](https://github.com/hzwer/ECCV2022-RIFE)模型进行插帧,极限帧数提升达到50%-100%,配合锁帧可以有效降低使用占用。 * 使用 [TurboJPEG](https://github.com/Dobatymo/turbojpeg-python) 获得成倍缓存命中率提升,在长时间使用上显卡减负效果相当出色。 -* 使用 [waifu2x](https://github.com/nagadomi/waifu2x) 和 [real-esrgan]() 项目带来的输出超分辨率,对比anime4k效果提升显著(也使用更多gpu占用) +* 使用 [waifu2x](https://github.com/nagadomi/waifu2x) 和 [real-esrgan](https://github.com/xinntao/Real-ESRGAN) 项目带来的输出超分辨率,对比anime4k效果提升显著(也使用更多gpu占用) * 更漂亮的 WxPython 新启动器界面,带中文介绍更加简单易用 +* 添加Spout2 支持输出原生透明通道给OBS ## Requirements ### 硬件 - 支持FaceID的iPhone(使用ifacialmocap软件,需购买,需要稳定的WIFI连接)或网络摄像头(使用OpenCV) -- 任意5年内的游戏级显卡,N卡/A卡/I卡均可使用 +- 任意5年内的游戏级显卡,N卡/A卡/I卡均可使用,某些性能强的核显也可尝试,请参考[性能测试结果](PerformanceTest.md) ### 软件 - 本方案在Windows 10上测试可用 @@ -76,7 +77,7 @@ Start testing if TensorRT works on this machine ``` ### 启动项目 -双击`02A.启动器.bat` 或 `02B.启动器(调试输出).bat` 启动器,如下图启动: +双击`02A.启动器.bat` 或 `02B.启动器(调试输出).bat` 启动器,如下图启动(可在上一步构建同时启动,将TensorRT去除勾选即可): ![](assets/02success.png) 之后请移步输入输出自行调节。 @@ -89,7 +90,7 @@ Start testing if TensorRT works on this machine C:\Users\Eleven>conda --version conda 24.11.3 ``` -以上方式可以保证conda环境被你选定的Ananconda统一管理。若没有此需求可以忽略直接运行下一步,脚本会自动安装miniconda。 +以上方式可以保证conda环境被你选定的Ananconda统一管理。若没有此需求可以忽略直接运行下一步,`01X.构建运行环境(XX源).bat`脚本会自动安装miniconda。 ### 克隆项目和子项目 ``` @@ -100,12 +101,13 @@ git submodule update --recursive --remote ``` ### 安装环境 -双击运行`01A.构建运行环境(默认源).bat`或者`01B.构建运行环境(国内源).bat` +根据网络环境双击运行`01A.构建运行环境(默认源).bat`或者`01B.构建运行环境(国内源).bat` 这两个脚本会构建名为`ezvtb_rt_venv`的conda环境 或可以用如下命令手动创建: ``` conda create -y -n ezvtb_rt_venv python=3.10 conda activate ezvtb_rt_venv +call conda install -y nvidia/label/cuda-12.6.3::cuda-nvcc-dev_win-64 conda install -y conda-forge::pycuda python -m pip install --upgrade pip wheel python -m pip install nvidia-cudnn-cu12 @@ -128,13 +130,12 @@ python -m pip install -r requirements.txt --no-warn-script-location ### 运行启动器 在Conda环境中执行以下命令 -`python launcher.py` +`python launcher2.py` -### 错误排查 +### 环境错误排查 当运行TensorRT构建或启动器出现错误时,请参考如下可能性: 1. 环境安装有错误(一般运行时缺少库99%的原因都是这个,pip下载并不稳定,各种网络问题都可能导致安装失败),检查源,手动删除`envs`文件夹再试, 对照 [此log](assets/complete_building_log.txt) 为成功案例排查原因。 实在不懂排查请使用整合包。 -2. nvcc编译器没找到,即CudaToolkit安装有误,双击 `00.检查安装CudaToolkits.bat` 来验证 -3. 英伟达显卡但计算架构低于7.5(10系以及之前)不支持TensorRT +2. 英伟达显卡但计算架构低于7.5(10系以及之前)不支持TensorRT ## 输入输出设备 #### SPOUT2 OBS插件输出 @@ -174,7 +175,7 @@ https://www.ifacialmocap.com/download/ #### OpenSeeFace https://github.com/emilianavt/OpenSeeFace/releases -直接下载最新版本的Release包并解压 +直接下载最新版本的Release包并解压,或使用整合包附带的压缩包 之后进入解压目录的Binary文件夹 右键编辑`run.bat`,在倒数第二行运行facetracker的命令后加上`--model 4`,切换到模型4可以wink `facetracker -c %cameraNum% -F %fps% -D %dcaps% -v 3 -P 1 --discard-after 0 --scan-every 0 --no-3d-adapt 1 --max-feature-updates 900 --model 4`(仅供参考) diff --git a/args.py b/args.py index 46dd57c..3a92de0 100644 --- a/args.py +++ b/args.py @@ -64,6 +64,8 @@ if args.cache is not None: args.max_cache_len=convert_to_byte(args.cache)/pow(1024, 3) #In gigabytes else: args.max_cache_len=0 +if args.max_cache_len == 0: + args.use_cacher = False if args.gpu_cache is not None: args.max_gpu_cache_len=convert_to_byte(args.gpu_cache)/pow(1024, 3) #In gigabytes else: diff --git a/ezvtuber-rt b/ezvtuber-rt index 09de205..4ee9e63 160000 --- a/ezvtuber-rt +++ b/ezvtuber-rt @@ -1 +1 @@ -Subproject commit 09de205f3b5b53e984689d78a22b805a2592d18c +Subproject commit 4ee9e63d962bacbc5640194fbe90660e8c19824d diff --git a/launcher2.py b/launcher2.py index 3505854..ea6fac8 100644 --- a/launcher2.py +++ b/launcher2.py @@ -206,7 +206,7 @@ class LauncherPanel(wx.Panel): choices=['Spout2', 'OBS VirtualCam', 'UnityCapture', 'Debug Output'], mapping=[3, 1, 0, 2]) - addOption('device_id', title='GPU Device', desc='选择需要使用的计算设备', choices=['0']) + addOption('device_id', title='GPU Device', desc='选择需要使用的计算设备(默认0)', choices=['0','1','2','3']) addOption('use_tensorrt', title='TensorRT', desc='开启TensorRT后可使用预编译模型\n进一步提升性能(仅NVIDIA显卡支持)', type=1) @@ -388,7 +388,7 @@ class LauncherPanel(wx.Panel): run_args.append(args['vram_cache_size']) if args['interpolation'] is not None: - if not 'off' == args['interpolation']: + if not 'Off' == args['interpolation']: run_args.append('--use_interpolation') if 'half' in args['interpolation']: run_args.append('--interpolation_half')