Ubuntu 22.04下OpenMPI无法运行,仅显示hwloc相关警告无报错
解决Ubuntu 22.04LTS上mpirun/mpiexec因hwloc PCI域警告卡住的问题
问题概述
在Ubuntu 22.04LTS(Linux内核5.14.0-1051-oem)上运行mpirun、mpiexec或hwloc-info时,会弹出如下警告:
hwloc/linux: Ignoring PCI device with non-16bit domain.
Pass --enable-32bits-pci-domain to configure to support such devices
(warning: it would break the library ABI, don't enable unless really needed).
之后程序卡住,仅显示闪烁光标,硬件监控无后台进程运行。重装OpenMPI(sudo apt-get -y autoremove --purge openmpi-bin)无法解决,OpenFOAM单进程运行正常。
解决方案
方案1:临时/永久禁用hwloc的PCI设备扫描
这是最快捷的临时解决方法,跳过hwloc对PCI设备的检测,直接规避问题:
- 临时生效:运行命令前添加环境变量
HWLOC_COMPONENTS=-pci mpirun -np [进程数] [你的OpenFOAM命令] - 永久生效:将环境变量写入bash配置文件
echo 'export HWLOC_COMPONENTS=-pci' >> ~/.bashrc source ~/.bashrc
方案2:从源码编译hwloc和OpenMPI,启用32位PCI域支持
如果你的并行程序依赖硬件拓扑信息(必须扫描PCI设备),可以采用此方案:
- 卸载系统自带的相关包
sudo apt purge -y hwloc libhwloc-dev openmpi-bin openmpi-common libopenmpi-dev - 编译安装带32位PCI域支持的hwloc
# 下载hwloc源码(以2.9.0稳定版为例) wget https://download.open-mpi.org/release/hwloc/v2.9/hwloc-2.9.0.tar.gz tar xzf hwloc-2.9.0.tar.gz cd hwloc-2.9.0 ./configure --enable-32bits-pci-domain make -j$(nproc) sudo make install - 编译安装依赖新hwloc的OpenMPI
# 下载OpenMPI源码(以4.1.5稳定版为例) wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.5.tar.gz tar xzf openmpi-4.1.5.tar.gz cd openmpi-4.1.5 ./configure --with-hwloc=/usr/local make -j$(nproc) sudo make install sudo ldconfig
方案3:升级系统内核
你当前使用的是OEM定制内核,可能存在PCI域处理的兼容性问题。尝试升级到Ubuntu官方稳定内核:
sudo apt update sudo apt install linux-generic sudo reboot
重启后使用新内核运行mpirun,查看问题是否消失。
为什么重装OpenMPI没用?
系统通过apt安装的OpenMPI和hwloc是预编译包,默认未启用--enable-32bits-pci-domain选项,重装后依然使用相同的预编译文件,因此无法解决PCI域不兼容导致的卡住问题。
内容的提问来源于stack exchange,提问作者x.y.z liu
相关产品推荐
相关产品推荐

