What is USE_TENSORRT flag used for?

username: Rich_Tarquini
cooked: <p>I’ve built Pytorch from source for Jetson Xavier successfully, and I am now interested in accelerating inference. What does the USE_TENSORRT flag accomplish? Seems like without this flag I could convert my model to ONNX, build the engine and call the NVinfer API directly?</p>
<p>Thanks,<br>
Rich</p>

username: AntonB
cooked: <p><strong>AFAIK:</strong><br>
Hi, when I wanted to compile Pytorch I checked for this flag. AFAIK it enables your Pytorch to use NVIDIA TensorRT library.</p>
<p>Hopefully, any source building works even with e.g. 3.5 capability value in TORCH_ARCH with USE_TENSORRT set.<br>
<strong>Quoting TensorRT site:</strong><br>
“<em>You can import trained models from every deep learning framework into TensorRT. After applying optimizations, TensorRT selects platform specific kernels to maximize performance on Tesla GPUs in the data center, Jetson embedded platforms, and NVIDIA DRIVE autonomous driving platforms.</em><br>
<em>With TensorRT developers can focus on creating novel AI-powered applications rather than performance tuning for inference deployment.</em>”</p>
<p>CCMake Hint:<br>
<img src="https://discuss.pytorch.org/uploads/default/original/3X/3/3/3330e054e995ac734999131b2e2ab14e086f60ed.png" alt="obrázok" data-base62-sha1="7iR4dhXSPBAJqFRS01licG6Rjpr" width="447" height="42"></p>
<p><strong>Supported HW (Cuda Capability &gt; 5):</strong></p><aside class="onebox allowlistedgeneric" data-onebox-src="https://docs.nvidia.com/deeplearning/tensorrt/support-matrix/index.html#hardware-precision-matrix">
  <header class="source">

      <a href="https://docs.nvidia.com/deeplearning/tensorrt/support-matrix/index.html#hardware-precision-matrix" target="_blank" rel="noopener nofollow ugc">docs.nvidia.com</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://docs.nvidia.com/deeplearning/tensorrt/support-matrix/index.html#hardware-precision-matrix" target="_blank" rel="noopener nofollow ugc">Support Matrix :: NVIDIA Deep Learning TensorRT Documentation</a></h3>

  <p>These support matrices provide a look into the supported platforms, features, and hardware capabilities of the NVIDIA TensorRT 8.6.1 APIs, parsers, and layers.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


username: rafale77
cooked: <p>Anyone got to the bottom of this? I have been trying to make my pytorch models infer with tensorRT but it’s been pretty painful. The ONNX route kind of works but is not ideal. Then there are torch2trt and TRTtorch which are beta/alpha projects from nVidia. Is pytorch working to support a nvinfer/TensorRT backend?</p>

username: seungjun
cooked: <p><a class="mention" href="/u/rafale77">@rafale77</a><br>
You may want to check out <a href="https://docs.nvidia.com/deeplearning/tensorrt/pytorch-quantization-toolkit/docs/index.html" rel="noopener nofollow ugc">pytorch-quantization</a> maintained by NVIDIA.</p>
<p>According to the documentation they support post-training quantization and quantized fine-tuning.</p>

username: Raj_Bhattacharjea
cooked: <p>The USE_TENSORRT flag probably does many things in the build, but at least one of the things it does is try to build the onnx-tensorrt package from github. The thing is though, the submodule pointer in the pytorch repo still points to a 2019 tag/commit from the onnx-tensorrt repo, when there have been several releases since then. That commit builds against a rather old version of TensorRT, I think pre 7.0.x releases, so there is no way onnx-tensorrt builds in the pytorch tree against any reasonably new TensorRT API / version. This leads me to conclude that the USE_TENSORRT flag is not supported, because if it were, the pytorch maintainers would at least update the submodule pointer and document what version of TensorRT to build against. My guess is they started down some route of making a TRT inference backend for pytorch but abandoned it and haven’t cleaned up the repo or cmake/setup.py options.</p>