TensorRT Guide
April 8, 2025 ยท View on GitHub
This guide helps you use TSCUNet with TensorRT for accelerated video upscaling.
Current Limitations:
- Static shapes required, must be multiples of 64 in each dimension
- Input videos must either:
- Be padded to match engine dimensions (e.g., 720x480 โ 768x512)
- Fit exactly to required dimensions
Setup Process
- Set up VapourSynth following pifroggi's guide
- Download and extract
vsmlrt-windows-x64-tensorrt.[version].7zfrom vs-mlrt releases to yourvs-pluginsdirectory - Get the model:
- Download pre-converted ONNX from releases, or
- Convert your own using
convert_to_onnx.py(see script for detailed options)
Usage
-
Build TensorRT engine using
trtexec:FP32:
trtexec --onnx="tscunet_fp32.onnx" --optShapes=input:1x15x512x768 --saveEngine=tscunet_fp32.engine --builderOptimizationLevel=5 --useCudaGraph --tacticSources=+CUDNN,-CUBLAS,-CUBLAS_LTFP16:
trtexec --onnx="tscunet_fp16.onnx" --fp16 --optShapes=input:1x15x512x768 --inputIOFormats=fp16:chw --outputIOFormats=fp16:chw --saveEngine=tscunet_fp16.engine --builderOptimizationLevel=5 --useCudaGraph --tacticSources=+CUDNN,-CUBLAS,-CUBLAS_LT- You'll want to change the shape in the
--optShapes=input:1x15x512x768section depending on the resolution of your input video - Please note that the shape has to be a multiple of 64. So if your input video is 720x540, you'd want to use
--optShapes=input:1x15x512x768
- You'll want to change the shape in the
-
Copy
vapoursynth_script.pyto your VapourSynth directory, then configure it with your video path and engine path -
Open a Command Prompt window (NOT POWERSHELL) in your VapourSynth directory, then run a command like this. Customize the encoder settings as you wish:
vspipe -c y4m ".\vapoursynth_script.vpy" - | ffmpeg -i - -c:v hevc_nvenc -qp 0 -preset p5 -tune lossless "output.mkv"