xinference
github官网:https://github.com/xorbitsai/inference
readme:https://github.com/xorbitsai/inference/blob/main/README_zh_CN.md
准备工作
Xinference 使用 GPU 加速推理,该镜像需要在有 GPU 显卡并且安装 CUDA 的机器上运行。
保证 CUDA 在机器上正确安装。可以使用 nvidia-smi 检查是否正确运行。
镜像中的 CUDA 版本为 12.4 。为了不出现预期之外的问题,请将宿主机的 CUDA 版本和 NVIDIA Driver 版本分别升级到 12.4 和 550 以上。
mvidia-smi版本不够,升级
wget https://cn.download.nvidia.cn/XFree86/Linux-x86_64/550.54.14/NVIDIA-Linux-x86_64-550.54.14.run
/bin/sh NVIDIA-Linux-x86_64-550.54.14.run
按图形提示去安装升级nvidia驱动
最后安装完成后需要重启系统才能生效
docker安装:
在执行安装命令之前,确保你的系统中已经安装了 Docker 和 CUDA
https://inference.readthedocs.io/zh-cn/latest/getting_started/using_docker_image.html
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
vi /etc/yum.repos.d/docker-ce.repo
sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
yum -y install docker-ce
systemctl status docker
docker启动命令:
docker run -d \
--name xinference \
-v /xinference/data/.xinference:/root/.xinference \
-v /xinference/data/.cache/huggingface:/root/.cache/huggingface \
-v /xinference/data/.cache/modelscope:/root/.cache/modelscope \
-v /xinference/log:/workspace/xinference/logs \
-e XINFERENCE_HOME=/xinference \
-p 9997:9997 \
--gpus all \
registry.cn-hangzhou.aliyuncs.com/xprobe_xinference/xinference:latest \
xinference-local -H 0.0.0.0 --log-level debug
docker启动如果报错:could not select device driver ““ with capabilities: [[gpu]]
解决关于Docker运行容器使用GPU资源时的异常:Error response from daemon: could not select device driver ““ with capabilities: [[gpu]]
–gpus all参数说明:运行容器的时候调用本机的GPU
1.检查GPU设备驱动程序:nvidia-smi
2.Installing the NVIDIA Container Toolkit — NVIDIA Container Toolkit 1.16.0 documentation
3.配置容器运行时nvidia-ctk
nvidia-ctk runtime configure --runtime=docker
{
"registry-mirrors": [],
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
}
}
4.重新启动 Docker 守护进程
systemctl restart docker