{"record":{"id":"5686f1831a68c84e","repo":"oobabooga/textgen","slug":"failed-to-import-tensorrt-llm-please-install-it","errorCode":null,"errorMessage":"Failed to import 'tensorrt_llm'. Please install it manually following the instructions in the TensorRT-LLM GitHub repository.","messagePattern":"Failed to import 'tensorrt_llm'\\. Please install it manually following the instructions in the TensorRT-LLM GitHub repository\\.","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"modules/models.py","lineNumber":128,"sourceCode":"\ndef ExLlamav3_HF_loader(model_name):\n    from modules.exllamav3_hf import Exllamav3HF\n\n    return Exllamav3HF.from_pretrained(model_name)\n\n\ndef ExLlamav3_loader(model_name):\n    from modules.exllamav3 import Exllamav3Model\n\n    model, tokenizer = Exllamav3Model.from_pretrained(model_name)\n    return model, tokenizer\n\n\ndef TensorRT_LLM_loader(model_name):\n    try:\n        from modules.tensorrt_llm import TensorRTLLMModel\n    except ModuleNotFoundError:\n        raise ModuleNotFoundError(\"Failed to import 'tensorrt_llm'. Please install it manually following the instructions in the TensorRT-LLM GitHub repository.\")\n\n    model = TensorRTLLMModel.from_pretrained(model_name)\n    return model, model.tokenizer\n\n\ndef unload_model(keep_model_name=False):\n    if shared.model is None:\n        return\n\n    model_class_name = shared.model.__class__.__name__\n    is_llamacpp = (model_class_name == 'LlamaServer')\n\n    if model_class_name in ['Exllamav3Model', 'Exllamav3HF', 'TensorRTLLMModel']:\n        shared.model.unload()\n    elif model_class_name == 'LlamaServer':\n        shared.model.stop()\n\n    shared.model = shared.tokenizer = None","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/oobabooga/textgen/blob/ed888c71f221df552750e1834b3654abab8ae345/modules/models.py#L110-L146","documentation":"Error \"Failed to import 'tensorrt_llm'. Please install it manually following the instructions in the TensorRT-LLM GitHub repository.\" thrown in oobabooga/textgen.","triggerScenarios":"Raised when the TensorRT-LLM loader is selected but the 'tensorrt_llm' Python package cannot be imported. Triggers when TensorRT-LLM is not installed in the environment; install it manually following the TensorRT-LLM GitHub repository instructions.","commonSituations":"See trigger scenarios.","solutions":["Install TensorRT-LLM manually following the instructions in its GitHub repository.","Select a different model loader that does not require tensorrt_llm."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed888c71f221df552750e1834b3654abab8ae345","analyzedAt":"2026-08-15T05:24:21.000Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}