Skip to content

RuntimeError: Trying to create tensor with negative dimension -1: [-1, 320, -1, -1] if running without Controlnet #1

@ccarmatic

Description

@ccarmatic

Describe the bug
Python 3.10.14, Torch 2.8.0+cu128, SDTurbo
Running Streamdiffusion without Controlnet results in the following error:

File "c:\Users\fdasfasdfasd\Documents\StreamDiffusion.venv\lib\site-packages\streamdiffusion\acceleration\tensorrt\utilities.py", line 303, in allocate_buffers
tensor = torch.empty(tuple(shape),
RuntimeError: Trying to create tensor with negative dimension -1: [-1, 320, -1, -1]

To Reproduce

    stream = StreamDiffusionWrapper(
        model_id_or_path=MODELPATH,
        t_index_list=indexlist,
        width=WIDTH,
        height=HEIGHT,
        warmup=10,
        acceleration='tensorrt',
        mode="img2img",
        cfg_type='self',
        seed=2,
        use_cached_attn=True,
        cache_maxframes= 2,
        cache_interval=1,
        normalize_prompt_weights= False,
        output_type='pt'
    )

Omit use_controlnet= which defaults to False and controlnet_config= which defaults to None
Expected behavior
Streamdiffusion runs with no controlnet

Additional context
in utilities.py , under Engine, method allocate_buffers, there is this

for idx in range(self.engine.num_io_tensors):
            name = self.engine.get_tensor_name(idx)

            if shape_dict and name in shape_dict:
                shape = shape_dict[name]
            else:
                shape = self.engine.get_tensor_shape(name)

from my testing, if shape_dict and name in shape_dict returns True 5 times, before returning False and self.engine.get_tensor_shape(name) runs and returns the -1 values

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions