X AMD Hello ROCm 学习 Day1
2026/7/3 13:34:10 网站建设 项目流程

1、登录AMD 平台https://radeon.anruicloud.com/

2、选择Hello ROCm Bate,launch并打开notebook。

3、打开terminal

4、检查环境是否可用

amd-smi #检查GPU是否可用
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')" #检查 PyTorch 是否能识别 AMD GPU

5、下载Gemma4 模型

先切换到国内镜像

pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple/

安装modelscope

pip install modelscope

下载 Gemma4 模型到当前目录

modelscope download --model google/gemma-4-E4B-it --cache_dir "./models"

出现这个即为下载成功

Snapshot ready at models/models/google--gemma-4-E4B-it/snapshots/master

注意这个文件地址,根据你的文件地址按需替换。

确认下载完成

ls -1h models/models/google--gemma-4-E4B-it/snapshots/master

6、启动 vLLM 服务

vLLM 是一个本地高效推理大模型的项目,这里我们使用vLLM来测试刚才下载的模型能否正常使用。

在使用 vLLM 前,需更新云环境中的 vLLM 版本才能运行 Gemma4 模型。

uv pip uninstall torchvision torchaudio # 经测试,在该云环境中,需卸载重新安装这个库才能正常使用 uv pip install 'vllm==0.24.0+rocm723' torchvision torchaudio 'fastapi[standard]==0.136.0' \ --no-cache \ --index-url https://mirrors.aliyun.com/pypi/simple/ \ --extra-index-url https://wheels.vllm.ai/rocm/ \ -U

启动

vllm serve models/models/google--gemma-4-E4B-it/snapshots/master --served-model-name gemma-4-E4B-it

注意:运行这个命令后,这个终端窗口就会被大模型服务“死死占满”。请保持运行,绝对不要关闭它,也不要按Ctrl+C,否则大模型服务就会立刻停止。

7、打开新终端进行对话测试

打开新终端后,与Gemma4开启对话

vllm chat --url http://localhost:8000/v1 --model gemma-4-E4B-it
你是谁,你能做什么

8、如果需要对模型进行微调,记得使用ctrl+c终止上一个终端,停止vLLM服务。

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询