• Stars
    star
    282
  • Rank 141,690 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created 12 months ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

TensorRT support for webui

Adds the ability to convert loaded model's Unet module into TensortRT. Requires version least after commit 339b5315 (currently, it's the dev branch after 2023-05-27). Only tested to work on Windows.

Loras are baked in into the converted model. Hypernetwork support is not tested. Controlnet is not supported. Textual inversion works normally.

NVIDIA is also working on releaseing their version of TensorRT for webui, which might be more performant, but they can't release it yet.

There seems to be support for quickly replacing weight of a TensorRT engine without rebuilding it, and this extension does not offer this option yet.

How to install

Apart from installing the extension normally, you also need to download zip with TensorRT from NVIDIA.

You need to choose the same version of CUDA as python's torch library is using. For torch 2.0.1 it is CUDA 11.8.

Extract the zip into extension directory, so that TensorRT-8.6.1.6 (or similarly named dir) exists in the same place as scripts directory and trt_path.py file. Restart webui afterwards.

You don't need to install CUDA separately.

How to use

  1. Slect the model you want to optimize and make a picture with it, including needed loras and hypernetworks.
  2. Go to a TensorRT tab that appears if the extension loads properly.
  3. In Convert to ONNX tab, press Convert Unet to ONNX.
    • This takes a short while.
    • After the conversion has finished, you will find an .onnx file with model in models/Unet-onnx directory.
  4. In Convert ONNX to TensorRT tab, configure the necessary parameters (including writing full path to onnx model) and press Convert ONNX to TensorRT.
    • This takes very long - from 15 minues to an hour.
    • This takes up a lot of VRAM: you might want to press "Show command for conversion" and run the command yourself after shutting down webui.
    • After the conversion has finished, you will find a .trt file with model in models/Unet-trt directory.
  5. In settings, in Stable Diffusion page, use SD Unet option to select newly generated TensorRT model.
  6. Generate pictures.

Stable Diffusion 2.0 support

Stable diffusion 2.0 conversion should fail for both ONNX and TensorRT because of incompatible shapes, but you may be able to rememdy this by chaning instances of 768 to 1024 in the code.

More Repositories

1

stable-diffusion-webui

Stable Diffusion web UI
Python
130,383
star
2

stable-diffusion-webui-feature-showcase

Feature showcase for stable-diffusion-webui
920
star
3

stable-diffusion-webui-rembg

Removes backgrounds from pictures. Extension for webui.
Python
835
star
4

stable-diffusion-webui-pixelization

stable-diffusion-webui-pixelization
Python
470
star
5

stable-diffusion-webui-extensions

Extension index for stable-diffusion-webui
410
star
6

stable-diffusion-webui-promptgen

stable-diffusion-webui-promptgen
Python
386
star
7

stable-diffusion-webui-aesthetic-gradients

Aesthetic gradients extension for web ui
Python
384
star
8

stable-diffusion-webui-wildcards

Wildcards
Python
353
star
9

stable-diffusion-webui-tokenizer

An extension for stable-diffusion-webui that adds a tab that lets you preview how CLIP model would tokenize your text.
Python
119
star
10

TorchDeepDanbooru

Pure pytorch implementation of DeepDanbooru
Python
100
star
11

stable-diffusion-webui-nsfw-censor

stable-diffusion-webui-nsfw-censor
Python
85
star
12

4chan-captcha-solver

4chan captcha solver userscript
81
star
13

3ds-shell

3DS Windows Explorer extension
C++
21
star
14

stable-diffusion-webui-old-localizations

CSS
17
star
15

KoikatsuMods

Koikatsu Mods
C#
14
star
16

Autocleaner

C#
11
star
17

GradientHair

Gradient Hair
C#
10
star
18

RecipeIcons

Icons for Rimworld context menus
C#
9
star
19

StartupImpact

Startup Impact
C#
9
star
20

WhiteOnly

White Only
C#
6
star
21

BionicIcons

Bionic Icons
C#
5
star
22

Rimlaser

A mod for Rimworld game
C#
4
star
23

HighQualityTextures

High Quality Textures
C#
4
star
24

Radiology

Radiology
C#
4
star
25

Autolinks

Rimworld mod. Automatically adds hyperlinks to descriptions.
C#
4
star
26

IntoTheBreachLua

Lua proxy library for Into The Breach game
C
4
star
27

HairDye

Hair Dye
C#
4
star
28

Gunplay

C#
4
star
29

tf-palette

Tesnorflow color quantization
Python
2
star
30

randdraw

Draws pictures using random shapes
C++
2
star
31

TraderShips

C#
2
star
32

jslife

Javascript game of life
JavaScript
2
star
33

PeacefulProtests

Rimworld mod: PeacefulProtests
C#
1
star