Instructions to use deepseek-ai/DeepSeek-R1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/DeepSeek-R1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use deepseek-ai/DeepSeek-R1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "deepseek-ai/DeepSeek-R1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-R1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/deepseek-ai/DeepSeek-R1
- SGLang
How to use deepseek-ai/DeepSeek-R1 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 "deepseek-ai/DeepSeek-R1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-R1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "deepseek-ai/DeepSeek-R1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-R1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use deepseek-ai/DeepSeek-R1 with Docker Model Runner:
docker model run hf.co/deepseek-ai/DeepSeek-R1
所以部署一个671B的模型 显存需要多少 有什么基准的硬件配置?
所以部署一个671B的模型 显存需要多少 有什么基准的硬件配置?
如果不想量化损失 benchmark scores,需要 700GB 以上的显存,或者 700 GB 以上的 CPU 内存。
现在本地部署满血deepseekR1按精度区分, **FP16(16位浮点数)需要1.342 TB显存, **FP32(32位浮点数)需要 2.684 TB显存,普通人就别想了…
看着是混合精度:BF16·F8_E4M3·F32,而且还要预留一部分现存给推理时用
现在本地部署满血deepseekR1按精度区分, **FP16(16位浮点数)需要1.342 TB显存, **FP32(32位浮点数)需要 2.684 TB显存,普通人就别想了…
如果有设备,如何部署?有方案吗?
能跑这个模型的工具我只试过 Ollama。
命令是 ollama run deepseek-r1:671b-q8_0
大概要 713GB 的硬盘存储空间,以及大约768GB的内存或者显存。
参考 https://zhuanlan.zhihu.com/p/20714478546
现在我们部署了一套满血版可以给你参考
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
为什么我们a800 3token/s?
可以交流一下你们做了哪里的限制吗 方便的话可以加个v
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
为什么我们a800 3token/s?
可以交流一下你们做了哪里的限制吗 方便的话可以加个v
请教下,八卡H20部署,使用的Ollama吗?还是其他什么工具
这个限制了能加速吗
具体那个参数?
请教下,八卡H20部署,使用的Ollama吗?还是其他什么工具
sglang 和vllm都可以
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
为什么我们a800 3token/s?
可以交流一下你们做了哪里的限制吗 方便的话可以加个v
8卡A800显存够吗?我只部署了一个AWQ量化版本的R1.
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
为什么我们a800 3token/s?
可以交流一下你们做了哪里的限制吗 方便的话可以加个v8卡A800显存够吗?我只部署了一个AWQ量化版本的R1.
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
为什么我们a800 3token/s?
可以交流一下你们做了哪里的限制吗 方便的话可以加个v8卡A800显存够吗?我只部署了一个AWQ量化版本的R1.
量化应该可以 满血不够
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
大佬,是使用的量化到多少的版本
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
大佬,是使用的量化到多少的版本
@Nashihikari 未量化的版本……而且目前速度经过优化能到单请求 20 tokens/s 了(不过并发下降到 20 左右,否则可能出现异常截断或者OOM)
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
为什么我们a800 3token/s?
可以交流一下你们做了哪里的限制吗 方便的话可以加个v
单机8卡A100 AWQ量化就可以部署起来了。已验证
如果不用任何量化方式,想问下是不是至少要16张a 800 80g?
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
大佬,是使用的量化到多少的版本
@Nashihikari 未量化的版本……而且目前速度经过优化能到单请求 20 tokens/s 了(不过并发下降到 20 左右,否则可能出现异常截断或者OOM)
可以请教一下如何优化的吗,我们打算用H20部署满血版,20tps真不错呀
bs=1 (单请求) 下 671B 一般能到多少的 TPS 啊?(如果不允许量化、稀疏)
我们目前使用了一台八卡H20进行部署,能保证约50路左右的并发(单路并发约 7 tokens/s),但是在上下文方面我们做了限制
大佬,是使用的量化到多少的版本
@Nashihikari 未量化的版本……而且目前速度经过优化能到单请求 20 tokens/s 了(不过并发下降到 20 左右,否则可能出现异常截断或者OOM)
可以请教一下如何优化的吗,我们打算用H200部署满血版,20tps真不错呀
单机 8卡 MI300 的满血、满精度版的 bs = 1 TPS 可以达到 90+了。
https://github.com/microsoft/Tutel?tab=readme-ov-file#support-full-precision-inference-of-moe-based-deepseek-r1-671b-on-amd-mi300
八卡H20 使用VLLM 0.7.1部署【cognitivecomputations/DeepSeek-R1-awq】,然后使用Vllm benchmark_serving 随机100个输入,最大10并发,4000Token输入的情况下,能到39.78Token/S,不过首Token输出平均时间特别长,到了25秒
h20 141g h200 141g的整机我都有 但是部署有点问题 有经验的大佬可以相互指教一下。
h20 141g h200 141g的整机我都有 但是部署有点问题 有经验的大佬可以相互指教一下。
什么问题
