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

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.
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

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.
  • 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 fails with OSError: CUDA_HOME environment variable is not set, set CUDA_HOME to your CUDA Toolkit installation directory. Replace the path below with the actual path on your machine:
For a versioned installation, this is typically /usr/local/cuda-VERSION. Alternatively, install FlashInfer first using the FlashInfer installation instructions, then retry the SGLang installation.

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.