以下安装过程本人已验证可行供君参看1、安装系统、配置网卡/root文件夹尽量大一些2、装gcc和g直接运行gcc --version和g --version和有提醒安装4、禁用nouveau重建 initramfs 镜像这一步至关重要确保引导时加载新配置重启echo -e blacklist nouveau\noptions nouveau modeset0 | sudo tee /etc/modprobe.d/blacklist-nouveau.confsudo dracut --force --kver $(uname -r)sudo reboot3、装英伟达驱动和cuda建议用run文件运行以下命令后重启wget https://developer.download.nvidia.com/compute/cuda/13.2.0/local_installers/cuda_13.2.0_595.45.04_linux.runsudo sh cuda_13.2.0_595.45.04_linux.runsudo reboot# 查看驱动nvidia-smi# 查看cuda版本nvcc -V4、安装Anaconda3激活SGLang环境psAnaconda3版本自行修改# 给安装包赋予权限对应文件在执行上一步命令时的文件夹下chmod x Anaconda3-2024.10-1-Linux-x86_64.sh# 安装anaconda(安装过程一路选择yes即可在安装路径配置时选择默认路径即可)./Anaconda3-2024.10-1-Linux-x86_64.sh# 安装完毕后重启终端一般会激活conda的base环境如未激活请使用下述命令conda init# 查看是否安装成功conda -V# 创建虚拟环境Python≥3.10 and 3.13conda create -n SGLang python3.10 -yconda activate SGLang5、安装SGLang推理架构及下载模型ps模型名称自行修改# 安装torch及其套件pip install torch2.5.1 torchvision0.20.1 torchaudio2.5.1 --index-url https://download.pytorch.org/whl/cu124# 安装SGLang推理架构pip install --upgrade pippip install sgl-kernel --force-reinstall --no-depspip install sglang[all] --find-links https://flashinfer.ai/whl/cu124/torch2.5/flashinfer/# 通过git lfsmodelscope加速下载模型apt install git git-lfsgit lfs clone https://www.modelscope.cn/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B.git6、启动模型ps执行指令具体参数什么意思自行搜索【如果看到”GET /model_info HTTP/1.1“和“POST /generate HTTP/1.1”均为“200 OK”即为模型成功运行】python3 -m sglang.launch_server --model-path /root/DeepSeek-R1-Distill-Qwen-7B --port 30000 --mem-fraction-static 0.9 --tp 1 --trust-remote-code --host 0.0.0.07、推理测试localhost可以填具体模型服务器地址curl -X POST http://localhost:port/v1/chat/completions \-H Content-Type: application/json \-d {model: default,messages: [{role: system,content: You are a helpful AI assistant},{role: user,content: 你是谁}],temperature: 0.6,max_tokens: 1024}8、其他可选项# 可选由于模型下载时间较长为避免因终端连接中断导致下载失败建议后台挂起操作screen命令自行搜索apt install screenscreen -S SGLang# 可选如遇见transformers库报错请尝试降低版本下述版本确认可用pip install transformers4.48.3