← BACK TO BLOG

LiveTalking安装记录

LiveTalking 实时数字人项目的安装记录,重点记录 CUDA 与 PyTorch 版本不匹配等依赖问题的排查与解决。

次阅读

仓库

https://github.com/lipku/LiveTalking

问题

1. CUDA 版本(11.8)与用于编译 PyTorch 的版本(12.4)不匹配

code
    File "/venv/LiveTalking/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 79, in run
      _build_ext.run(self)
    File "/venv/LiveTalking/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 339, in run
      self.build_extensions()
    File "/venv/LiveTalking/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 520, in build_extensions
      _check_cuda_version(compiler_name, compiler_version)
    File "/venv/LiveTalking/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 415, in _check_cuda_version
      raise RuntimeError(CUDA_MISMATCH_MESSAGE.format(cuda_str_version, torch.version.cuda))
  RuntimeError:
  The detected CUDA version (11.8) mismatches the version that was used to compile
  PyTorch (12.4). Please make sure to use the same CUDA versions.

解决:

  • 查看当前pytorch版本conda list | grep torch

    bash
    (LiveTalking) root@C.22771731:/workspace$ conda list | grep torch
    pytorch                   2.5.0           py3.10_cuda12.4_cudnn9.1.0_0    pytorch
    pytorch-cuda              12.4                 hc786d27_7    pytorch
    pytorch-mutex             1.0                        cuda    pytorch
    torch-ema                 0.3                      pypi_0    pypi
    torchaudio                2.5.0               py310_cu124    pytorch
    torchtriton               3.1.0                     py310    pytorch
    torchvision               0.20.0              py310_cu124    pytorch
  • 因为我当前CUDA是11.8,需要到https://pytorch.org/get-started/previous-versions/找到与之适配的PyTorch版本,重新安装来替换掉12.4版本的pytorch-cuda

  • 卸载现有的 pytorch-cuda conda uninstall pytorch pytorch-cuda pytorch-mutex

  • 重新安装适配版本pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url [https://download.pytorch.org/whl/cu116](https://download.pytorch.org/whl/cu116) --resume-retries 5

2. 因网络导致下载中断

bash
(LiveTalking) root@C.22771731:/workspace$ pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118
Looking in indexes: https://download.pytorch.org/whl/cu118
Collecting torch==2.5.1
  Downloading https://download.pytorch.org/whl/cu118/torch-2.5.1%2Bcu118-cp310-cp310-linux_x86_64.whl (838.3 MB)
     ━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━ 251.9/838.3 MB 115.1 MB/s eta 0:00:06
  WARNING: Connection timed out while downloading.
error: incomplete-download

× Download failed because not enough bytes were received (251.9 MB/838.3 MB)
╰─> URL: https://download.pytorch.org/whl/cu118/torch-2.5.1%2Bcu118-cp310-cp310-linux_x86_64.whl#sha256=eee38239682a01ab02d3790fe194753f7070f07e1741e67fb5c3c3059d3b97b2

note: This is an issue with network connectivity, not pip.
hint: Consider using --resume-retries to enable download resumption.

用pip安装依赖时报如上错,可以在命令中加入--resume-retries 并指定重试次数,这样网络抖动就会自动重试。例:pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url [https://download.pytorch.org/whl/cu118](https://download.pytorch.org/whl/cu118) --resume-retries 5

3. 安装MMLab报错

安装文档中要求执行下列命令安装

bash
pip install --no-cache-dir -U openmim 
mim install mmengine 
mim install "mmcv>=2.0.1" 
mim install "mmdet>=3.1.0" 
mim install "mmpose>=1.1.0"

但随着mmcv mmdet mmpose 三个库版本的更新,后续版本可能与当前环境有冲突,为确保版本锁定应使用下面的命令,注意版本用==不是用>=

bash
pip install --no-cache-dir -U openmim
mim install mmengine
mim install "mmcv==2.0.1"
mim install "mmdet==3.1.0"
mim install "mmpose==1.1.0"

4. 缺少cmake

bash
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
triton 2.0.0 requires cmake, which is not installed.

解决:pip install cmake