Install Nvidia HPC free C, C++, Fortran compilers

The free-to-use Nvidia HPC SDK compiler executables are:

  • C: nvc
  • C++: nvc++
  • Fortran: nvfortran

Existing toolchains such as CMake and Meson can immediately use HPC SDK by setting environment variables:

CC=pgcc
CXX=pgc++
FC=pgfortran

first ensuring the HPC SDK bin/ directory is on PATH.

Nvidia HPC binaries can offer speed improvements over GNU GCC / GFortran, but Intel oneAPI binaries can be significantly faster than Nvidia-compiled binaries for CPU-only workloads. Unless one specifically needs the GPU features of Nvidia HPC SDK consider GNU or Intel oneAPI that have more modern Fortran features.

Nvidia HPC compilers are currently available for Linux, with language standard support:

  • C11
  • C++17
  • Fortran 2003, with some Fortran 2008 including submodule and error stop

Install

  1. Download and install Nvidia HPC SDK:
  2. sudo is not required, but the install must be on symbolic-link-aware drive (not ExFAT)
  3. Add the Nvidia “bin” directory to your “~/.bashrc” PATH environment variable.
  4. Open a new terminal to use Nvidia compilers.

CMake

Currently, CMake can recognize Nvidia compilers as “PGI” since Nvidia HPC SDK takes over for deprecated PGI compilers.

Set compiler-specific options in CMakeLists.txt for various Fortran compilers like:

project(myproj Fortran)

if(CMAKE_Fortran_COMPILER_ID STREQUAL PGI)
  add_compile_options(-Mdclchk)
endif()

Until CMake is updated to recognize Nvidia HPC as a distinct compiler suite, select the Nvidia compilers at CMake configure step:

FC=pgfortran CC=pgcc CXX=pgc++ cmake -B build