Skip to content

Problem when using Citrinet example notebook #1573

Closed
@hamjam

Description

@hamjam

I have similar problem with #763 when trying to adopt Citrinet-Example.ipynb.
My model is a fine-tuned Citrinet512 from NeMo.
By the way, my pytorch_tensorrt version is 1.3.0.
Here is my code:

import torch
import torch.nn as nn
import torch_tensorrt as torchtrt
import argparse

precisions = [torch.float, torch.half]
batch_sizes = [1,8,32,128]
model = torch.jit.load(model_path+f"{variant}.ts")
model.eval()
for precision in precisions:
    for batch_size in batch_sizes:
        compile_settings = {
            "inputs": [torchtrt.Input(shape=[batch_size, 80, 1488],  dtype=torch.int), torchtrt.Input(shape=[1, batch_size],  dtype=torch.int)],
            "enabled_precisions": {precision},
            "workspace_size": 2000000000,
            "truncate_long_and_double": True,
        }
        print(f"Generating Torchscript-TensorRT module for batchsize {batch_size} precision {precision}")
        trt_ts_module = torchtrt.compile(model, **compile_settings)
        torch.jit.save(trt_ts_module, f"{variant}_bs{batch_size}_{precision}.torch-tensorrt")

Output:

RuntimeError                              Traceback (most recent call last)
Input In [6], in <module>
    14 compile_settings = {
    15     "inputs": [torchtrt.Input(shape=[batch_size, 80, 1488],  dtype=torch.int), torchtrt.Input(shape=[1, batch_size],  dtype=torch.int)],
    16     "enabled_precisions": {precision},
    17     "workspace_size": 2000000000,
    18     "truncate_long_and_double": True,
    19 }
    20 print(f"Generating Torchscript-TensorRT module for batchsize {batch_size} precision {precision}")
---> 21 trt_ts_module = torchtrt.compile(model, **compile_settings)
    22 torch.jit.save(trt_ts_module, f"{variant}_bs{batch_size}_{precision}.torch-tensorrt")

File ~/nvidia-nemo-asr-training/venv/lib/python3.9/site-packages/torch_tensorrt/_compile.py:125, in compile(module, ir, inputs, enabled_precisions, **kwargs)
   120         logging.log(
   121             logging.Level.Info,
   122             "Module was provided as a torch.nn.Module, trying to script the module with torch.jit.script. In the event of a failure please preconvert your module to TorchScript",
   123         )
   124         ts_mod = torch.jit.script(module)
--> 125     return torch_tensorrt.ts.compile(
   126         ts_mod, inputs=inputs, enabled_precisions=enabled_precisions, **kwargs
   127     )
   128 elif target_ir == _IRType.fx:
   129     if (
   130         torch.float16 in enabled_precisions
   131         or torch_tensorrt.dtype.half in enabled_precisions
   132     ):

File ~/nvidia-nemo-asr-training/venv/lib/python3.9/site-packages/torch_tensorrt/ts/_compiler.py:136, in compile(module, inputs, input_signature, device, disable_tf32, sparse_weights, enabled_precisions, refit, debug, capability, num_avg_timing_iters, workspace_size, dla_sram_size, dla_local_dram_size, dla_global_dram_size, calibrator, truncate_long_and_double, require_full_compilation, min_block_size, torch_executed_ops, torch_executed_modules)
   110     raise ValueError(
   111         f"require_full_compilation is enabled however the list of modules and ops to run in torch is not empty. Found: torch_executed_ops: {torch_executed_ops}, torch_executed_modules: {torch_executed_modules}"
   112     )
   114 spec = {
   115     "inputs": inputs,
   116     "input_signature": input_signature,
  (...)
   133     },
   134 }
--> 136 compiled_cpp_mod = _C.compile_graph(module._c, _parse_compile_spec(spec))
   137 compiled_module = torch.jit._recursive.wrap_cpp_module(compiled_cpp_mod)
   138 return compiled_module

RuntimeError: [Error thrown at core/conversion/converters/impl/conv_deconv.cpp:129] Expected orig_dims.nbDims > 2 to be true but got false
Unable to create convolution layer from node: %18096 : Tensor = aten::_convolution(%18093, %33, %32, %34, %35, %34, %18094, %18095, %30, %18094, %18094, %18094, %18094)

Originally posted by @hamjam in #763 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions