Ubuntu 22.04完整安装Xinference及解决依赖报错

注:文中使用的环境为Ubuntu 22.04 LTS + CUDA 12.4.1

1、创建conda环境

shell 复制代码
conda create -n xinference python==3.11 -y
conda activate xinference

2、安装Xinference

shell 复制代码
pip install "xinference[all]"

3、解决报错

Pytorch报错

根据Pytorch安装指引进行安装,重新执行命令即可。注意,一定要在Pytorch网站上按照你的系统和CUDA版本等选择。使用pip即可。例:

shell 复制代码
pip3 install torch torchvision torchaudio
pip install "xinference[all]"

llama-cpp-python报错

当报错ERROR: Failed building wheel for llama-cpp-python时,需要手动修补环境并重新安装llama-cpp-python。这个问题比较复杂。按步骤操作即可修复:

  • 修复构建工具链

    shell 复制代码
    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    sudo apt update
    sudo apt install gcc-11 g++-11
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 60 --slave /usr/bin/g++ g++ /usr/bin/g++-11
    pip install --upgrade pip
    pip install --upgrade setuptools wheel
    sudo apt-get install build-essential
    sudo apt-get install libgomp1
  • 检查并更新环境变量

    shell 复制代码
    export PATH=/usr/local/cuda-12.4/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:/usr/local/cuda-12.4/extras/CUPTI/lib64:/usr/local/cuda-12.4/targets/x86_64-linux/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
  • 重新安装

    shell 复制代码
    # CPU推理
    pip install llama-cpp-python --verbose
    # N卡推理
    CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 pip install --upgrade --force-reinstall llama-cpp-python==0.2.57 --no-cache-dir --verbose
    pip install "xinference[all]"
相关推荐
Alex-Leung2 小时前
VMware虚拟机 ubuntu22.04无法与共享粘贴板和拖拽文件的解决方案
ubuntu·vmware·ubuntu22.04·vmware-tools
漠北尘-Gavin5 小时前
【Python3.12.9安装llama-cpp-python遇到编译报错问题解决】
python·llama
小安运维日记6 小时前
CKS认证 | Day3 K8s容器运行环境安全加固
运维·网络·安全·云原生·kubernetes·云计算
我是唐青枫6 小时前
Linux ar 命令使用详解
linux·运维·服务器
mljy.6 小时前
Linux《进程概念(上)》
linux
IEVEl6 小时前
Centos7 开放端口号
linux·网络·centos
我要升天!7 小时前
Linux中《环境变量》详细介绍
linux·运维·chrome
MobiCetus7 小时前
有关pip与conda的介绍
linux·windows·python·ubuntu·金融·conda·pip
Wnq100728 小时前
DEEPSEEK创业项目推荐:
运维·计算机视觉·智能硬件·ai创业·deepseek
开发小能手-roy8 小时前
ubuntu 安装mysql
mysql·ubuntu·adb