其实官方也有一篇教程,照着来完全没问题,不过如果你只是想玩一玩,那完全没有必要搞的那么复杂。

官方教程地址:How to Deploy Deepseek R1 Reasoning Large Language Model (LLM) Using SGLang

以下是我的非官方教程

新建一个实例,性能当然越强越好。我用的应该是比较便宜的那一款,一小时2毛钱(美元),显存是8GB(捉襟见肘)。

如果要注册的话,可以用我的aff,送的300美元够玩很久了。

注册链接:https://www.imtrq.com/vultr_with_coupon

安装SGLang

官方网址:https://docs.sglang.ai/start/install.html

pip install --upgrade pip
pip install sgl-kernel --force-reinstall --no-deps
pip install "sglang[all]" --find-links https://flashinfer.ai/whl/cu124/torch2.5/flashinfer/

安装DeepSeek-R1

官方网址:https://github.com/deepseek-ai/DeepSeek-R1

我安装的是DeepSeek-R1-Distill-Qwen-1.5B,可以视配置情况修改。

python3 -m sglang.launch_server --model deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B --trust-remote-code --tp 1 --host 0.0.0.0 --mem-fraction-static 0.7

注意,如果需要远程访问,需要和我一样加上--host 0.0.0.0,如果内存不够,可以和我一样尝试--mem-fraction-static 0.7。

我试了两次都报错找不到“flashinfer”,感谢这篇文章SGLang, Flashinfer使用踩坑,需要安装一下flashinfer。

pip install flashinfer -i https://flashinfer.ai/whl/cu124/torch2.4

尝试使用

貌似使用的是fastapi?访问http://ip:30000/docs,能看到Swagger文档说明服务就起来了,不过使用这东西感觉也太难受了,还是装个web页面吧。