AmusementClub / vs-mlrt

Efficient CPU/GPU ML Runtimes for VapourSynth (with built-in support for waifu2x, DPIR, RealESRGANv2/v3, Real-CUGAN, RIFE, SCUNet and more!)
GNU General Public License v3.0
273 stars 18 forks source link

RealESRGAN models not working #35

Closed mrtaichi closed 1 year ago

mrtaichi commented 1 year ago

I use the portable version. When using with TRT, among the RealESRGAN models, only animevideov3 works. Though even that does not work if "fp16=True" is set. The other two models animevideo_xsx2 and animevideo_xsx4 also do not work.

Here is the script I used: import vapoursynth as vs core = vs.core from vsmlrt import RealESRGANv2, RealESRGANv2Model, Backend src = core.ffms2.Source(r"D\Test.mkv") rgb = core.resize.Bicubic(src, format=vs.RGBS) flt = RealESRGANv2(rgb, model=RealESRGANv2Model.animevideo_xsx2, backend=Backend.TRT()) res = core.resize.Bicubic(flt, format=src.format.id, matrix_s="709") res.set_output()

Error: [vapoursynth @ 000001acb7162f40] Failed to parse script: Python exception: trtexec execution fails, log has been written to C:\ Traceback (most recent call last): File "src\cython\vapoursynth.pyx", line 2993, in vapoursynth._vpy_evaluate File "src\cython\vapoursynth.pyx", line 2994, in vapoursynth._vpy_evaluate File "RK_S01E05-1m-40s_TRT-RealESR.vpy", line 10, in <module> flt = RealESRGANv2(rgb, model=RealESRGANv2Model.animevideo_xsx2, backend=Backend.TRT())

Everything works with ORT_CUDA though.

WolframRhodium commented 1 year ago

Could you please provide the log?

mrtaichi commented 1 year ago

Hello I have provided two log files here. I have also added the error log part as well. https://mega.nz/folder/ra4VmbJB#vj983tAS1E3BiQOOqzBpKA One for regular TRT error & another for when fp16=True is used with animevideov3 model.

AkarinVS commented 1 year ago

Perhaps you can try executing the command in the first line of the log file in a cmd window and see if there are any other error not included in the log file?

e.g.

D:/Software/Multimedia/Video_Related/Ai_Up/vs-mlrt/vapoursynth_portable_23H1b5p_cpu+cuda/vapoursynth64/plugins\vsmlrt-cuda\trtexec --onnx=D:/Software/Multimedia/Video_Related/Ai_Up/vs-mlrt/vapoursynth_portable_23H1b5p_cpu+cuda/vapoursynth64/plugins\models\RealESRGANv2\RealESRGANv2-animevideo-xsx2.onnx --timingCacheFile=D:/Software/Multimedia/Video_Related/Ai_Up/vs-mlrt/vapoursynth_portable_23H1b5p_cpu+cuda/vapoursynth64/plugins\models\RealESRGANv2\RealESRGANv2-animevideo-xsx2.onnx.1920x1080_workspace128_trt-8501_cudnn_I-fp32_O-fp32_NVIDIA-GeForce-RTX-2060_328a7930.engine.cache --device=0 --saveEngine=D:/Software/Multimedia/Video_Related/Ai_Up/vs-mlrt/vapoursynth_portable_23H1b5p_cpu+cuda/vapoursynth64/plugins\models\RealESRGANv2\RealESRGANv2-animevideo-xsx2.onnx.1920x1080_workspace128_trt-8501_cudnn_I-fp32_O-fp32_NVIDIA-GeForce-RTX-2060_328a7930.engine --memPoolSize=workspace:128 --shapes=input:1x3x1080x1920 --tacticSources=-CUBLAS,-CUBLAS_LT --buildOnly --inputIOFormats=fp32:chw --outputIOFormats=fp32:chw
mrtaichi commented 1 year ago

Hello the log file is uploaded in the folder above with the name "3rd_log.txt".

AkarinVS commented 1 year ago

so trtexec silently exits after prints [I] Finish parsing network model? Are there any other output on the screen?

Please add --verbose to the command line and try again.

mrtaichi commented 1 year ago

Yes, it silently exits. I mean exits to the prompt. the whole window is not closed. the verbose_log file is uploaded.

AkarinVS commented 1 year ago

trtexec generates a path that is way too long for Windows to handle. You need to shorten the path to the portable directory.

D:/Software/Multimedia/Video_Related/Ai_Up/vs-mlrt/vapoursynth_portable_23H1b5p_cpu+cuda/vapoursynth64/plugins\models\RealESRGANv2\RealESRGANv2-animevideo-xsx2.onnx.1920x1080_workspace128_trt-8501_cudnn_I-fp32_O-fp32_NVIDIA-GeForce-RTX-2060_328a7930.engine.cache.lock.

For example, try make it D:/Software/Multimedia/Video_Related/Ai_Up/vs-mlrt/23H1b5p_cuda.

mrtaichi commented 1 year ago

that solved it. on a different note, backend=Backend.TRT() but in case of CUGAN BackendV2 is used. but ESRGAN can't use the v2. does that have an impact on performance or something?

WolframRhodium commented 1 year ago

why ESRGAN can't use the v2?

mrtaichi commented 1 year ago

flt = RealESRGANv2(rgb, model=RealESRGANv2Model.animevideov3, backend=BackendV2.TRT(fp16=True), scale=2) If I use this, it says NameError: name 'BackendV2' is not defined

WolframRhodium commented 1 year ago
from vsmlrt import BackendV2