Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 7

Install OpenMPI during GitHub Action

Solved! Go to Solution.

Hello,

since I made more commits to fix my workflow than for my entire project, I'd appreciate some help.

I need to install OpenMPI before compiling my C project; here's my workflow file:

 

name: C CI

on: [push]

jobs:
  openmpi:
    runs-on: ubuntu-latest
    env:
      TOKEN: ${{ secrets.TOKEN }}
    steps:
    - name: download-openmpi
      run: wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.2.tar.gz
    - name: extract-openmpi
      run: tar -xvf ./openmpi-4.0.2.tar.gz
    - name: configure-openmpi
      run: ./openmpi-4.0.2/configure --prefix="/home/${USER}/.openmpi"
    - name: install-openmpi
      run: |
        make -j
        sudo make install
  build:
    runs-on: ubuntu-latest
    needs: [openmpi]
    steps:
    - uses: actions/checkout@master
      with:
        fetch_depth: 1
    - name: set-openmpi-path
      run: |
        export PATH=${PATH}:/home/${USER}/.openmpi/bin/
        export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/${USER}/.openmpi/lib/
        echo ${PATH}
        echo ${LD_LIBRARY_PATH}
    - name: make
      env:
        TOKEN: ${{ secrets.TOKEN }}
      run: make

Looks like all environment variables have been properly set and OpenMPI gets compiled and installed; however, in build job, I get the error about the #include "mpi.h" directive.

 

What am I missing?

6 Replies
Highlighted
Solution
GitHub Partner
Message 2 of 7

Re: Install OpenMPI during GitHub Action

According to your workflow, you install OpenMPI and compile your C project in two separate jobs. Needs only deside the execution order of two jobs.  In Github Actions, different jobs will run on different runners, and the different runners are in different VMs. So you will get error when running job build, cause OpenMPI is not installed on that VM.

 

I would recommend you to install OpenMPI and compile your C project in one job.   

Highlighted
Copilot Lvl 2
Message 3 of 7

Re: Install OpenMPI during GitHub Action

I guessed that was the case, despite hoping it didn't work like that.

Thank you anyway, I merged the two jobs and make managed to find the OpenMPI C header.

 

Anyway, is there a way to organize workflows into phases sharing the same environment?

Highlighted
GitHub Partner
Message 4 of 7

Re: Install OpenMPI during GitHub Action

>>Anyway, is there a way to organize workflows into phases sharing the same environment?

Do you want to run different jobs in the same environment? You could specify container for a job, then all steps without specify a container already will be executed in the container. You could create a docker image for your environment . Then use the same image in multiple jobs containers.  

https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainer 

Highlighted
Copilot Lvl 2
Message 5 of 7

Re: Install OpenMPI during GitHub Action

So, if I add

container: ubuntu:latest

to openmpi job, the build one will run on the same environment as openmpi one?

Highlighted
Copilot Lvl 3
Message 6 of 7

Re: Install OpenMPI during GitHub Action

Unfortunately not, but if you run the job with a container image that includes the OpenMPI installation you need, it'll already be available inside the container without having to install it first.

Highlighted
Copilot Lvl 2
Message 7 of 7

Re: Install OpenMPI during GitHub Action

I see.

 

Thank you all for your answers!