2

I installed openmpi v4.1.6 (and dependencies) to a clean environment using anaconda conda-forge channel. After installing and attempting to compile, I get the error

--------------------------------------------------------------------------
The Open MPI wrapper compiler was unable to find the specified compiler
x86_64-apple-darwin13.4.0-clang in your PATH.

Note that this compiler was either specified at configure time or in
one of several possible environment variables.
--------------------------------------------------------------------------

After some additional digging, $ mpicc --showme reveals x86_64-apple-darwin13.4.0-clang has been chosen as the C compiler, except this is the wrong clang version! $ clang --version returns

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

This can be fixed by exporting the variable OMPI_CC=clang or OMPI_CC=gcc, although the openmpi documentation seems to strongly discourage this, or at least implies this shouldn't be necessary.

Where is openmpi getting this compiler information from? Why is it linking to a C compiler that no longer exists and can I change this default behavior?

Installing the latest version of openmpi using conda is successful, but links to the wrong C compiler.

$ mpicc --showme
x86_64-apple-darwin13.4.0-clang -I/Users/ericvc/opt/anaconda3/envs/fargo-workshop/include -I/Users/ericvc/opt/anaconda3/envs/fargo-workshop/include -L/Users/ericvc/opt/anaconda3/envs/fargo-workshop/lib -L/Users/ericvc/opt/anaconda3/envs/fargo-workshop/lib -Wl,-rpath,/Users/ericvc/opt/anaconda3/envs/fargo-workshop/lib -lmpi

$ clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

$ which -a clang
/usr/bin/clang

openmpi won't compile and run anything until I change the OMPI_CC variables

$ export OMPI_CC=gcc

but I need to do this each time I open a new bash profile (plus this is a work around that really shouldn't be necessary imo)


EDIT:

Big thank you to Dmitry for helping me through this. I created some test environments, because I've found that installing gfortran from conda-forge solves the issue.

I created three python enviornments, one where I installed only openmpi, one where I first installed clang using conda-forge, and one where I first installed gfortran using conda-forge. The results are below, where I've left off the long installation info from anaconda.

(base) $ conda create -n onlympi python
(base) $ conda activate onlympi
(onlympi) $ conda install -c conda-forge openmpi
(onlympi) $ mpicc --showme
x86_64-apple-darwin13.4.0-clang -I/Users/ericvc/opt/anaconda3/envs/onlympi/include -I/Users/ericvc/opt/anaconda3/envs/onlympi/include -L/Users/ericvc/opt/anaconda3/envs/onlympi/lib -L/Users/ericvc/opt/anaconda3/envs/onlympi/lib -Wl,-rpath,/Users/ericvc/opt/anaconda3/envs/onlympi/lib -lmpi
(onlympi) $ echo $CC

(onlympi) $ which x86_64-apple-darwin13.4.0-clang
x86_64-apple-darwin13.4.0-clang not found
(base) $ conda create -n clang-first python
(base) $ conda activate clang-first
(clang-first) $ conda install -c conda-forge clang
(clang-first) $ conda install -c conda-forge openmpi
(clang-first) $ mpicc --showme
x86_64-apple-darwin13.4.0-clang -I/Users/ericvc/opt/anaconda3/envs/clang-first/include -I/Users/ericvc/opt/anaconda3/envs/clang-first/include -L/Users/ericvc/opt/anaconda3/envs/clang-first/lib -L/Users/ericvc/opt/anaconda3/envs/clang-first/lib -Wl,-rpath,/Users/ericvc/opt/anaconda3/envs/clang-first/lib -lmpi
(clang-first) $ echo $CC

(clang-first) $ which x86_64-apple-darwin13.4.0-clang
x86_64-apple-darwin13.4.0-clang not found
(base) $ conda create -n gfortran-first python
(base) $ conda activate gfortran-first
(gfortran-first) $ conda install -c conda-forge gfortran
(gfortran-first) $ conda install -c conda-forge openmpi
(gfortran-first) $ mpicc --showme
x86_64-apple-darwin13.4.0-clang -I/Users/ericvc/opt/anaconda3/envs/gfortran-first/include -I/Users/ericvc/opt/anaconda3/envs/gfortran-first/include -L/Users/ericvc/opt/anaconda3/envs/gfortran-first/lib -L/Users/ericvc/opt/anaconda3/envs/gfortran-first/lib -Wl,-rpath,/Users/ericvc/opt/anaconda3/envs/gfortran-first/lib -lmpi
(gfortran-first) $ echo $CC
x86_64-apple-darwin13.4.0-clang
(gfortran-first) $ which x86_64-apple-darwin13.4.0-clang
/Users/ericvc/opt/anaconda3/envs/gfortran-first/bin/x86_64-apple-darwin13.4.0-clang

As you can see, all three enviornments use the same C compiler for openmpi, but only when I install gfortran does this compiler exist in the enviornment.

gfortran has a lot of dependencies that are installed, I'll include them here. Of particular interest are likely the clang packages that are installed with gfortran but no otherwise: clang_impl_osx-64 and clang_osx-64

$ conda install -c conda-forge clang
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/ericvc/opt/anaconda3/envs/clang-first

  added / updated specs:
    - clang


The following NEW packages will be INSTALLED:

  clang              conda-forge/osx-64::clang-17.0.6-hac416ee_2
  clang-17           conda-forge/osx-64::clang-17-17.0.6-default_h6b1ee41_2
  icu                conda-forge/osx-64::icu-73.2-hf5e326d_0
  libclang-cpp17     conda-forge/osx-64::libclang-cpp17-17.0.6-default_h6b1ee41_2
  libcxx             conda-forge/osx-64::libcxx-16.0.6-hd57cbcb_0
  libiconv           conda-forge/osx-64::libiconv-1.17-hd75f5a5_2
  libllvm17          conda-forge/osx-64::libllvm17-17.0.6-hbedff68_1
  libxml2            conda-forge/osx-64::libxml2-2.12.4-hc0ae0f7_1
  zstd               conda-forge/osx-64::zstd-1.5.5-h829000d_0
$ conda install -c conda-forge gfortran
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/ericvc/opt/anaconda3/envs/gfortran-first

  added / updated specs:
    - gfortran


The following NEW packages will be INSTALLED:

  cctools            conda-forge/osx-64::cctools-973.0.1-h5b2de21_15
  cctools_osx-64     conda-forge/osx-64::cctools_osx-64-973.0.1-h031c385_15
  clang              conda-forge/osx-64::clang-17.0.6-hac416ee_2
  clang-17           conda-forge/osx-64::clang-17-17.0.6-default_h6b1ee41_2
  clang_impl_osx-64  conda-forge/osx-64::clang_impl_osx-64-17.0.6-h1af8efd_8
  clang_osx-64       conda-forge/osx-64::clang_osx-64-17.0.6-hb91bd55_8
  clangxx            conda-forge/osx-64::clangxx-17.0.6-default_h6b1ee41_2
  compiler-rt        conda-forge/osx-64::compiler-rt-17.0.6-ha38d28d_1
  compiler-rt_osx-64 conda-forge/noarch::compiler-rt_osx-64-17.0.6-ha38d28d_1
  gfortran           conda-forge/osx-64::gfortran-13.2.0-h2c809b3_1
  gfortran_impl_osx~ conda-forge/osx-64::gfortran_impl_osx-64-13.2.0-h7643cbd_1
  gfortran_osx-64    conda-forge/osx-64::gfortran_osx-64-13.2.0-h18f7dce_1
  gmp                conda-forge/osx-64::gmp-6.3.0-h93d8f39_0
  icu                conda-forge/osx-64::icu-73.2-hf5e326d_0
  isl                conda-forge/osx-64::isl-0.25-hb486fe8_0
  ld64               conda-forge/osx-64::ld64-609-h0a3eb4e_15
  ld64_osx-64        conda-forge/osx-64::ld64_osx-64-609-hd3532be_15
  libclang-cpp17     conda-forge/osx-64::libclang-cpp17-17.0.6-default_h6b1ee41_2
  libcxx             conda-forge/osx-64::libcxx-16.0.6-hd57cbcb_0
  libgfortran        conda-forge/osx-64::libgfortran-5.0.0-13_2_0_h97931a8_1
  libgfortran-devel~ conda-forge/noarch::libgfortran-devel_osx-64-13.2.0-h80d4556_1
  libgfortran5       conda-forge/osx-64::libgfortran5-13.2.0-h2873a65_1
  libiconv           conda-forge/osx-64::libiconv-1.17-hd75f5a5_2
  libllvm17          conda-forge/osx-64::libllvm17-17.0.6-hbedff68_1
  libxml2            conda-forge/osx-64::libxml2-2.12.4-hc0ae0f7_1
  llvm-openmp        conda-forge/osx-64::llvm-openmp-17.0.6-hb6ac08f_0
  llvm-tools         conda-forge/osx-64::llvm-tools-17.0.6-hbedff68_1
  mpc                conda-forge/osx-64::mpc-1.3.1-h81bd1dd_0
  mpfr               conda-forge/osx-64::mpfr-4.2.1-h0c69b56_0
  sigtool            conda-forge/osx-64::sigtool-0.1.3-h88f4db0_0
  tapi               conda-forge/osx-64::tapi-1100.0.11-h9ce4665_0
  zlib               conda-forge/osx-64::zlib-1.2.13-h8a1eda9_5
  zstd               conda-forge/osx-64::zstd-1.5.5-h829000d_0

tl;dr incase anyone finds themselves here with the same problem: install gfortran. This will make conda set the correct C compiler for the enviornment.

1 Answer 1

1

If you installed openmpi using Conda from conda-forge channel, then the C compiler looks good to me because conda uses its own compilers: under Linux it is gcc and under macOS it is clang. However, as you can see, their names are more complicated and encode information about the platform (operating system).

For example, I work in Linux and in a conda environment which depends on a C compiler, the actual C compiler is path-to-the-conda-environment/bin/x86_64-conda-linux-gnu-cc.

To change the actual C compiler, Conda sets the CC environment variable and that's why openmpcc points not simply to clang in your case but to x86_64-apple-darwin13.4.0-clang. You can check it by executing in the shell command echo $CC. CC stands for "C compiler" and basically all build tools respect the value of this environment variable if it is set.

The question is, why the actual C compiler cannot be found in PATH.

Did you activate the Conda environment in which openmpi is installed?

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks for the response! This is interesting. In my base enviornment, I have a bunch of conda-dir/bin/x86_64-apple-darwin13.4.0-* files, but no conda-dir/bin/x86_64-apple-darwin13.4.0-clang. echo $CC returns nothing. In this new enviornment I do not have any conda-dir/envs/conda-enviornment/bin/x86_64* and echo $CC returns nothing. I typically use /usr/bin/gcc for c-compiling. Perhaps a conflict there?
I did find a file: path-to-conda-env/share/openmpi/mpicc-wrapper-data.txt. For now I've edited that file to point to a C compiler that works (for me, /usr/bin/gcc), although it's curious my conda C compiler is not pointing to the right place.
What is conda-dir? Can you execute which x86_64-apple-darwin13.4.0-clang and see where the compiler is located? Also, after you activate conda environment, can you print the $PATH (echo $PATH | tr : "\n") and see that the directory from the which command is in the $PATH?
(base) $ which x86_64-apple-darwin13.4.0-clang gives x86_64-apple-darwin13.4.0-clang not found. (fargo-workshop) $ which x86_64-apple-darwin13.4.0-clang also returns x86_64-apple-darwin13.4.0-clang not found.
Thanks for all your help, I recreated the environment and mpicc is working correctly now. Something must have gone wrong when I downloaded before. I'll run some tests to try and track down the problem in the future, but for now I have a working enviornment
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.