Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: libmpi.so.12: cannot open shared object file: No such file or directory #11

Open
zsn2021 opened this issue May 6, 2022 · 3 comments

Comments

@zsn2021
Copy link

zsn2021 commented May 6, 2022

System: Ubuntu 18 04
Compiler: PyCharm
There was a problem installing the dependency package mpi4py==3.0.2
Does anyone have a similar problem? How to solve it?

@Novice-me
Copy link

Solution:

  1. Check if any MPI library is installed (e.g. MPICH, OPENMPI), if not, you can install OPENMPI by referring to the following tutorial from Microsoft
    https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-CNTK-on-Linux#open-mpi
  2. After the installation is complete, you can use the following command to locate libmpi.so.12
    sudo find ./ -name libmpi.so.12
  3. Usually, the problem has been solved and you can install the mpi4py library. But if you are using Anaconda or other virtual env, you also need to copy libmpi.so.12 to the lib folder of env

@xuedingebuaimao
Copy link

I directly used the command "conda install mpi4py", which installed the following packages.

The following NEW packages will be INSTALLED:

ipykernel anaconda/pkgs/main/linux-64::ipykernel-6.9.1-py37h06a4308_0
mpi anaconda/pkgs/main/linux-64::mpi-1.0-mpich
mpi4py anaconda/pkgs/main/linux-64::mpi4py-3.1.4-py37hfc96bbd_0
mpich anaconda/pkgs/main/linux-64::mpich-3.3.2-external_0

Then I ran "from mpi4py import MPI" and got the ImportError. Initially, I found there was no "libmpi.so.12" in my conda env's lib folder, which I thought corresponds to the 3rd point you mentioned, so I copied it from pkgs/... and now have the following "libmpi.so.12"

/home/nico/anaconda3/lib/libmpi.so.12
/home/nico/anaconda3/envs/condavenv1/lib/libmpi.so.12
/home/nico/anaconda3/pkgs/mpich-3.3.2-hc856adb_0/lib/libmpi.so.12

but still get the same error.

@wfc1102
Copy link

wfc1102 commented Mar 25, 2024

Same error here:
from mpi4py import MPI
ImportError: libmpi.so.12: cannot open shared object file: No such file or directory

conda install -c conda-forge mpi4py
conda install mpi4py

conda uninstall mpi4py
pip uninstall mpi4py

install and uninstall several times does not work. When conda uninstall it shows:

mpi-1.0-mpich
mpi4py-3.1.4-py38hfc96bbd_0
mpich-3.3.2-external_0

Before give up, I tried

pip install mpi4py

Successfully installed mpi4py-3.1.5
My program runs smoothly. It seems the mpi4py version matters. conda install differs from pip install by selecting different version at this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants