This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Problems in using RealESRGAN in Hybrid 2022.11.28.1
#11
Seems like caching is broken. -> HolyWu figured out how to fix it working now, send you a new link
Reply
#12
Hello Selur

   I installed the last development version. The cache directory now is working. If is not set the cache is created under ".\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsrealesrgan".
  In some case it could be useful this solution so that it could be possible reuse the cache in the case the file in input is using the same model and has the same resolution, this because the name used for the cash file is providing all the necessary info.
  Unfortunately the last version CRASH. I was unable to understand the reason, I attached the debug file. I was able to use the same script created by using "vsViewer.exe", so the problem should not be related to the script "per se". Please let me know.

Thanks,
Dan


Attached Files
.zip   HybridDebugOutput.zip (Size: 17,97 KB / Downloads: 7)
Reply
#13
Quote: If is not set the cache is created under ..
Argh, I'll adjust Hybrid so it always sets the cache path to the current temp dir.

----

The used script:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
import site
import os
# Adding torch dependencies to PATH
path = site.getsitepackages()[0]+'/torch_dependencies/'
path = path.replace('\\', '/')
os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]
# Loading Plugins
core.std.LoadPlugin(path="D:/Programs/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="D:/Programs/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# source: 'E:\VideoTest\2022-12-17\Anime_DVD_test.mkv'
# current color space: YUV420P8, bit depth: 8, resolution: 720x536, fps: 25, color matrix: 709, yuv luminance scale: limited, scanorder: progressive
# Loading E:\VideoTest\2022-12-17\Anime_DVD_test.mkv using LWLibavSource
clip = core.lsmas.LWLibavSource(source="E:/VideoTest/2022-12-17/Anime_DVD_test.mkv", format="YUV420P8", stream_index=0, cache=0, fpsnum=25, prefer_hw=0)
# Setting color matrix to 709.
clip = core.std.SetFrameProps(clip, _Matrix=1)
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=1)
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0)
from vsrealesrgan import RealESRGAN
# adjusting color space from YUV420P8 to RGBH for VsRealESRGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
# resizing using RealESRGAN
clip = RealESRGAN(clip=clip, model=3, device_index=0, trt=True, trt_cache_path=r"E:\VideoTest\2022-12-17", num_streams=2) # 2880x2144
# resizing 2880x2144 to 1280x952
# adjusting resizing
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, range_s="limited")
clip = core.fmtc.resample(clip=clip, w=1280, h=952, kernel="lanczos", interlaced=False, interlacedd=False)
# adjusting output color from: RGBS to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
# set output frame rate to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
seems fine to me.
Encoding call:
"D:\Programs\Hybrid\64bit\Vapoursynth\vspipe.exe" "E:\VideoTest\2022-12-17\encodingTempSynthSkript_2022-12-17@19_51_26_2510.vpy" - -c y4m | "D:\Programs\Hybrid\64bit\x265.exe" --preset fast --input - --output-depth 10 --y4m --profile main10 --b-adapt 2 --crf 20.00 --sbrc --deblock=-1:-1 --psnr --ssim --range limited --colormatrix bt709 --output "E:\VideoTest\2022-12-17\2022-12-17@19_51_26_2510_03.265"
crashes with:
x265 [error]: unable to open input file <->
No clue why it would crash since you wrote that the script works fine. (assuming you are not running out if vram)

Cu Selur
Reply
#14
As I wrote I was able to use the script using "vsViewer.exe" located in Hybrid.
This the log
2022-12-17 20:56:43.069 
Ready to encode script E:/VideoTest/2022-12-17/encodingTempSynthSkript_2022-12-17@19_51_26_2510.vpy
2022-12-17 20:57:44.242
 Command line:
"D:/Program Files/VapourSynth64Portable/bin/x265.exe" - --y4m --crf 20 --preset fast --output-depth 10 -o "E:/VideoTest/2022-12-17\x265_10bit_video.hevc"

                        Checking the encoder sanity.
x265 [error]: unable to open input file 

                        Encoder seems sane. Starting.
Encoder started. Beginning encoding.
2022-12-17 20:57:44.263
 Y4M header: YUV4MPEG2 C420p10 W1280 H952 F25:1 Ip A0:0 XLENGTH=4508
2022-12-17 20:57:44.297
 y4m [info]: 1280x952 fps 25/1 i420p10 unknown frame count
                        raw [info]: output file: E:\VideoTest\2022-12-17\x265_10bit_video.hevc
                        x265 [info]: HEVC encoder version 3.4+27-g5163c32d7
                        x265 [info]: build info [Windows][GCC 10.2.0][64 bit] 10bit
                        x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 
x265 [info]: Main 10 profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 20 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 4 / wpp(15 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut / bias : 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 15 / 4 / 0
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 0
x265 [info]: References / ref-limit cu / depth : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-20.0 / 0.60
x265 [info]: tools: rd=2 psy-rd=2.00 rskip mode=1 signhide tmvp fast-intra
x265 [info]: tools: strong-intra-smoothing lslices=6 deblock sao
2022-12-17 20:57:50.299
 1 frames: 0.17 fps, 3062.60 kb/s
3


 I remember that this problem already happen in the past, I have to search in my old posts.

I reported a similar problem in this post: https://forum.selur.net/thread-2330-post...l#pid15154
Reply
#15
Okay,... if you find something let me know.
Atm. I'm trying to figure out how to run DPIR and RealESRGAN inside one script.
Reply
#16
It seems that the problem is related to "Tensor RT". If I disable it so that "Tensor" is not used. Hybrid is able to encode the movie. I think that we are in the same condition where the "Tensor" dll are not loaded as in my old post. I think that they are in my path, because if I perform the encoding using "vsViewer" there are not problems in using "Tensor RT". I remember that to solve this issue you created a dedicated folder "/torch_dependencies/", maybe is missing some dll...

I commented the following lines in the script

# Adding torch dependencies to PATH

# path = site.getsitepackages()[0]+'/torch_dependencies/'

# path = path.replace('\\', '/')

# os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]

 and I was still able to encode the movie. This means that is using the "Tensor" DLL located in some place on my PC.

In my path there are the following directory

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\libnvvp;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;
C:\Program Files\NVIDIA Corporation\Nsight Compute 2021.2.2;

I copied all the files included in "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin" in "/torch_dependencies/" and removed from the path "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin". vsViewer is able to encode only if in the script there are the following lines

# Adding torch dependencies to PATH

# path = site.getsitepackages()[0]+'/torch_dependencies/'

# path = path.replace('\\', '/')

# os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]

 Also the preview in Hybrid is working. But the encoding task still CRASH. It seems that the environment used to run the preview in Hybrid is different from the environment used to run the encoding task.

I run in command window, the following command

"D:\Programs\Hybrid\64bit\Vapoursynth\vspipe.exe" "E:\VideoTest\2022-12-17\encodingTempSynthSkript_2022-12-17@19_51_26_2510.vpy" - -c y4m > .\video.raw

and was written a huge file. The begin of the file contains the following rows:

[12/17/2022-22:14:55] [TRT] [W] CUDA lazy loading is not enabled. Enabling it can significantly reduce device memory usage. See `CUDA_MODULE_LOADING` in https://docs.nvidia.com/cuda/cuda-c-prog...l#env-vars
[12/17/2022-22:14:55] [TRT] [W] CUDA lazy loading is not enabled. Enabling it can significantly reduce device memory usage. See `CUDA_MODULE_LOADING` in https://docs.nvidia.com/cuda/cuda-c-prog...l#env-vars
YUV4MPEG2 C420p10 W1280 H952 F25:1 Ip A0:0 XLENGTH=4508
FRAME
Reply
#17
If in the script I change the call in this way:

clip = RealESRGAN(clip=clip, model=3, device_index=0)

so that is not used "Tensor RT", the begin of the file "video.raw" contains the follow lines:

YUV4MPEG2 C420p10 W1280 H952 F25:1 Ip A0:0 XLENGTH=4508

FRAME

So I think that the warning lines that are reported in the case "Tensor RT" is enabled are the reasons for the encoding CRASH reported by Hybrid. In some way vsViewer is able to manage this situation, but not x265.exe.

PROBLEM SOLVED

If I set the environment variable: CUDA_MODULE_LOADING=LAZY, the encoding works. I need to do more tests but I think that in this way the problem is solved.

I performed a reboot of PC and launched Hybrid. And now Hybrid is able to encode with RealESRGAN and "Tensor RT" enabled. Smile Smile Smile
Reply
#18
Quote:CUDA_MODULE_LOADING=LAZY
Then you are running out of VRAM. Main thing 'CUDA_MODULE_LOADING=LAZY' does is lowering the VRAM usage.
Btw. I'm working on support for AnimeSR, but struggling a bit atm. (https://github.com/HolyWu/vs-animesr/issues/3)
But there one get's the following info:
Quote:[TRT] [W] CUDA lazy loading is not enabled. Enabling it can significantly reduce device memory usage. See `CUDA_MODULE_LOADING` in https://docs.nvidia.com/cuda/cuda-c-prog...l#env-vars

Quote: I performed a reboot of PC and launched Hybrid. And now Hybrid is able to encode with RealESRGAN and "Tensor RT" enabled.
Wonderful. My guess is that the VRAM wasn't properly cleared. (happens with HolyWus filters often, that only closing vsviewer helps)

Cu Selur
Reply
#19
Send you links to an updated dev and torchAddon which adds support for AnimeSR. Smile

Cu Selur
Reply
#20
Hello Selur,

   AnimeSR is working perfectly. With "Tensor RT" enabled and using FP16 it is possible to obtain an encoding speed of about 17fps.
   While without "Tensor RT" it is possible to obtain a significant speed increase by enabling "Fusion".
   
   The new versions provided HolyWu with support of "Torch" have in common that the time for producing the cache file for using "Tensor RT" has been reduced significantly. Previously I had to wait till 40min now the max wait time is about 6min.

Thanks!  Smile
Dan
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)