Skip to main content
Choose one installation method below. These instructions target Linux with NVIDIA GPUs; for other devices, see Hardware platforms.

Prerequisites

For Docker, install a compatible NVIDIA driver, Docker Engine, and NVIDIA Container Toolkit as described below. You do not need a host CUDA Toolkit or Python development environment. For pip / uv and source installs, install these before launching a server, even when installing prebuilt SGLang wheels. Some kernels compile at runtime:
  • A CUDA 13-compatible NVIDIA driver. Check that nvidia-smi can see your GPU.
  • The CUDA 13 Toolkit, including nvcc and development headers. The CUDA version shown by nvidia-smi describes driver compatibility; it does not mean the Toolkit is installed. CUDA runtime libraries installed by pip are not a substitute for a complete build toolchain.
  • A C/C++ compiler and Python development headers (Python.h) matching the interpreter in your environment.

Ubuntu setup for pip and source installs

Install the host build tools:
Install a CUDA 13 Toolkit using NVIDIA’s Linux installation guide. Select your Ubuntu release and architecture, and use a versioned cuda-toolkit-X-Y package from NVIDIA’s repository. For example, cuda-toolkit-13-0 installs CUDA 13.0 without replacing your driver. Ubuntu’s nvidia-cuda-toolkit package may be too old for your SGLang release or GPU. Set the path to the Toolkit you installed and check both compilers. Adjust the example path if you installed a different version:
The uv steps below use a managed Python installation that includes its development headers. If you use Ubuntu’s Python instead, install the matching development package: for example, sudo apt-get install python3.12-dev for Ubuntu 24.04’s Python 3.12. A virtual environment alone does not provide missing headers from its base interpreter.

Install SGLang

Docker includes Python, SGLang, and its dependencies; no separate host Python installation is required.The docker images are available on Docker Hub at lmsysorg/sglang, built from Dockerfile. Use Linux with a supported NVIDIA GPU, a CUDA 13-compatible driver, Docker Engine, and NVIDIA Container Toolkit. Complete the Toolkit guide’s Docker runtime configuration before starting a GPU container.SGLang images ship a CUDA 13 environment. CUDA 12 images (-cu12 / -cu129) are no longer published; lmsysorg/sglang:v0.5.19-cu129 is the last CUDA 12 tag.Pull the imagelatest contains the newest stable release:
Image optionsThe examples use latest. To use another image, replace the tag in the pull and run commands:
  • Nightly: Built daily from the latest main, including changes not yet in a stable release. Choose a tag from the nightly image list.
  • Runtime: A smaller image of the same stable release, with inference dependencies and fewer development utilities. Use the latest-runtime tag.
  • AWS EFA: The CUDA 13 images above include the AWS EFA userspace for EFA-enabled EC2 instances. See AWS EFA for the settings that enable it.
For reproducible deployments, use a specific release or dated nightly tag from Docker Hub.Start a containerSet HF_CACHE_DIR to an absolute directory path on the host for downloaded model weights, replacing the placeholder below.For gated or private models, export your Hugging Face token as HF_TOKEN on the host and add --env HF_TOKEN before the image name in this command.
The container shell is ready for sglang serve.

Start a model server

For a pip / source install, verify the active interpreter’s headers before loading a model:
Start a model server inside your Docker container or activated Python environment. Replace MODEL_PATH with a Hugging Face model ID or a local model directory:
Additional launch arguments depend on the model and your hardware. The first launch can spend several minutes downloading weights, compiling kernels, and capturing CUDA graphs. Cached kernels can reduce subsequent startup time, but CUDA graph capture still runs when the server starts. Wait for The server is fired up and ready to roll! before sending requests; a missing compiler or header is an error, not a warmup stage.
  • Quickstart: Launch a model and send a request to verify the server.
  • Cookbook: Find model-specific launch arguments for your hardware.

Deployment options

Choose how to run SGLang as a service. Expand an option for setup instructions.
Please check out OME, a Kubernetes operator for enterprise-grade management and serving of large language models (LLMs).
  1. Option 1: For single node serving (typically when the model size fits into GPUs on one node) Execute command kubectl apply -f docker/k8s-sglang-service.yaml, to create k8s deployment and service, with llama-31-8b as example.
  2. Option 2: For multi-node serving (usually when a large model requires more than one GPU node, such as DeepSeek-R1) Modify the LLM model path and arguments as necessary, then execute command kubectl apply -f docker/k8s-sglang-distributed-sts.yaml, to create two nodes k8s statefulset and serving service.
This method is recommended if you plan to serve it as a service. A better approach is to use the k8s-sglang-service.yaml.
  1. Copy the compose.yml to your local machine
  2. Execute the command docker compose up -d in your terminal.
To deploy on Kubernetes or 12+ clouds, you can use SkyPilot.
  1. Install SkyPilot and set up Kubernetes cluster or cloud access: see SkyPilot’s documentation.
  2. Deploy on your own infra with a single command and get the HTTP API endpoint:
Config
Command
  1. To further scale up your deployment with autoscaling and failure recovery, check out the SkyServe + SGLang guide.
To deploy on SGLang on AWS SageMaker, check out AWS SageMaker InferenceAmazon Web Services provide supports for SGLang containers along with routine security patching. For available SGLang containers, check out AWS SGLang DLCs.To deploy a pre-built SGLang Deep Learning Container without building your own image, see Amazon SageMaker AI.To host a model with your own container, follow the following steps:
  1. Build a docker container with sagemaker.Dockerfile alongside the serve script.
  2. Push your container onto AWS ECR.
Command
  1. Deploy a model for serving on AWS Sagemaker, refer to deploy_and_serve_endpoint.py. For more information, check out sagemaker-python-sdk.
    1. By default, the model server on SageMaker will run with the following command: python3 -m sglang.launch_server --model-path /opt/ml/model --host 0.0.0.0 --port 8080. This is optimal for hosting your own model with SageMaker.
    2. To modify your model serving parameters, the serve script allows for all available options within python3 -m sglang.launch_server --help cli by specifying environment variables with prefix SM_SGLANG_.
    3. The serve script will automatically convert all environment variables with prefix SM_SGLANG_ from SM_SGLANG_INPUT_ARGUMENT into --input-argument to be parsed into python3 -m sglang.launch_server cli.
    4. For example, to run Qwen/Qwen3-0.6B with reasoning parser, simply add additional environment variables SM_SGLANG_MODEL_PATH=Qwen/Qwen3-0.6B and SM_SGLANG_REASONING_PARSER=qwen3.

Troubleshooting

CUDA_HOME

If installation or startup fails with OSError: CUDA_HOME environment variable is not set or cannot find nvcc, first check that the CUDA Toolkit is installed. Setting CUDA_HOME does not install it. Follow the prerequisites, then point CUDA_HOME at the real Toolkit directory:
For a versioned installation, this is typically /usr/local/cuda-VERSION. Installing FlashInfer alone does not provide all the system build dependencies needed by SGLang’s other JIT kernels.

Missing compiler or Python.h

For Failed to find C compiler or a missing gcc / g++, install build-essential on Ubuntu. For fatal error: Python.h: No such file or directory, install development headers for the active Python interpreter, not just the system default. Use the header check above to see which path is missing. If you do not need a system Python, create a fresh environment with uv venv --python 3.12 --managed-python and reinstall SGLang there.

FlashInfer

  • FlashInfer is the default attention kernel backend. It only supports sm75 and above. If you encounter any FlashInfer-related issues on sm75+ devices (e.g., T4, A10, A100, L4, L40S, H100), please switch to other kernels by adding --attention-backend triton --sampling-backend pytorch and open an issue on GitHub.
  • To reinstall flashinfer locally, use the following command: pip3 install --upgrade flashinfer-python --force-reinstall --no-deps and then delete the cache with rm -rf ~/.cache/flashinfer.