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-smican see your GPU. - The CUDA 13 Toolkit, including
nvccand development headers. The CUDA version shown bynvidia-smidescribes 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: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:
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
- pip / uv
- From source
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 (Image optionsThe examples use The container shell is ready for
-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: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-runtimetag. - 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.
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.sglang serve.Start a model server
For a pip / source install, verify the active interpreter’s headers before loading a model:MODEL_PATH with a Hugging Face model ID or a local model directory:
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.Kubernetes
Serve models on a Kubernetes cluster, on one node or across multiple nodes.
Kubernetes
Serve models on a Kubernetes cluster, on one node or across multiple nodes.
Please check out OME, a Kubernetes operator for enterprise-grade management and serving of large language models (LLMs).
-
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. -
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 commandkubectl apply -f docker/k8s-sglang-distributed-sts.yaml, to create two nodes k8s statefulset and serving service.
Docker Compose
Run a model service on a single Docker host with a Compose configuration.
Docker Compose
Run a model service on a single Docker host with a Compose configuration.
This method is recommended if you plan to serve it as a service. A better approach is to use the k8s-sglang-service.yaml.
- Copy the compose.yml to your local machine
- Execute the command
docker compose up -din your terminal.
SkyPilot
Deploy on Kubernetes or across cloud providers from one YAML configuration.
SkyPilot
Deploy on Kubernetes or across cloud providers from one YAML configuration.
To deploy on Kubernetes or 12+ clouds, you can use SkyPilot.
- Install SkyPilot and set up Kubernetes cluster or cloud access: see SkyPilot’s documentation.
- Deploy on your own infra with a single command and get the HTTP API endpoint:
SkyPilot YAML: sglang.yaml
SkyPilot YAML: sglang.yaml
Config
Command
- To further scale up your deployment with autoscaling and failure recovery, check out the SkyServe + SGLang guide.
AWS SageMaker
Deploy on SageMaker with a pre-built SGLang image or your own container.
AWS SageMaker
Deploy on SageMaker with a pre-built SGLang image or your own container.
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:
- Build a docker container with sagemaker.Dockerfile alongside the serve script.
- Push your container onto AWS ECR.
Build script: build-and-push.sh
Build script: build-and-push.sh
Command
- Deploy a model for serving on AWS Sagemaker, refer to deploy_and_serve_endpoint.py. For more information, check out sagemaker-python-sdk.
- 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. - To modify your model serving parameters, the serve script allows for all available options within
python3 -m sglang.launch_server --helpcli by specifying environment variables with prefixSM_SGLANG_. - The serve script will automatically convert all environment variables with prefix
SM_SGLANG_fromSM_SGLANG_INPUT_ARGUMENTinto--input-argumentto be parsed intopython3 -m sglang.launch_servercli. - For example, to run Qwen/Qwen3-0.6B with reasoning parser, simply add additional environment variables
SM_SGLANG_MODEL_PATH=Qwen/Qwen3-0.6BandSM_SGLANG_REASONING_PARSER=qwen3.
- By default, the model server on SageMaker will run with the following command:
Troubleshooting
CUDA_HOME
If installation or startup fails withOSError: 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:
/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
ForFailed 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 pytorchand open an issue on GitHub. - To reinstall flashinfer locally, use the following command:
pip3 install --upgrade flashinfer-python --force-reinstall --no-depsand then delete the cache withrm -rf ~/.cache/flashinfer.
