系统:Ubuntu 22.04
安装 Python 版本 3.10 到 3.12
创建虚拟环境
1. 安装 Python 和 venv(如果未安装)
sudo apt update
sudo apt install python3 python3-venv # 确保安装 Python 和 venv 模块
2. 创建虚拟环境
gpustack是虚拟环境目录名,可自定义
python3 -m venv gpustack
3. 激活虚拟环境
source gpustack/bin/activate
4. 退出虚拟环境
deactivate
安装 GPUStack
# You can add extra dependencies, options are "vllm", "audio" and "all".
# e.g., gpustack[all]
pip install gpustack
验证
gpustack version
启动 GPUStack 服务器
root用户权限启动
gpustack start
将 GPUStack 作为系统服务运行
创建服务文件
sudo nano /etc/systemd/system/gpustack.service
内容
[Unit]
Description=GPUStack Service
Wants=network-online.target
After=network-online.target
[Service]
EnvironmentFile=-/etc/default/%N
ExecStart=gpustack start
Restart=always
RestartSec=3
StandardOutput=append:/var/log/gpustack.log
StandardError=append:/var/log/gpustack.log
[Install]
WantedBy=multi-user.target
- 保存并退出编辑器(在 nano 中按 Ctrl+X,然后按 Y,最后按 Enter)
- 创建日志文件并设置权限
sudo touch /var/log/gpustack.log sudo chown root:root /var/log/gpustack.log sudo chmod 644 /var/log/gpustack.log
- 重新加载 systemd 配置
sudo systemctl daemon-reload
- 启用并启动服务
sudo systemctl enable gpustack.service sudo systemctl start gpustack.service
- 验证服务状态
sudo systemctl status gpustack.service
-
其他有用命令
查看服务日志
journalctl -u gpustack.service -f
停止服务:
sudo systemctl stop gpustack.service
禁用服务(开机不自动启动):
sudo systemctl disable gpustack.service
没有回复内容