How-to guides

Deploy SGLang on a GPU server, step by step

To deploy SGLang, rent an NVIDIA GPU with compute capability 7.5 or higher and a CUDA 13-compatible driver, then run the lmsysorg/sglang Docker image or install with uv pip install --prerelease=allow sglang. Start sglang serve with a model ID, set --tp-size, --mem-fraction-static and --context-length deliberately, test /v1/chat/completions on port 30000, and keep the port behind an SSH tunnel or authenticated proxy.

A GPU server with a serving engine block routing many request streams into stacked GPU cards
SGLang turns one or more GPUs into an OpenAI-compatible endpoint; the flags decide how memory is split. AI-generated illustration.

Prerequisites: GPU, driver and VRAM

SGLang is an open-source serving engine for LLMs and vision-language models with an OpenAI-compatible API. Its installation guide states that current releases require CUDA 13, and Docker users need a CUDA 13-compatible driver; the last CUDA 12 image tag was lmsysorg/sglang:v0.5.19-cu129. FlashInfer, the default attention backend, supports compute capability sm75 and above, which covers T4, A10, L4, L40S, A100, H100 and newer cards.

Size the GPU from the weights. At 16-bit precision a model needs about two bytes per parameter, so an 8-billion-parameter model needs roughly 16 GB before any KV cache. SGLang reserves a static share of memory for weights plus the KV cache pool, so a 48 GB or 80 GB card leaves room for real concurrency. A 70B model at 16-bit is about 140 GB and needs tensor parallelism across several 80 GB GPUs. The LLM VRAM budget guide covers the full estimate.

You also need a Linux instance with SSH access, Python 3.11 or newer if you skip Docker, a Hugging Face token for gated models, and disk for the model cache.

Prerequisites: GPU, driver and VRAM
Illustrative model (BF16)WeightsStarting point
0.6B to 4B parameters≈1 to 8 GBOne 24 GB GPU, e.g. L4 or RTX 4090
8B parameters≈16 GBOne 48 GB or 80 GB GPU
32B parameters≈64 GBOne 80 GB GPU or two 48 GB GPUs with --tp-size 2
70B parameters≈140 GBTwo to four 80 GB GPUs with --tp-size

References: SGLang documentation: install · SGLang documentation: server arguments · NVIDIA L4 specifications

Step 1: check the GPU and the driver

Run nvidia-smi. Confirm the product name, memory and GPU count match what you rented, and read the CUDA version in the header: that is the highest CUDA version the installed driver supports. If it is below 13, the current SGLang image will not start; ask the provider for a newer driver or pin the last CUDA 12 image as a stopgap.

On multi-GPU machines also run nvidia-smi topo -m. NV entries mean NVLink between GPUs; PIX, PHB, NODE or SYS mean traffic crosses PCIe or the CPU interconnect, which slows tensor parallelism. vLLM tensor parallelism explains why the link type matters, and the same reasoning applies to SGLang.

References: NVIDIA System Management Interface · SGLang documentation: install

Step 2: install SGLang with Docker or uv

Docker is the shortest route to deploy SGLang because the image bundles CUDA libraries, FlashInfer and the server. It needs the NVIDIA Container Toolkit on the host; Docker with NVIDIA GPUs covers that setup. Pull the image with docker pull lmsysorg/sglang:latest, then pin a specific version tag in production so a restart cannot change the engine under you.

Without Docker, the documented route is a uv virtual environment: pip install --upgrade pip, pip install uv, uv venv --python 3.12, source .venv/bin/activate, then uv pip install --prerelease=allow sglang. Docker is easier to reproduce across machines; a venv is easier to patch while debugging.

References: SGLang documentation: install · SGLang GitHub repository README

Step 3: launch the server with sglang serve

The quickstart launch is sglang serve followed by a Hugging Face model ID, for example sglang serve Qwen/Qwen3-0.6B --host 0.0.0.0 --port 30000. The older form, python3 -m sglang.launch_server --model-path, still appears in parts of the docs. With Docker, the documented command is docker run --gpus all --shm-size 32g --ipc=host -p 30000:30000 -v "$HF_CACHE_DIR:/root/.cache/huggingface" with --env HF_TOKEN for gated models, followed by the image name and the sglang serve command.

Inside a container the server must listen on 0.0.0.0 so Docker can forward to it. Control exposure on the host side instead: publish with -p 127.0.0.1:30000:30000 so only the machine itself can reach the port. Docker’s documentation warns that publishing ports is insecure by default because a plain -p makes the port available to the outside world.

Mount the Hugging Face cache from a persistent disk. Without it, each restart downloads the weights again, which for a large model can take longer than the restart itself.

References: SGLang documentation: quickstart · SGLang documentation: install · SGLang documentation: sending requests · Docker documentation: port publishing

SGLang server flags that matter

Most defaults are sensible. Set the flags below explicitly and record them with the image tag, so the configuration you tested is the configuration you run. Defaults come from the SGLang server arguments reference.

If you get out-of-memory errors while serving, the reference suggests lowering --mem-fraction-static, for example to 0.7, to shrink the KV cache pool. If memory runs out during prefill of long prompts, set a smaller --chunked-prefill-size such as 4096.

SGLang server flags that matter
FlagDefaultHow to set it
--host127.0.0.1Keep it outside Docker; 0.0.0.0 inside a container with a localhost-only publish
--port30000Change only if the port is taken
--tp-size (--tensor-parallel-size)1GPUs on one node that share the model
--dp-size (--data-parallel-size)1Extra replicas when the model fits on fewer GPUs than you have
--mem-fraction-staticComputed; 0.88 if memory cannot be detectedLower if you hit OOM or share the GPU
--context-lengthRead from config.jsonLongest prompt plus output you will accept
--api-keyNoneAlways set it on a reachable server
--served-model-nameNoneStable name returned by /v1/models
--quantizationNoneFor example fp8 or awq, only when you have tested quality
--enable-metricsFalseTurn on to export Prometheus metrics

References: SGLang documentation: server arguments

A GPU memory gauge split between a block of model weights and a pool of cache slots
mem-fraction-static sets how much GPU memory goes to weights plus the KV cache pool; lower it when you hit out-of-memory errors. AI-generated illustration.

Step 4: send a test request

When the log shows the server is ready, call the OpenAI-compatible endpoint from the same machine: curl http://localhost:30000/v1/chat/completions -H "Content-Type: application/json" -d with a JSON body naming the model and a messages array, such as one user message asking for the capital of France. If you set --api-key, add an Authorization: Bearer header with the key.

Check that the reply is coherent, that a request without the key is refused, and that /v1/models returns the name you expect. Any client that speaks the OpenAI API, including the official Python SDK with base_url pointed at http://localhost:30000/v1, should work the same way.

One good reply says nothing about capacity. Before real traffic, load-test at your real prompt and output lengths, as described in benchmark LLM inference.

References: SGLang documentation: quickstart · SGLang documentation: server arguments

Step 5: secure access to the SGLang port

Never leave port 30000 open to the internet. Keep it bound to localhost on the host and reach it through an SSH tunnel for development: ssh -N -L 30000:localhost:30000 user@your-gpu-host, then send requests to http://localhost:30000 from your laptop. The OpenSSH manual describes -L as local port forwarding and -N as not running a remote command.

For production, put a reverse proxy on the same machine. It terminates TLS, enforces per-client keys and rate limits, and writes access logs, while SGLang’s --api-key remains a second layer. Close the provider firewall for every port except SSH and the proxy.

References: OpenSSH ssh(1) manual · Docker documentation: port publishing · SGLang documentation: server arguments

Common errors when you deploy SGLang

The SGLang install guide documents the first three fixes in this table; the rest follow from the flags above.

Common errors when you deploy SGLang
SymptomLikely causeFix
Container exits at start with a CUDA errorDriver older than CUDA 13Update the driver, or pin lmsysorg/sglang:v0.5.19-cu129 temporarily
FlashInfer kernel errors on a supported GPUKernel or cache problemTry --attention-backend triton --sampling-backend pytorch; reinstall flashinfer-python and clear ~/.cache/flashinfer
OSError: CUDA_HOME environment variable is not setCUDA toolkit path unknownSet CUDA_HOME to the toolkit path, e.g. /usr/local/cuda-VERSION
CUDA out of memory while servingKV cache pool too largeLower --mem-fraction-static, e.g. 0.7
OOM on long promptsPrefill chunk too bigSet --chunked-prefill-size 4096
Connection refused from the laptopPort bound to localhost, no tunnelStart the SSH tunnel; do not open the port publicly
Errors with shared memory in multi-GPU runsContainer /dev/shm too smallAdd --shm-size 32g or --ipc=host

References: SGLang documentation: install · SGLang documentation: server arguments

Illustrative serving cost

These figures are illustrative, using assumed rates rather than quotes. An 8B model on one 80 GB GPU at an assumed $2.00 per GPU-hour costs $48 a day and about $1,460 for a 730-hour month. A 70B model on four such GPUs costs four times as much: $8 an hour, $192 a day, about $5,840 a month.

Turn those into cost per request using the throughput you measure in your load test, not a published figure from different hardware. If the server idles at night, scheduled stops save more than any flag. GPU-hour cost explained covers the arithmetic.

Illustrative serving cost
Setup (assumed $2.00 per GPU-hour)Per hourPer dayPer 730-hour month
8B model, 1 × 80 GB GPU$2.00$48$1,460
32B model, 2 × 80 GB GPUs$4.00$96$2,920
70B model, 4 × 80 GB GPUs$8.00$192$5,840

Checklist and next step

nvidia-smi shows the rented GPUs and a CUDA 13-capable driver. Image tag or package version pinned. Hugging Face cache on a persistent disk. --tp-size, --mem-fraction-static and --context-length set explicitly. --api-key set. Port published to 127.0.0.1 only and reached by SSH tunnel or a TLS proxy. Load test run at real lengths. If you are choosing between engines, vLLM vs SGLang compares them, and the vLLM path is in deploy vLLM on a cloud GPU.

Once you know the GPU and count, rent it. On NeuraMesh you pick the GPU, a plan, GPU count, hours and region, for example on the H100 rental page, and receive a confirmed quotation, typically within one business day, with nothing charged until you approve.

NeuraMesh prices for these GPUs

NeuraMesh prices per GPU-hour in USD, excluding taxes, as of 2026-11-27. Live prices are on the rental pages.
GPUMemoryData centerValue
RTX 409024 GB$0.46$0.40
L40S48 GB$1.26$0.54
A10080 GB$1.56$0.98
H10080 GB$2.88$2.00

Every order is confirmed in a quotation before you pay. See all GPU prices.

Questions readers ask

What GPU do I need to deploy SGLang?

An NVIDIA GPU with compute capability 7.5 or higher for the default FlashInfer backend, a CUDA 13-compatible driver, and enough VRAM for the weights plus KV cache. At 16-bit, budget about two bytes per parameter for weights, then leave headroom for traffic.

What port does SGLang use?

Port 30000 by default, and it binds 127.0.0.1 unless you pass --host. Inside Docker, listen on 0.0.0.0 and publish the port as 127.0.0.1:30000:30000 so only the host can reach it.

How do I fix SGLang out of memory errors?

Lower --mem-fraction-static, for example to 0.7, to shrink the KV cache pool. If the error appears during prefill of long prompts, set --chunked-prefill-size to a smaller value such as 4096. Reducing --context-length also helps.

Is sglang serve the same as python -m sglang.launch_server?

Both start the HTTP server. The current quickstart uses sglang serve with the model ID as an argument, while some pages still show python3 -m sglang.launch_server --model-path. Use the form your pinned version documents.

Does SGLang have an OpenAI-compatible API?

Yes. It serves /v1/chat/completions and /v1/models, so the OpenAI Python SDK works with base_url set to the server’s /v1 address. Set --api-key and send it as a Bearer token.

Sources and editorial notes

Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.

Read the editorial policy.

Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.