ComfyUI-Upscaler-Tensorrt icon indicating copy to clipboard operation
ComfyUI-Upscaler-Tensorrt copied to clipboard

readme is unclear (update it with more detail)

Open fractalfantasy opened this issue 1 year ago • 5 comments
trafficstars

Took me a few days to understand how to build the engine, so im putting this here to help other people:

  1. git clone the repo to your custom_nodes directory

  2. navigate command prompt to ComfyUI-Upscaler-Tensorrt directory and install it: pip install -r requirements.txt

  3. download onnx files to this directory: ..\ComfyUI\app\models\tensorrt\upscaler\onnx

  4. run engine builder script from ComfyUI-Upscaler-Tensorrt directory to build the engine. python export_trt.py Enter the path to save the TensorRT engine (e.g ./realesrgan.engine): ..\ComfyUI\app\models\tensorrt\upscaler\4x_foolhardy_Remacri.engine Enter the path to the ONNX model (e.g ./realesrgan.onnx): ..\ComfyUI\app\models\tensorrt\upscaler\onnx\4x_foolhardy_Remacri.onnx

  • do not create a .engine directory/file before you run the script, it will automatically create this file for you. just give it the filepath for the future .engine file , see my example above
  • there should not be quotes '' around the paths

once the engine(s) are built!!

  1. open the node in ComfyUi and place it at the end of your IMAGE chain

right click >> add node >> tensorrt >> Upscale Tensorrt

image
  1. pick your .engine file and run it, it should upscale the image :)

fractalfantasy avatar May 27 '24 23:05 fractalfantasy

Thanks for the detailed guide, I pinned the issue :)

yuvraj108c avatar May 29 '24 09:05 yuvraj108c

On Windows if you are in the directory with the export_trt.py the required way to path is "../../../" not the single ".." fractalfantasy said because, for me at least, I use the venv version (no portable nonsense for me again) and it is two levels deeper and remove the "\app" as that is part of portable version nonsense.

DarkAlchy avatar Jun 11 '24 14:06 DarkAlchy

thank uuuu! this saved me from another hour of bashing head on keyboard 🙏

RONNYKHALIL avatar Jun 16 '24 20:06 RONNYKHALIL

On Windows if you are in the directory with the export_trt.py the required way to path is "../../../" not the single ".." fractalfantasy said because, for me at least, I use the venv version (no portable nonsense for me again) and it is two levels deeper and remove the "\app" as that is part of portable version nonsense.

Would you be able to clarify on this a bit? Wondering if I'm missing something. I'm also on a venv, but it keeps throwing an error saying:

polygraphy.exception.exception.PolygraphyException: Failed to parse ONNX model. Does the model file exist and contain a valid ONNX model?`

I've got my file paths all lined up how I had them working for the other related engine building nodes (depth/pose), but it's still not working.

def export_trt(trt_path=None, onnx_path=None, use_fp16=True):
    if trt_path is None:
        trt_path = input("C:/SD/ComfyUI/ComfyUI/models/tensorrt/upscaler/RealESRGAN_x4.engine")
    if onnx_path is None:
        onnx_path = input("C:/SD/ComfyUI/ComfyUI/models/tensorrt/upscaler/onnx/RealESRGAN_x4.onnx")

Anyone know if I am I missing something here?

wordbrew avatar Jul 20 '24 05:07 wordbrew

On Windows if you are in the directory with the export_trt.py the required way to path is "../../../" not the single ".." fractalfantasy said because, for me at least, I use the venv version (no portable nonsense for me again) and it is two levels deeper and remove the "\app" as that is part of portable version nonsense.

Would you be able to clarify on this a bit? Wondering if I'm missing something. I'm also on a venv, but it keeps throwing an error saying:

polygraphy.exception.exception.PolygraphyException: Failed to parse ONNX model. Does the model file exist and contain a valid ONNX model?`

I've got my file paths all lined up how I had them working for the other related engine building nodes (depth/pose), but it's still not working.

def export_trt(trt_path=None, onnx_path=None, use_fp16=True):
    if trt_path is None:
        trt_path = input("C:/SD/ComfyUI/ComfyUI/models/tensorrt/upscaler/RealESRGAN_x4.engine")
    if onnx_path is None:
        onnx_path = input("C:/SD/ComfyUI/ComfyUI/models/tensorrt/upscaler/onnx/RealESRGAN_x4.onnx")

Anyone know if I am I missing something here?

@wordbrew set the paths directly in the fuction params

e.g

def export_trt(trt_path="C:/SD/ComfyUI/ComfyUI/models/tensorrt/upscaler/RealESRGAN_x4.engine", onnx_path="C:/SD/ComfyUI/ComfyUI/models/tensorrt/upscaler/onnx/RealESRGAN_x4.onnx", use_fp16=True):

yuvraj108c avatar Aug 07 '24 06:08 yuvraj108c

Tensorrt models are now built automatically!

yuvraj108c avatar Mar 04 '25 11:03 yuvraj108c