HolyWu/vs-rife

Cannot import name 'SourceIR' from 'torch_tensorrt.fx.converters.converter_utils'

Selur opened this issue · 1 comments

  • created 'Vapoursynth'-folder
  • downloaded 'Windows embeddable package (64-bit)' from https://www.python.org/downloads/release/python-3123/
  • extracted it into the 'Vapoursynth'-folder
  • downloaded 'VapourSynth64-Portable-R68' from https://github.com/vapoursynth/vapoursynth/releases
  • extracted it into the 'Vapoursynth'-folder
  • finished Vapoursynth portable installation:
    • adjusted python312._pth by adding:
    Scripts
    Lib\site-packages
    
    • installed pip:
    • python -m pip install wheel\VapourSynth-68-cp312-cp312-win_amd64.whl
  • installed torch dependencies:
    • python -m pip install wheel
      • install TensorRT FX
      • python -m pip install torch_tensorrt_fx_only
    • install Pytorch 2.4 dev (uninstalled torch 2.3.0 and installed Pytorch 2.4.0.dev20240519+cu121)
      • python -m pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu121
    • install TensorRT
    • python -m pip install https://github.com/HolyWu/vs-dpir/releases/download/v4.1.0/torch_tensorrt-2.4.0.dev20240518+cu121-cp312-cp312-win_amd64.whl
    • python -m pip install tensorrt==10.0.1 tensorrt-cu12_bindings==10.0.1 tensorrt-cu12_libs==10.0.1 --extra-index-url https://pypi.nvidia.com
  • installed 'vsrife':
    • python -m pip install -U vsrife
    • python -m vsrife
      Calling it with:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# loading plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
# Import scripts
import ChangeFPS
import validate
# Source: 'G:\TestClips&Co\files\test.avi'
# Current color space: YUV420P8, bit depth: 8, resolution: 640x352, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading G:\TestClips&Co\files\test.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="G:/TestClips&Co/files/test.avi", format="YUV420P8", stream_index=0, cache=0, fpsnum=25, prefer_hw=0)
frame = clip.get_frame(0)
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip=clip, _Matrix=5)
# setting color transfer (170), if it is not set.
if validate.transferIsInvalid(clip):
  clip = core.std.SetFrameProps(clip=clip, _Transfer=6)
# setting color primaries info (to 470), if it is not set.
if validate.primariesIsInvalid(clip):
  clip = core.std.SetFrameProps(clip=clip, _Primaries=5)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
# making sure frame rate is set to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=0) # progressive
original = clip
from vsrife import rife
# adjusting color space from YUV420P8 to RGBS for vsTorchRIFE
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
# adjusting frame count&rate with RIFE (torch)
clip = rife(clip, sc_threshold=0.150) # new fps: 50
# adjusting frame count by adding duplicate frames
original = ChangeFPS.ChangeFPS(clip=original,target_fps_num=50,target_fps_den=1)
# adjusting output color from: YUV420P8 to YUV420P10 for NVEncModel
original = core.resize.Bicubic(clip=original, format=vs.YUV420P10, range_s="limited")
# adjusting output color from: RGBS to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
original = core.text.Text(clip=original,text="Original",scale=1,alignment=7)
clip = core.text.Text(clip=clip,text="Filtered",scale=1,alignment=7)
stacked = core.std.StackHorizontal([original,clip])
# set output frame rate to 50fps (progressive)
stacked = core.std.AssumeFPS(clip=stacked, fpsnum=50, fpsden=1)
# output
stacked.set_output()

results in:

Python exception: cannot import name 'SourceIR' from 'torch_tensorrt.fx.converters.converter_utils' (F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\fx\converters\converter_utils.py)

Traceback (most recent call last):
File "src\\cython\\vapoursynth.pyx", line 3365, in vapoursynth._vpy_evaluate
File "src\\cython\\vapoursynth.pyx", line 3366, in vapoursynth._vpy_evaluate
File "J:\tmp\tempPreviewVapoursynthFile20_19_40_586.vpy", line 40, in 
clip = rife(clip, sc_threshold=0.150) # new fps: 50
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsrife\__init__.py", line 199, in rife
from .IFNet_HDv3_v4_15_lite import IFNet
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsrife\IFNet_HDv3_v4_15_lite.py", line 4, in 
from .interpolate import interpolate
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsrife\interpolate.py", line 11, in 
from torch_tensorrt.dynamo._SourceIR import SourceIR
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\__init__.py", line 133, in 
from torch_tensorrt.dynamo import backend # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\dynamo\__init__.py", line 10, in 
from ._compiler import compile, convert_module_to_trt_engine
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\dynamo\_compiler.py", line 14, in 
from torch_tensorrt.dynamo import _defaults, partitioning
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\dynamo\partitioning\__init__.py", line 1, in 
from ._adjacency_partitioner import partition as fast_partition
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\dynamo\partitioning\_adjacency_partitioner.py", line 20, in 
from torch_tensorrt.dynamo.conversion._ConverterRegistry import (
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\dynamo\conversion\__init__.py", line 1, in 
from . import aten_ops_converters, ops_evaluators, prims_ops_converters
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\dynamo\conversion\aten_ops_converters.py", line 11, in 
from torch_tensorrt.dynamo.conversion import impl
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\dynamo\conversion\impl\__init__.py", line 1, in 
from torch_tensorrt.fx.converters.impl import convolution
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\fx\converters\impl\convolution.py", line 9, in 
from torch_tensorrt.fx.converters.converter_utils import (
ImportError: cannot import name 'SourceIR' from 'torch_tensorrt.fx.converters.converter_utils' (F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch_tensorrt\fx\converters\converter_utils.py)

calling python -m pip list
shows:

Package                  Version
------------------------ ------------------------
annotated-types          0.7.0
antlr4-python3-runtime   4.9.3
beautifulsoup4           4.12.3
blis                     0.7.11
Bottleneck               1.3.8
catalogue                2.0.10
certifi                  2024.2.2
charset-normalizer       3.3.2
click                    8.1.7
cloudpathlib             0.16.0
colorama                 0.4.6
confection               0.1.4
contourpy                1.2.1
cupy-cuda11x             13.1.0
cycler                   0.12.1
cymem                    2.0.8
einops                   0.8.0
fastai                   1.0.60
fastprogress             1.0.3
fastrlock                0.8.2
filelock                 3.14.0
fonttools                4.52.1
fsspec                   2024.5.0
huggingface-hub          0.23.1
idna                     3.7
imageio                  2.34.1
intel-openmp             2021.4.0
Jinja2                   3.1.4
kiwisolver               1.4.5
kornia                   0.7.2
kornia_rs                0.1.3
langcodes                3.4.0
language_data            1.2.0
lazy_loader              0.4
llvmlite                 0.42.0
marisa-trie              1.1.1
markdown-it-py           3.0.0
MarkupSafe               2.1.5
matplotlib               3.9.0
mdurl                    0.1.2
mkl                      2021.4.0
mpmath                   1.3.0
murmurhash               1.0.10
networkx                 3.3
numba                    0.59.1
numexpr                  2.10.0
numpy                    1.26.4
nvidia-cuda-runtime-cu12 12.5.39
nvidia-ml-py3            7.352.0
omegaconf                2.3.0
opencv-contrib-python    4.9.0.80
opencv-python            4.9.0.80
packaging                24.0
pandas                   2.2.2
Pillow                   10.1.0
pip                      24.0
preshed                  3.0.9
pydantic                 2.7.1
pydantic_core            2.18.2
Pygments                 2.18.0
pyparsing                3.1.2
python-dateutil          2.9.0.post0
pytz                     2024.1
PyYAML                   6.0.1
requests                 2.32.2
rich                     13.7.1
safetensors              0.4.3
scikit-image             0.23.2
scipy                    1.13.1
setuptools               70.0.0
six                      1.16.0
smart-open               6.4.0
soupsieve                2.5
spacy                    3.7.4
spacy-legacy             3.0.12
spacy-loggers            1.0.5
srsly                    2.4.8
stgpytools               1.0.5
sympy                    1.12
tbb                      2021.12.0
tensorrt                 10.0.1
tensorrt-cu12            10.0.1
tensorrt-cu12_bindings   10.0.1
tensorrt-cu12_libs       10.0.1
thinc                    8.2.3
tifffile                 2024.5.22
timm                     1.0.3
torch                    2.4.0.dev20240523+cu121
torch_tensorrt           2.4.0.dev20240518+cu121
torch-tensorrt-fx-only   1.4.0.dev0
torchvision              0.19.0.dev20240525+cu121
tqdm                     4.66.4
typer                    0.9.4
typing_extensions        4.12.0
tzdata                   2024.1
urllib3                  2.2.1
VapourSynth              68
vsanimesr                1.0.0
vscodeformer             1.0.1
vsddcolor                1.0.1
vsdeoldify               3.5.3
vsdpir                   4.1.0
vsgan                    1.6.4
vsgmfss_fortuna          1.0.0
vsgrlir                  1.1.1
vshinet                  1.0.0
vsrealesrgan             4.0.0
vsrife                   5.0.0
vsscunet                 1.0.0
vsswinir                 2.0.0
vstools                  3.1.0
vsutil                   0.8.0
wasabi                   1.1.2
weasel                   0.3.4
wheel                    0.43.0

Any idea what I'm missing / doing wrong?

Okay, problem is 'torch-tensorrt-fx-only 1.4.0.dev0', needs to be 2.2 or higher