页面简介
Run NVIDIA Cosmos Reason2 (2B / 8B) models on Jetson with vLLM and connect to Live VLM WebUI for real-time vision inference.
正文摘录
Back to Tutorials Cosmos Reason2 Models on Jetson Run NVIDIA Cosmos Reason2 (2B / 8B) models on Jetson with vLLM and connect to Live VLM WebUI for real-time vision inference. Author Johnny Nuñez NVIDIA Cosmos Reason2 is a family of vision-language models with built-in chain-of-thought reasoning capabilities. The family includes two sizes: Cosmos Reason2 2B — a compact model ideal for memory-constrained edge devices, capable of spatial reasoning, anomaly detection, and scene analysis. Cosmos Reason2 8B — a larger model that delivers stronger reasoning accuracy while still fitting on Jetson AGX platforms. Both models are available in quantized formats (FP8 for vLLM, FP4/other GGUF variants for llama.cpp) and can be served on Jetson. This tutorial walks through downloading, serving, and connecting either model to Live VLM WebUI for real-time webcam-based inference. Prerequisites RequirementDetailsDevicesJetson AGX Thor, AGX Orin (64 GB / 32 GB), Orin Super NanoJetPackJP 6 (L4T r36.x) for Orin · JP 7 (L4T r38.x) for ThorStorageNVMe SSD required — ~5 GB (2B) / ~17 GB (8B) for weights, ~8 GB for vLLM imageAccountsNVIDIA NGC (free) — for NGC CLI and model download Which Model Should I Choose using vLLM? Cosmos Reason2 2BCosmos Reason2 8BParameters2 billion8 billionFP8 Weights~5 GB~17 GBSupported DevicesThor, AGX Orin, Orin Super NanoThor, AGX OrinReasoning StrengthGood — spatial reasoning, anomaly detectionStronger — more detailed analysis and accuracyBest ForMemory-constrained deployments, fast prototypingHigher-accuracy reasoning when memory allows Important: Orin Super Nano supports only the 2B model when running with vLLM due to memory constraints. Tip: If you prefer a lighter-weight setup (especially on Orin Nano), both models are also available as GGUF checkpoints for llama.cpp. See the individual model pages for Cosmos Reason2 2B and Cosmos Reason2 8B. Overview Jetson AGX ThorJetson AGX OrinOrin Super NanovLLM Containerghcr.io/nvidia-ai-iot/vllm:latest-jetson-thorghcr.io/nvidia-ai-iot/vllm:latest-jetson-oringhcr.io/nvidia-ai-iot/vllm:latest-jetson-orinModelFP8 2B or 8B via NGCFP8 2B or 8B via NGCFP8 2B via NGCMax Model Length8192 tokens8192 tokens768 tokens (memory-constrained)GPU Memory Util0.80.80.52 The workflow is the same for both models and all devices: Download the FP8 model checkpoint via NGC CLI Pull the vLLM Docker image for your device Launch the container with the model mounted as a volume Connect Live VLM WebUI to the vLLM endpoint Step 1: Install the NGC CLI The NGC CLI lets you download model checkpoints from the NVIDIA NGC Catalog. Download and install mkdir -p ~/Projects/CosmosReason2 cd ~/Projects/CosmosReason2 # Download the NGC CLI for ARM64 # Get the latest installer URL from: https://org.ngc.nvidia.com/setup/installers/cli wget -O ngccli_arm64.zip https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions/4.13.0/files/ngccli_arm64.zip unzip ngccli_arm64.zip chmod u+x ngc-cli/ngc # Add to PATH export PATH="$PATH:$(pwd)/ngc-cli" Configure the CLI ngc config set You will be prompted for: API Key — generate one at NGC API Key setup CLI output format — choose json or ascii org — press Enter to accept the default Step 2: Download the Model Download the FP8-quantized checkpoint for the model you want to run. Cosmos Reason2 2B (all devices) cd ~/Projects/CosmosReason2 ngc registry model download-version "nim/nvidia/cosmos-reason2-2b:1208-fp8-static-kv8" This creates a directory called cosmos-reason2-2b_v1208-fp8-static-kv8/ containing the model weights. Cosmos Reason2 8B (AGX Thor / AGX Orin only) cd ~/Projects/CosmosReason2 ngc registry model download-version "nim/nvidia/cosmos-reason2-8b:1208-fp8-static-kv8" This creates a directory called cosmos-reason2-8b_v1208-fp8-static-kv8/. The 8B model provides stronger reasoning capabilities but requires more memory — it is not supported on Orin Super Nano. Note the full path of the model you downloaded — you will mount it into the Docker container as a volume. Step 3: Pull the vLLM Docker Image For Jetson AGX Thor docker pull ghcr.io/nvidia-ai-iot/vllm:latest-jetson-thor For Jetson AGX Orin / Orin Super Nano docker pull ghcr.io/nvidia-ai-iot/vllm:latest-jetson-orin Step 4: Serve Cosmos Reason2 with vLLM Select your Jetson device below for device-specific instructions: AGX Thor AGX Orin Orin Super Nano (2B only) Thor has ample GPU memory and can run either the 2B or 8B model with generous context length. Set the model path and free cached memory: # For the 2B model: MODEL_PATH="$HOME/Projects/CosmosReason2/cosmos-reason2-2b_v1208-fp8-static-kv8" # Or for the 8B model: # MODEL_PATH="$HOME/Projects/CosmosReason2/cosmos-reason2-8b_v1208-fp8-static-kv8" sudo sysctl -w vm.drop_caches=3 1. Launch the container: docker run --rm -it \ --runtime nvidia \ --network host \ --shm-size=8g \ --ulimit memlock=-1 \ --ulimit stack=67108864 \ -v "$MODEL_PATH:/models/cosmos-reason2:ro" \ -e NVIDIA_VISIBLE_DEVICES=all \ -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \ ghcr.io/nvidia-ai-iot/vllm:latest-jetson-thor \ bash 2. Inside the container, activate the environment and serve: cd /opt/ source venv/bin/activate vllm serve /models/cosmos-reason2 \ --max-model-len 8192 \ --media-io-kwargs '{"video": {"num_frames": -1}}' \ --reasoning-parser qwen3 \ --gpu-memory-utilization 0.8 Note: The --reasoning-parser qwen3 flag enables chain-of-thought reasoning extraction. The --media-io-kwargs flag configures video frame handling. Wait until you see: INFO: Uvicorn running on http://0.0.0.0:8000 AGX Orin can run either the 2B or 8B model with the same parameters as Thor. Set the model path and free cached memory: # For the 2B model: MODEL_PATH="$HOME/Projects/CosmosReason2/cosmos-reason2-2b_v1208-fp8-static-kv8" # Or for the 8B model: # MODEL_PATH="$HOME/Projects/CosmosReason2/cosmos-reason2-8b_v1208-fp8-static-kv8" sudo sysctl -w vm.drop_caches=3 1. Launch the container: docker run --rm -it \ --runtime nvidia \ --network host \ --shm-size=8g \ --ulimit memlock=-1 \ --ulimit stack=67108864 \ -v "$MODEL_PATH:/models/cosmos-reason2:ro" \ -e NVIDIA_VISIBLE_DEVICES=all \ -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \ ghcr.io/nvidia-ai-iot/vllm:latest-jetson-orin \ bash 2. Inside the container, activate the environment and serve: cd /opt/ source venv/bin/activate vllm serve /models/cosmos-reason2 \ --max-model-len 8192 \ --media-io-kwargs '{"video": {"num_frames": -1}}' \ --reasoning-parser qwen3 \ --gpu-memory-utilization 0.8 Wait until you see: INFO: Uvicorn running on http://0.0.0.0:8000 The Orin Super Nano has significantly less RAM, so we need aggressive memory optimization including reducing the model’s default image resolution. Only the 2B model is supported on this device. 1. Reduce the model’s image resolution config: The default preprocessor_config.json allows images up to 16M pixels, which produces too many tokens for the Orin Super Nano’s limited context window. Reduce it on the host before launching Docker: cd ~/Projects/CosmosReason2/cosmos-reason2-2b_v1208-fp8-static-kv8 cp preprocessor_config.json preprocessor_config.json.bak python3 -c " import json with open('preprocessor_config.json') as f: cfg = json.load(f) print(f'Old longest_edge: {cfg[\"size\"][\"longest_edge\"]}') print(f'Old shortest_edge: {cfg[\"size\"][\"shortest_edge\"]}') cfg['size']['longest_edge'] = 50176 cfg['size']['shortest_edge'] = 3136 with open('preprocessor_config.json', 'w') as f: json.dump(cfg, f, indent=2) print('New longest_edge: 50176') print('New shortest_edge: 3136') " This limits input images to ~50K pixels, keeping image tokens small enough to fit in the constrained context window. 2. Set the model path and free cached memory: MODEL_PATH="$HOME/Projects/CosmosReason2/cosmos-reason2-2b_v1208-fp8-static-kv8" sudo sysctl -w vm.drop_caches=3 3. Launch the container: docker run --rm -it \ --runtime nvidia \ --network host \ -v "$MODEL_PATH:/models/cosmos-reason2:ro" \ -e NVIDIA_VISIBLE_DEVICES=all \ -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \ ghcr.io/nvidia-ai-iot/vllm:latest-jetson-orin \ bash 4. Inside the container, activate the environment and serve: cd /opt/ source venv/bin/activate vllm serve /models/cosmos-reason2 \ --host 0.0.0.0 \ --port 8000 \ --trust-remote-code \ --enforce-eager \ --max-model-len 768 \ --max-num-batched-tokens 768 \ --gpu-memory-utilization 0.52 \ --max-num-seqs 1 \ --enable-chunked-prefill \ --limit-mm-per-prompt '{"image":1}' Key flags explained (Orin Super Nano only): FlagPurpose--enforce-eagerDisables CUDA graphs to save memory--max-model-len 768Context window sized for image tokens + output--max-num-batched-tokens 768Matches the model length limit--gpu-memory-utilization 0.52Uses most available memory (~3.9 GiB free of 7.4 GiB)--max-num-seqs 1Single request at a time to minimize memory--enable-chunked-prefillProcesses prefill in chunks for memory efficiency--limit-mm-per-promptLimits to 1 image per prompt Wait until you see the server is ready: INFO: Uvicorn running on http://0.0.0.0:8000 Verify the server is running From another terminal on the Jetson: curl http://localhost:8000/v1/models You should see the model listed in the response. Step 5: Test with a Quick API Call Before connecting the WebUI, verify the model responds correctly with a vision request. First, download a sample image: wget -q -O sample.jpg https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg Then send a vision request: curl -s http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "/models/cosmos-reason2", "messages": [ { "role": "user", "content": [ {"type": "image_url", "image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"}}, {"type": "text", "text": "Describe what you see in this image."} ] } ], "max_tokens": 256 }' | python3 -m json.tool You should see a response with chain-of-thought reasoning followed by a description of the image. Tip: The