votes up 6

Incompatible TensorRT versions

Package:
Exception Class:
RuntimeError

Raise code

tf_logging.error(
        "Loaded TensorRT %s but linked TensorFlow against TensorRT %s. " %
        (".".join(str(x) for x in loaded_version), ".".join(
            str(x) for x in linked_version)) +
        "TensorRT does not support forward compatibility. " +
        "It is also required to use the same major version of TensorRT " +
        "during compilation and runtime.")
    raise RuntimeError("Incompatible TensorRT versions")
  if loaded_version[0] > linked_version[0]:
    tf_logging.error(
        "Loaded TensorRT %s but linked TensorFlow against TensorRT %s. " %
        (".".join(str(x) for x in loaded_version), ".".join(
            str(x) for x in linked_version)) +
        "It is required to use the same major version " +
        "of TensorRT during compilation and runtime.")

Ways to fix

votes up 1 votes down

TensorRT is a high-performance neural network inference optimizer and runtime engine for production deployment. TensorRT optimizes the network by combining layers and optimizing kernel selection for improved latency, throughput, power efficiency, and memory consumption. Check here

As you can see in the error condition block, it checks the version loaded and linked.

if loaded_version < linked_version:
  tf_logging.error(
      "Loaded TensorRT %s but linked TensorFlow against TensorRT %s. " %
      (".".join(str(x) for x in loaded_version), ".".join(
          str(x) for x in linked_version)) +
      "TensorRT does not support forward compatibility. " +
      "It is also required to use the same major version of TensorRT " +
      "during compilation and runtime.")
  raise RuntimeError("Incompatible TensorRT versions")

Loaded means TensorRT's version

Linked means TensorFlow's version

_check_trt_version_compatibility() function is used when TrtGraphConverter initial method calling.

from tensorflow.python.compiler import tensorrt  as trt

converter = trt.TrtGraphConverter(
    input_saved_model_dir="my_dir",
    precision_mode=trt.TrtPrecisionMode.FP16)
converted_graph_def = converter.convert()
converter.save(output_saved_model_dir)

So, when a version of TensorRT younger (less) than the TensorFlow version an error will pop.

Note 1: TensorRT is not supported Windows Platform.

Note 2: TensorFlow 2.0.0 is required.

Jul 10, 2021 anonim answer
anonim 13.0k

Add a possible fix

Please authorize to post fix