Skip to content

Instantly share code, notes, and snippets.

@scivision
Last active January 8, 2024 04:33
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scivision/d94bb10a01fa3b8ed0c9a93ee16318ba to your computer and use it in GitHub Desktop.
Save scivision/d94bb10a01fa3b8ed0c9a93ee16318ba to your computer and use it in GitHub Desktop.
Intel oneAPI GitHub Actions with MKL and MPI (C, C++, Fortran) and CMake

GitHub Actions Intel oneAPI without caching

Unlike cached approach, this is simpler but takes much longer to setup on each run.

# this method does not use Github Actions cache--good for infrequent simple runs
jobs:
linux-intel-oneapi:
runs-on: ubuntu-latest
steps:
- name: Intel Apt repository
timeout-minutes: 1
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
- name: Install Intel oneAPI compilers
timeout-minutes: 5
run: sudo apt-get install intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp
# optional
- name: Install Intel MPI and MKL
timeout-minutes: 5
run: intel-oneapi-mpi intel-oneapi-mpi-devel intel-oneapi-mkl
- name: Setup Intel oneAPI environment
run: |
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- name: checkout project code
uses: actions/checkout@v4
- name: CMake Configure
run: cmake -B build
- name: CMake build
run: cmake --build build
- name: CMake test
run: ctest --test-dir build
@scivision
Copy link
Author

https://github.com/scivision/fortran-filesystem/blob/main/.github/workflows/oneapi-linux.yml
This uses auxiliary scripts and cache still takes a couple minutes to setup. I didn't switch to cached in other projects as a result of not much time savings and additional setup hassle

@Koushikphy
Copy link

I was using the exact same Install Intel oneAPI step (without the ninja_build) and the apt installation takes almost 3 and half minutes, whereas the cache setup took 50 sec.

@mathomp4
Copy link

@scivision Does all this still work for you? For some reason now it's like intel oneAPI's setvars.sh isn't adding to PATH where ifort is and I need to do:

FC: /opt/intel/oneapi/compiler/2024.0/bin/ifort

Do you know if there is some extra things now needed to get ifort out of an intel-oneapi apt install?

@scivision
Copy link
Author

scivision commented Nov 30, 2023

I don't know, I don't use "ifort" anymore. Here is what I'm updating this Gist with, that has recently run (November 2023): https://github.com/scivision/fortran2018-examples/blob/main/.github/workflows/oneapi-linux.yml

@scivision
Copy link
Author

@mathomp4
Copy link

I don't know, I don't use "ifort" anymore. Here is what I'm updating this Gist with, that has recently run (November 2023): https://github.com/scivision/fortran2018-examples/blob/main/.github/workflows/oneapi-linux.yml

So I just made my workflow file look like this gist:

https://github.com/Goddard-Fortran-Ecosystem/pFUnit/actions/runs/7048495483/workflow

(fixing the install for Intel MPI) but the run dies:

https://github.com/Goddard-Fortran-Ecosystem/pFUnit/actions/runs/7048495483/job/19184779771

I have:

    env:
      FC: ifx
      CC: icx

and then:

      - name: Versions
        run: |
          ${FC} --version
          ${CC} --version
          mpirun --version
          cmake --version

and it's failing with:

/home/runner/work/_temp/cb650a95-20a2-4f19-8de3-453e0635ddd4.sh: line 1: ifx: command not found

@scivision
Copy link
Author

scivision commented Nov 30, 2023

changes to $GITHUB_ENV persist across steps in a job per https://docs.github.com/en/actions/learn-github-actions/variables
On my Linux workstation, "ifx" is at /opt/intel/oneapi/compiler/2023.2.0/linux/bin/ifx which is on your runner's PATH

Maybe it's a GA YAML syntax issue? Should that command be

${{ env.FC }} --version

Otherwise try temporarily commenting out that "Versions" step and see if CMake detects oneAPI as expected.

@mathomp4
Copy link

Sigh. Nope, unhappy:

https://github.com/Goddard-Fortran-Ecosystem/pFUnit/actions/runs/7051576623/job/19194785582

It's obviously seeing FC as CMake tried to use ifx but ifx is just not in the path. It's like setvars.sh isn't...setting all the vars.

@loganoz
Copy link

loganoz commented Jan 3, 2024

Hi @mathomp4, I have exactly the same problem with ifort that you are reporting. Any ideas on how to solve it?

@loganoz
Copy link

loganoz commented Jan 3, 2024

I found this, https://fortran-lang.discourse.group/t/oneapi-on-ubuntu23010/6878/21. It would seem like the problem is with oneAPI.

@mathomp4
Copy link

mathomp4 commented Jan 3, 2024

I found this, https://fortran-lang.discourse.group/t/oneapi-on-ubuntu23010/6878/21. It would seem like the problem is with oneAPI.

Ooh. Let me give that a try!

@mathomp4
Copy link

mathomp4 commented Jan 3, 2024

Yep. That seems to have worked!

https://github.com/Goddard-Fortran-Ecosystem/pFUnit/actions/runs/7397692487/job/20125281071

Now to start bringing back all my other CI that I commented out! Thanks!

@loganoz
Copy link

loganoz commented Jan 3, 2024

Good! I'll try to do the same in my ifort CIs.

@scivision
Copy link
Author

Thanks I've corrected this example. I'm going to make it a repo so it will run in Github Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment