Instructions to use nvidia/Nemotron-Flash-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Nemotron-Flash-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Nemotron-Flash-3B", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("nvidia/Nemotron-Flash-3B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/Nemotron-Flash-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Nemotron-Flash-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/Nemotron-Flash-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/nvidia/Nemotron-Flash-3B
- SGLang
How to use nvidia/Nemotron-Flash-3B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nvidia/Nemotron-Flash-3B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/Nemotron-Flash-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nvidia/Nemotron-Flash-3B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/Nemotron-Flash-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use nvidia/Nemotron-Flash-3B with Docker Model Runner:
docker model run hf.co/nvidia/Nemotron-Flash-3B
Upload setup.sh
Browse files
setup.sh
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -eo pipefail
|
| 3 |
+
|
| 4 |
+
CONDA_ROOT="/lustre/fsw/portfolios/nvr/projects/nvr_lpr_llm/users/yongganf/anaconda"
|
| 5 |
+
ENV_NAME="nemotron_flash"
|
| 6 |
+
PYTHON_VERSION="3.10.12"
|
| 7 |
+
|
| 8 |
+
source "${CONDA_ROOT}/etc/profile.d/conda.sh"
|
| 9 |
+
|
| 10 |
+
if conda env list | awk '{print $1}' | grep -qx "${ENV_NAME}"; then
|
| 11 |
+
echo "Conda env '${ENV_NAME}' already exists, skipping creation."
|
| 12 |
+
else
|
| 13 |
+
echo "Creating conda env '${ENV_NAME}' with Python ${PYTHON_VERSION}..."
|
| 14 |
+
conda create -n "${ENV_NAME}" "python=${PYTHON_VERSION}" -y
|
| 15 |
+
fi
|
| 16 |
+
conda activate "${ENV_NAME}"
|
| 17 |
+
|
| 18 |
+
echo "Installing CUDA toolkit 12.8..."
|
| 19 |
+
conda install -c nvidia cuda-toolkit=12.8 -y
|
| 20 |
+
|
| 21 |
+
export CUDA_HOME
|
| 22 |
+
CUDA_HOME="$(dirname "$(dirname "$(which nvcc)")")"
|
| 23 |
+
echo "CUDA_HOME set to ${CUDA_HOME}"
|
| 24 |
+
|
| 25 |
+
echo "Installing PyTorch and core Python packages..."
|
| 26 |
+
pip install torch==2.8.0 transformers==4.56.2 psutil
|
| 27 |
+
|
| 28 |
+
echo "Installing causal-conv1d from source..."
|
| 29 |
+
pip install --no-build-isolation causal-conv1d
|
| 30 |
+
|
| 31 |
+
echo "Installing flash-attention from source..."
|
| 32 |
+
pip install --no-build-isolation flash-attn==2.7.3
|
| 33 |
+
|
| 34 |
+
echo "Installing mamba-ssm from source..."
|
| 35 |
+
pip install --no-build-isolation mamba-ssm
|
| 36 |
+
|
| 37 |
+
echo "Installing flash-linear-attention..."
|
| 38 |
+
pip install --no-build-isolation flash-linear-attention
|
| 39 |
+
|
| 40 |
+
echo "Done! Environment '${ENV_NAME}' is ready."
|
| 41 |
+
|