sglang Python package, using sglang generate and sglang serve.
Docker is the recommended setup for Linux GPU deployments. The official NVIDIA images include SGLang, its diffusion dependencies, and the optimized kernel stack; no separate Python installation or pip install inside the container is needed for the standard diffusion runtime. Optional backends and model-specific dependencies are documented in the cookbook.
For Python installation, use sglang[diffusion]: [diffusion] adds optional dependencies to the same package, not a separate engine.
Install on NVIDIA GPUs
- Docker (recommended)
- pip / uv
- From source
Use Linux with a supported NVIDIA GPU, a driver compatible with the image’s CUDA version, Docker Engine, and NVIDIA Container Toolkit. Configure Docker’s GPU runtime before continuing. See the SGLang installation guide for current CUDA requirements.The example uses the latest stable release. For reproducible deployments, replace Start a container with persistent model and output directories. The working directory is For gated or private models, export your Hugging Face token as
latest with a release tag or image digest from Docker Hub. For models or features not yet released, choose a nightly image containing the required changes, or install from source./outputs, so generated files remain in the host’s outputs directory after the container exits. The server port is published only on the host’s loopback interface.HF_TOKEN on the host and add --env HF_TOKEN before the image name. Mount any local input media or checkpoints into the container and use their container paths in requests.Run the commands in Generate or serve inside this container. For development tools and source changes, see the development environment guide.Generate or serve
Run these commands inside the container or your activated Python environment. For a one-off image:0.0.0.0 makes the published container port reachable from the host:
AMD GPUs (ROCm)
Docker is also recommended for AMD GPUs. Use a ROCm image matched to your GPU and host driver, not the NVIDIAlatest image. Follow AMD GPUs for the current image tags, device passthrough flags, and source installation options.
For Strix Halo / gfx1151, use rocm/sgl-dev:*-gfx1151* (image sets SGLANG_USE_AITER=0) and pass --attention-backend torch_sdpa --num-gpus 1. Do not use AITER on wave32 gfx115x. See the Strix Halo section in AMD GPUs.
Platform-Specific: MUSA (Moore Threads GPUs)
Moore Threads GPUs (MUSA)
For Moore Threads GPUs (MTGPU) with the MUSA software stack, follow the platform guide first. If the source tree still requires the alternate platformpyproject fallback, keep a backup of the default file before switching:
Command
Intel XPU
For Intel Data Center GPU Max or Arc GPUs, follow the Docker instructions in the XPU installation guide. The Dockerfile already includes diffusion dependencies.Ascend NPU
For Ascend NPU, please follow the NPU installation guide. Quick test:Command
Platform-Specific: Apple MPS
For Apple MPS, install natively on macOS using the source instructions below; the Linux Docker image is not an MPS runtime. If the source tree still requires the alternate platformpyproject fallback, keep a backup of the default file before switching:
Command
all_mps extra also installs the SRT
MLX backend dependencies; SGLANG_USE_MLX applies only to SRT serving.