解决MPICH的GPU初始化失败:一次深入探索

今天来分享“MPICH:MPII_Init_thread(222): gpu_init failed”这个问题的解决方式

解决MPICH的GPU初始化失败:一次深入探索_第1张图片

文章目录

    • 前言
    • 问题原因
    • 解决方案

前言

如果在安装MPICH的时候没有注意要一些选项,那么当使用mpicxx mpi_send.cpp -o send && mpirun -n 2 ./send进行编译输出的时候,就会得到一段报错:MPICH:MPII_Init_thread(222): gpu_init failed
这个问题在国内外没有一个人指出答案,希望后续有人搜到,能够帮助到你。

问题原因

这个问题在于,我们在安装MPICH的时候,如果我们安装了CUDA或者HIP,那么MPICH它对于GPU是默认自动启动支持的。

回顾文档,重要的安装细节包括:

GPU support is automatically enabled if CUDA, ZE, or HIP runtime is
detected during configure. To specify where your GPU runtime is
installed, use:--with-cuda= or --with-ze= or --with-hip=

(我认为在这要指定是因为cuda这些安装不是正常位置,安装程序没有找到)

If the lib/ and include/ are not in the same path, both can be specified
separately, for example: --with-cuda-include= and --with-cuda-lib=

In addition, GPU support can be explicitly disabled by using:--without-cuda or --without-ze or --without-hip

(如果当初加了这个指令,那么安装后就不会自动启用GPU支持了。这里是产生问题的根本原因)

解决方案

如果没有注意到上面,默认就启动了GPU支持。只要程序没有关于GPU相关的调用函数,就会报错。那么如何挽救呢?难道重装吗?
不用不用,只要设置一个环境变量即可:MPIR_CVAR_ENABLE_GPU=0

你可能感兴趣的:(高性能计算,mpich,高性能计算,gpu,cpu,c++)