Install Yambo on Ubuntu/LinuxMint with NVfortran compiler

From The Yambo Project
Jump to navigation Jump to search

The NVIDIA compiler are freely available on Linux machines. You can download Fortran,C, C++ compiler and debugger from: NVIDIA HPC Software Development Kit (SDK)
On Ubuntu, it can be easely installed via the following procedure

sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install -y build-essential automake autoconf libtool zlib1g-dev curl gpg wget git tar cmake
curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | sudo tee /etc/apt/sources.list.d/nvhpc.list
sudo apt-get update -y && sudo apt-get install -y nvhpc-25-1

Setup NVIDIA compilers

Once you downloaded and installed the NVIDIA SDK it is suggested avoiding manually setting environment variables for compilers and MPI wrappers. The safest approach is to use the module files provided by Nvidia, located at: `/opt/nvidia/hpc_sdk/modulefiles`

Before using module files, you need to install the module management tool:

sudo apt-get install environment-modules
echo "source /etc/profile.d/modules.sh" >> ~/.bashrc
echo "module use /opt/nvidia/hpc_sdk/modulefiles" >> ~/.bashrc
source ~/.bashrc

The commands above only need to be used the first time. Now, you can load the Nvidia SDK module, which will correctly set up all environment variables for both compilers and MPI:

module load nvhpc/25.1

Configure Yambo with NVfortran and openMPI

Then you can configure Yambo with the command:

./configure MPIFC=mpif90 MPICC=mpicc FC=nvfortran F77=nvfortran CPP="cpp -E"  FPP="nvfortran -Mpreprocess -E" F90SUFFIX=".f90" \
--enable-memory-profile  --enable-open-mp --enable-par-linalg  --enable-hdf5-par-io  --enable-slepc-linalg 

If you have an installed CUDA GPU on your machine you can compile Yambo to use it, by adding the flag

--enable-cuda-fortran 

and then specify your GPU architecture and the CUDA runtime version, look at configure help for more info.

Check that your Nvidia graphic card is properly installed

To be sure that the code will run fine on your GPU card, you need the proper driver installed on your machine. If you have the nvidia drivers, just run

$nvidia-smi
Mon Sep  9 16:20:02 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.03              Driver Version: 560.35.03      CUDA Version: 12.6     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce GTX 1650        Off |   00000000:01:00.0  On |                  N/A |
| 20%   39C    P8              8W /   75W |     280MiB /   4096MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

CUDA Version: V.S should be lower or equal to what you set in your cuda-runtime in the configure. In this case we are running with driver 560, which supports cuda version 12.6 or newer via the CUDA Forward Compatibility Package (see https://docs.nvidia.com/deploy/cuda-compatibility/).

More info on Yambo on NVIDIA graphic cards can be found here: Materials Design Toward the Exascale: Porting Electronic Structure Community Codes to GPUs