conda-forge / mpich-feedstock

A conda-smithy repository for mpich.
BSD 3-Clause "New" or "Revised" License
2 stars 26 forks source link

mpicc and mpic++ unusable #31

Closed ChristopherHogan closed 5 years ago

ChristopherHogan commented 5 years ago

Issue: When I create a conda environment with the latest mpich package I get an error on Ubuntu 16.04 when trying to run mpic++ or mpicc:

$ conda create -n mpi -c conda-forge mpich
$ source activate mpi
$ which mpic++
/home/chris/miniconda3/envs/mpi/bin/mpic++
$ mpic++ -v
mpicxx for MPICH version 3.2.1
/home/chris/miniconda3/envs/mpi/bin/mpic++: line 280: x86_64-conda_cos6-linux-gnu-c++: command not found
$ cat test.cpp
int main() { return 0; }
$ mpic++ test.cpp
/home/chris/miniconda3/envs/mpi/bin/mpic++: line 276: x86_64-conda_cos6-linux-gnu-c++: command not found


Environment (conda list):

``` $ conda list # packages in environment at /home/chris/miniconda3/envs/mpi: # # Name Version Build Channel libgcc-ng 7.3.0 hdf63c60_0 conda-forge libgfortran-ng 7.2.0 hdf63c60_3 conda-forge libstdcxx-ng 7.3.0 hdf63c60_0 conda-forge mpi 1.0 mpich conda-forge mpich 3.2.1 h1c2f66e_1007 conda-forge ```


Details about conda and system ( conda info ):

``` $ conda info active environment : mpi active env location : /home/chris/miniconda3/envs/mpi shell level : 1 user config file : /home/chris/.condarc populated config files : conda version : 4.5.11 conda-build version : not installed python version : 3.6.3.final.0 base environment : /home/chris/miniconda3 (writable) channel URLs : https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/linux-64 https://repo.anaconda.com/pkgs/free/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/pro/linux-64 https://repo.anaconda.com/pkgs/pro/noarch package cache : /home/chris/miniconda3/pkgs /home/chris/.conda/pkgs envs directories : /home/chris/miniconda3/envs /home/chris/.conda/envs platform : linux-64 user-agent : conda/4.5.11 requests/2.18.4 CPython/3.6.3 Linux/4.15.0-43-generic ubuntu/16.04 glibc/2.23 UID:GID : 1000:1000 netrc file : None offline mode : False ```
minrk commented 5 years ago

the mpich package only depends on its runtime requirements. To use the mpi compilers you also need the conda compiler package:

conda install gxx-linux_64

I've been meaning to add mpich-mpicc, etc. compiler metapackages that would be empty packages depending on mpich and the compilers.

ChristopherHogan commented 5 years ago

I see. I guess I'll have to update my recipes to use the anaconda compilers. Thanks for the info.

minrk commented 5 years ago

Yes. This is part of the migration to packaged compilers for better portability which completed earlier this month.

If you are making a conda recipe that compiles with mpicc/mpicxx, you would want these in your requirements:

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
  host:
    - mpich

which should install the right compiler on any platform.

rainwoodman commented 5 years ago

@minrk To clarify, did you mean that if I use {{ compiler('c') }} and host: mpich, then the build environment will use mpicc as cc?

I am asking because I'd like to rebuild our channel against conda-forge's mpich / mpi4py.

minrk commented 5 years ago

Use of mpi compilers would not necessarily be automatic, depending on the build system of the given package. That's just the requirement to get everything compilers available and on PATH. To use the mpi compilers by default, you would need to set the appropriate env in build.sh:

export CC=mpicc
export CXX=mpic++
export FC=mpifort

or pass the appropriate args directly to your build input (e.g. sometimes mpi compiler and C compiler are specified separately in the same build).