课程笔记

  1. 检查当前 GPU 是否可用
amd-smi
python -c "import torch; print('PyTorch:', torch.__version__); print('ROCm available:', torch.cuda.is_available()); print('Device:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A')"
  1. 框架
# 换源
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple/
# 装魔搭
pip install modelscope
# 下载 Gemma4 并检验
modelscope download --model google/gemma-4-E4B-it --cache_dir "./models"
ls -lh ./models/google/gemma-4-E4B-it/

启动 vLLM 服务

# 更新云环境中的 vLLM 版本
uv pip uninstall torchvision torchaudio # 经测试,在该云环境中,需卸载重新安装这个库才能正常使用
uv pip install vllm torchvision torchaudio \
  --no-cache \
  --index-url https://mirrors.aliyun.com/pypi/simple/ \
  --extra-index-url https://wheels.vllm.ai/rocm/ \
  -U

vllm serve ./models/google/gemma-4-E4B-it/ --served-model-name gemma-4-E4B-it # 可以设置最大上下文长度 --max-model-len 8192

# 对话测试, 注意需要开新终端
vllm chat --url http://localhost:8000/v1 --model gemma-4-E4B-it

3eff00c4-8fb2-482e-9fa5-f9bcc7b0dcee

posted @ 2026-06-13 23:56  520Enterprise  阅读(3)  评论(0)    收藏  举报