6
6
from typing import Any , Callable , Dict , List , Optional , Sequence , Tuple , Union , overload
7
7
8
8
import numpy as np
9
- import tensorrt as trt
10
9
import torch
11
10
import torch_tensorrt .dynamo .conversion .impl as impl
12
11
from torch .fx .node import Argument , Target
20
19
DynamoConverterImplSignature ,
21
20
)
22
21
22
+ import tensorrt as trt
23
+
23
24
from ..types import Shape , TRTDataType , TRTLayer , TRTTensor
24
25
25
26
_LOGGER : logging .Logger = logging .getLogger (__name__ )
@@ -931,33 +932,28 @@ def load_tensorrt_llm() -> bool:
931
932
bool: True if the plugin was successfully loaded and initialized, False otherwise.
932
933
"""
933
934
try :
934
- import tensorrt_llm as trt_llm
935
+ import tensorrt_llm as trt_llm # noqa: F401
935
936
936
- _LOGGER .info ("TensorRT_LLM successfully imported. " )
937
+ _LOGGER .info ("TensorRT-LLM successfully imported" )
937
938
return True
938
939
except (ImportError , AssertionError ) as e_import_error :
939
- _LOGGER .warning (
940
- "TensorRT_LLM is not installed. Please install TensorRT_LLM or set TRTLLM_PLUGINS_PATH" ,
941
- exc_info = e_import_error ,
942
- )
943
-
944
940
# Check for environment variable for the plugin library path
945
941
plugin_lib_path = os .environ .get ("TRTLLM_PLUGINS_PATH" )
946
942
if not plugin_lib_path :
947
943
_LOGGER .warning (
948
- "Please specify a valid path for TRTLLM_PLUGINS_PATH libnvinfer_plugin_tensorrt_llm.so when using distributed examples in examples/distributed_inference."
944
+ "TensorRT-LLM is not installed. Please install TensorRT-LLM or set TRTLLM_PLUGINS_PATH to the directory containing libnvinfer_plugin_tensorrt_llm.so to use converters for torch.distributed ops" ,
949
945
)
950
946
return False
951
947
952
- _LOGGER .info (f"Plugin lib path found: { plugin_lib_path } " )
948
+ _LOGGER .info (f"TensorRT-LLM Plugin lib path found: { plugin_lib_path } " )
953
949
try :
954
950
# Load the shared library
955
951
handle = ctypes .CDLL (plugin_lib_path )
956
952
_LOGGER .info (f"Successfully loaded plugin library: { plugin_lib_path } " )
957
953
except OSError as e_os_error :
958
954
_LOGGER .error (
959
- f"Failed to load the shared library at { plugin_lib_path } . "
960
- f"Ensure the path is correct and the library is compatible. " ,
955
+ f"Failed to load libnvinfer_plugin_tensorrt_llm.so from { plugin_lib_path } "
956
+ f"Ensure the path is correct and the library is compatible" ,
961
957
exc_info = e_os_error ,
962
958
)
963
959
return False
@@ -968,7 +964,7 @@ def load_tensorrt_llm() -> bool:
968
964
handle .initTrtLlmPlugins .restype = ctypes .c_bool
969
965
except AttributeError as e_plugin_unavailable :
970
966
_LOGGER .warning (
971
- "TensorRT-LLM Plugin initialization function is unavailable. " ,
967
+ "Unable to initialize the TensorRT-LLM plugin library " ,
972
968
exc_info = e_plugin_unavailable ,
973
969
)
974
970
return False
@@ -977,14 +973,14 @@ def load_tensorrt_llm() -> bool:
977
973
# Initialize the plugin
978
974
TRT_LLM_PLUGIN_NAMESPACE = "tensorrt_llm"
979
975
if handle .initTrtLlmPlugins (None , TRT_LLM_PLUGIN_NAMESPACE .encode ("utf-8" )):
980
- _LOGGER .info ("TensorRT-LLM Plugin successfully initialized. " )
976
+ _LOGGER .info ("TensorRT-LLM plugin successfully initialized" )
981
977
return True
982
978
else :
983
- _LOGGER .warning ("TensorRT-LLM Plugin initialization failed. " )
979
+ _LOGGER .warning ("TensorRT-LLM plugin library failed in initialization " )
984
980
return False
985
981
except Exception as e_initialization_error :
986
982
_LOGGER .warning (
987
- "Exception occurred during TensorRT-LLM plugin initialization. " ,
983
+ "Exception occurred during TensorRT-LLM plugin library initialization" ,
988
984
exc_info = e_initialization_error ,
989
985
)
990
986
return False
0 commit comments