Nvidia HPC SDK 24.1

:~$sudo apt-get install -y nvhpc-24-1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
nvhpc-24-1 is already the newest version (24.1).
:~$ nvfortran --version
nvfortran: command not found

If it is already the newest version why does it show the error ?

It looks like its path is not in your PATH environment variable:

$ echo $PATH

Personally, I installed a script to modify the path:

$ cat /opt/nvidia/hpc_sdk/setvars.sh 
MANPATH=$MANPATH:/opt/nvidia/hpc_sdk/Linux_x86_64/22.7/compilers/man
export MANPATH
PATH=$PATH:/opt/nvidia/hpc_sdk/Linux_x86_64/22.7/compilers/bin
export PATH

(You should modify the path and version number to your own installation.)

1 Like

Where is it available to install? The NVIDIA platform? I did not find any information regarding path.

It brings to another problem of being familiar with all the details for the compilers.

  • I do not see any relevant path issues with gfortran.

  • For intel it has its own prompt.

  • Now NVIDIA seems to have a new requirement i.e. to make sure the path problem is solved.

Seems like the easiest to work with is gfortran and the hardest is nvfortran.

I have been including the following in my .bashrc to make ifx, ifort, nvfortran, Classic flang, AOCC flang, and armflang (if applicable) available in my bash under Ubuntu.

# Intel OneAPI
# See https://software.intel.com/content/www/us/en/develop/articles/installing-intel-oneapi-toolkits-via-apt.html
# The setvars script provided by Intel takes TOO MUCH time to run. So we record its results in
# .setintelvars and then source it. This will work after the following code is executed for the
# first time.
if [[ -d /opt/intel ]] ; then
    SETVARS="$(find /opt/intel -type f -name setvars.sh -print | sort | tail -n 1)"
    SETVARS_SAVE="$HOME/.setintelvars"
    if [[ -n "$SETVARS" ]] ; then
        (source "$SETVARS" > /dev/null ; env | grep -i 'intel\|oneapi' \
            | sed "s/:\/Users\/.*$//" | sed 's/^/export /' > "$SETVARS_SAVE") & disown
    fi

    if [[ -f "$SETVARS_SAVE" ]] ; then
        source "$SETVARS_SAVE"
    fi
    # The following does not work. Why?
    #source /opt/intel/oneapi/setvars.sh > /dev/null & disown
fi

# NAVIDIA HPC SDK
# See https://developer.nvidia.com/hpc-sdk
if [[ -d /opt/nvidia ]] ; then
    NVFORTRAN="$(find /opt/nvidia -type f -executable -name nvfortran -print | sort | tail -n 1)"
    if [[ -n "$NVFORTRAN" ]] ; then
        PATH=$PATH:"$(dirname "$NVFORTRAN")"
    fi
fi

# Classic flang                                                                                                                                                                 
# Install: Get the correct version of flang corresponding to your architecture from https://github.com/zaikunzhang/flang, and decompress it into $FLANGDIR.                                                                                                                                                                    
FLANGDIR="~/.local/flang"                                                                                  
if [[ -d "$FLANGDIR" ]] ; then                                                                        
    export PATH=$PATH:"$FLANGDIR"/bin                                                                    
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$FLANGDIR"/lib                                                                     
fi  

# AMD Flang Fortran compiler (will be known as `aflang` by bash). 
# See https://developer.amd.com/amd-aocc
if [[ -d /opt/AMD ]] ; then
    AOCCDIR="$(find /opt/AMD -maxdepth 1 -name "aocc-compiler*" -type d -print | sort | tail -n 1)"
    # The following must be done after NVFORTRAN.
    if [[ -n "$AOCCDIR" ]] ; then
        AFLANG=$(find -L /opt/AMD -type f -executable -name flang -print 2>/dev/null | sort | tail -n 1)
        if [[ -n "$AFLANG" ]] ; then alias aflang="$AFLANG" ; fi
        export LD_LIBRARY_PATH="$AMDFDIR"/lib:$LD_LIBRARY_PATH
        ############################################################################################
        # Do NOT do the following. Otherwise, the flang of AOCC will become the default flang,
        # rather than the Classic flang. This is also why we made an alias named aflang as above.
        #AOCC_ENVSH="$(find "$AOCCDIR" -name "*setenv*.sh" -type f)"
        #source "$AOCC_ENVSH"
        ############################################################################################
    fi
fi

# ARM Flang. See https://developer.arm.com/downloads/-/arm-compiler-for-linux
# For 32-bit Raspberry Pi, `uname -m` returns `armv*`. N.B.: Do not quote `armv*`.
if [[ ("$(uname -m)" == aarch* || "$(uname -m)" == arm*) && -d /opt/arm ]] ; then
    ARMDIR="$(find /opt/arm -maxdepth 1 -name "arm-linux-compiler*" -type d -print | sort | tail -n 1)"
    if [[ -n "$ARMDIR" ]] ; then
        export PATH=$PATH:"$ARMDIR"/bin
        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
        ARMLD_DIR=$(find /opt/arm -type f -executable -name ld | xargs dirname)
        ARMLD_DIR=${ARMLD_DIR//$'\n'/:}
        export PATH=$PATH:"$ARMLD_DIR"
    fi
fi

I am not a bash expert. My code may not be optimal, but it works well for my use. Comments and suggestions will be appreciated. Thanks.

3 Likes

After the software installation is complete, each user’s shell environment must be initialized to use the HPC SDK. [emphasis added]

[…]

To make the HPC SDK available:

In bash, sh, or ksh, use these commands:

$ NVARCH=`uname -s`_`uname -m`; export NVARCH
$ NVCOMPILERS=/opt/nvidia/hpc_sdk; export NVCOMPILERS
$ MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/24.1/compilers/man; export MANPATH
$ PATH=$NVCOMPILERS/$NVARCH/24.1/compilers/bin:$PATH; export PATH

You could add this to your .bashrc script if you want to have it available by default.

The same information is also repeated here: HPC Compilers User's Guide Version 24.1 for ARM, OpenPower, x86

1 Like

By seeing at your error log, you installed the HPC SDK with the instruction from “Linux x86_64 Ubuntu (apt)”. I did the same thing (Becasue I’m using WSL Ubuntu), but even after setting environment variables that the above answer mentioned, it didn’t worked.

I solved this problem by reinstalling HPC SDK using different ways(using tar), and setting environment variables using Installation Guide Version 24.3 .

Guide:
Install HPC SDK using “Linux x86_64 (tar file)”

$ wget https://developer.download.nvidia.com/hpc-sdk/24.3/nvhpc_2024_243_Linux_x86_64_cuda_12.3.tar.gz
$ tar xpzf nvhpc_2024_243_Linux_x86_64_cuda_12.3.tar.gz
$ nvhpc_2024_243_Linux_x86_64_cuda_12.3/install

Set environment variable

$ export PATH=$NVCOMPILERS/$NVARCH/24.3/comm_libs/mpi/bin:$PATH
$ export MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/24.3/comm_libs/mpi/man

This solved the problem for me.

.
I am no expert, I just want to share how I detoured this problem.

Welcome to the Forum!

I had my HPC SDK installed for almost 2 years. Recently, I figured out it was not working, so I tried the new installation.

As you suggested the tar way, I will try it soon and get back to you.