Skip to main content

Quickstart Guide

This guide will get you up and running with TensorRT-LLM in minutes. You’ll learn how to deploy a model for online serving and run offline inference using the Python API.

Prerequisites

Before you begin, ensure you have:
  • NVIDIA GPU with compute capability 7.0+ (Volta, Turing, Ampere, Hopper, or Blackwell)
  • NVIDIA Driver version 535+ installed
  • Docker with NVIDIA Container Toolkit installed
  • 8GB+ GPU memory (for TinyLlama example; larger models require more)
If you don’t have Docker installed, follow the NVIDIA Container Toolkit installation guide.

Launch Docker Container

1

Pull and run the TensorRT-LLM container

The TensorRT-LLM container comes with all dependencies pre-installed. Start the container with GPU access:
Replace 1.3.0rc6 with the latest version tag from the NGC catalog.
The -p 8000:8000 flag exposes port 8000 for the serving API.
2

Verify the installation

Once inside the container, verify TensorRT-LLM is installed:
You should see the version number printed (e.g., 1.3.0rc6).

Option 1: Online Serving with trtllm-serve

The fastest way to deploy a model is using trtllm-serve, which provides an OpenAI-compatible API.
1

Start the server

Launch a model server using trtllm-serve. This example uses TinyLlama for quick testing:
The server will:
  • Download the model from Hugging Face (on first run)
  • Optimize the model for your GPU
  • Start an OpenAI-compatible HTTP server on port 8000
The first run may take a few minutes to download and optimize the model. Subsequent runs are much faster as the optimized model is cached.
2

Send a test request

Open a new terminal and attach to the running container:
Or from outside the container (if you exposed port 8000), send a curl request:
Example Response:
3

Try a quantized model (optional)

For better performance, use a pre-quantized FP8 model:
FP8 quantization requires Hopper GPUs (H100, H200) or newer. For other GPUs, use standard models or INT4/INT8 quantization.
Browse more pre-optimized models in the NVIDIA Model Optimizer collection.

Streaming Responses

To enable streaming (useful for chat applications), add "stream": true to your request:
You’ll receive Server-Sent Events (SSE) with tokens as they’re generated.

Option 2: Offline Inference with LLM API

For batch processing or integration into Python applications, use the LLM API directly.
1

Create a Python script

Create a file called quickstart.py with the following code:
quickstart.py
This code:
  • Loads TinyLlama from Hugging Face
  • Defines three sample prompts
  • Generates completions with temperature sampling
  • Prints the results
2

Run the script

Execute the script inside the Docker container:
Example Output:
3

Try async generation (optional)

For concurrent request processing, use the async API:
async_example.py

Loading Quantized Models

Load pre-quantized models directly from Hugging Face for optimal performance:
Quantized models require significantly less GPU memory and can achieve 2-4x higher throughput with minimal accuracy loss.

Customizing Generation

The SamplingParams class provides fine-grained control over text generation:

Next Steps

Congratulations! You’ve successfully run your first TensorRT-LLM inference. Here’s what to explore next:

Installation Options

Learn about pip installation, building from source, and system requirements

Advanced Examples

Explore speculative decoding, multi-GPU inference, LoRA adapters, and more

Model Support

Check which models are supported and how to add custom models

Performance Tuning

Learn how to benchmark and optimize performance for your workload

Common Issues

If you encounter CUDA out of memory errors:
  1. Use a smaller model (e.g., TinyLlama instead of Llama-70B)
  2. Reduce batch size with max_batch_size parameter
  3. Use quantized models (FP8, INT4) to reduce memory footprint
  4. Enable KV cache offloading for long sequences
If model download from Hugging Face fails:
  1. Check your internet connection
  2. Set HuggingFace token if the model requires authentication:
  3. Download the model manually and pass the local path:
If you can’t connect to the trtllm-serve server:
  1. Ensure port 8000 is exposed with -p 8000:8000 in docker run
  2. Check the server started successfully (no errors in logs)
  3. Try connecting from inside the container first:
  4. Check firewall settings if connecting from another machine
For more troubleshooting help, check the FAQ or open an issue on GitHub.