You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Google Colab中安装Horovod失败求助:Wheel编译报错

Horovod安装失败问题排查

我尝试过多种Horovod版本的安装命令,包括:

!pip install horovod==0.26.1

以及:

!HOROVOD_WITH_TENSORFLOW=1 pip install horovod[tensorflow] --no-cache-dir horovod

但每次都会出现相同的错误:

Collecting horovod==0.15.0
  Downloading horovod-0.15.0.tar.gz (113 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 113.2/113.2 kB 2.8 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: cffi>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from horovod==0.15.0) (1.16.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.10/dist-packages (from cffi>=1.4.0->horovod==0.15.0) (2.21)
Building wheels for collected packages: horovod
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for horovod (setup.py) ... error
  ERROR: Failed building wheel for horovod
  Running setup.py clean for horovod
Failed to build horovod
ERROR: Could not build wheels for horovod, which is required to install pyproject.toml-based projects

请问我操作哪里出错了?是pip出现问题了吗?


问题分析与解决步骤

  1. 核心原因:编译依赖缺失 + 版本约束冲突
    错误日志显示实际安装的是horovod==0.15.0,而非你指定的0.26.1,说明环境中存在旧版本依赖约束,强制拉取了低版本。同时Horovod源码编译需要OpenMPI、CUDA(GPU环境)等底层库,缺失这些会导致编译失败,这不是pip本身的问题。

  2. 具体解决方法

  • 安装编译依赖(以Ubuntu为例):

    sudo apt-get install -y openmpi-bin openmpi-common libopenmpi-dev build-essential
    

    GPU环境需确保CUDA、CuDNN已正确安装,CUDA_HOME等环境变量配置生效。

  • 清理残留并重新安装指定版本
    先卸载所有Horovod相关包,再明确指定版本安装:

    pip uninstall -y horovod
    pip install --no-cache-dir horovod==0.26.1 tensorflow
    

    若需绑定TensorFlow并启用GPU加速,设置环境变量后安装:

    HOROVOD_WITH_TENSORFLOW=1 HOROVOD_GPU_OPERATIONS=NCCL pip install --no-cache-dir horovod[tensorflow]==0.26.1
    
  • 使用预编译包避免源码编译
    优先选择Horovod提供的预编译wheel包,跳过源码编译步骤:

    pip install horovod[tensorflow] --no-cache-dir
    

内容的提问来源于stack exchange,提问作者MarcosP

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 04:10:25