关于Xinference 中部署服务不能成功的若干问题整理(持续迭代)
背景:
能够成功部署安装并在浏览器访问Xinference,但在部署模型中容易报各种错误,导致莫名的是吧,又不懂如何修复
问题
部署rerank model 模型时报错
Due to a serious vulnerability issue in `torch.load`, even with `weights_only=True`, we now require users to upgrade torch to at least v2.6 in order to use the function. This version restriction does not apply when loading files with safetensors.
解决方案:
思路:
PyTorch 2.6.0版本针对torch.load
函数的安全漏洞进行了强制修复,要求用户必须升级至v2.6及以上版本才能使用该功能。该漏洞涉及反序列化安全问题,即使设置了weights_only=True
参数仍存在风险,因此新版通过版本限制强制修复了此问题 。
操作:
1、报错信息截图
2、查看当前pytorch 版本,执行下面命令“python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())",可见刚好处于有问题的2.5.x系列。
3、通过命令“pip uninstall torch torchvision torchaudio” 下载当前的2.5.x
4、通过命令“”查看是否成功卸载pytorch,如下截图表示卸载成功。
5、卸载完成后我们需要下载与自己环境适配的2.6.x 以上版本,访问https://pytorch.org/get-started/locally/ https://pytorch.org/get-started/locally/
2、根据上面网站的配置结合自己的服务配置选择后复制“Run this Command”中的命令在Anaconda Prompt 环境对话框中执行
3、安装完成后使用命令“python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())” 查看版本,如果有版本号出现并且有一个“True”那么证明当前版本可以完美适配你电脑中的显卡(切记本文是英伟达显卡)
4、执行命令“xinference-local --host 127.0.0.1 --port 9997” 重新启动xinference 进行服务安装
5、在网页端进行重新部署应该能够成功