Benchmarking Software Environment
Begin by installing all available software updates, for example, sudo apt update && sudo apt upgrade
on Ubuntu. Use the command ld --version
to check that GNU binutils version is 2.38 or later.
For best performance, GCC should be at version 12.3 or later. gcc --version
will report the GCC version.
Many Linux distributions provide packages for GCC 12 compilers that can be installed alongside the system GCC. For example, sudo apt install gcc-12
on Ubuntu. See your Linux distribution’s instructions for installing and using various GCC versions.
In case your distribution does not provide these packages, or you are unable to install them, instructions for building and installing GCC are provided below.
A Recommended Software Stack
This guide shows a variety of compilers, libraries, and tools. Suggested minimum versions of the major software packages used in this guide are shown below, but any recent version of these tools will work well on NVIDIA Grace. Installation instructions for each package are provided in the associated link.
Building and Installing GCC 12.3 from Source
Many Linux distributions provide packages for GCC 12 compilers that can be installed alongside the system GCC. For example, sudo apt install gcc-12
on Ubuntu. You should prefer those packages over building GCC from source.
Follow the instructions below to build GCC 12.3 from source. Note that filesystem I/O performance can affect compilation time, so we recommend building GCC on a local filesystem or ramdisk, e.g. /tmp
.
Download and unpack the GCC source code:
wget https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.3.0.tar.xz
tar xvf gcc-12.3.0.tar.xz
Download the GCC prerequisites:
cd gcc-12.3.0
./contrib/download_prerequisites
You should see output similar to:
2024-01-24 08:04:44 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.2.1.tar.bz2 [2493916/2493916] -> "gmp-6.2.1.tar.bz2" [1]
2024-01-24 08:04:45 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-4.1.0.tar.bz2 [1747243/1747243] -> "mpfr-4.1.0.tar.bz2" [1]
2024-01-24 08:04:47 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.2.1.tar.gz [838731/838731] -> "mpc-1.2.1.tar.gz" [1]
2024-01-24 08:04:49 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.24.tar.bz2 [2261594/2261594] -> "isl-0.24.tar.bz2" [1]
gmp-6.2.1.tar.bz2: OK
mpfr-4.1.0.tar.bz2: OK
mpc-1.2.1.tar.gz: OK
isl-0.24.tar.bz2: OK
All prerequisites downloaded successfully.
Configure, compile, and install GCC. Remember to set GCC_INSTALL_PREFIX
appropriately! This example installs GCC to /opt/gcc/12.3
but any valid filesystem path can be used:
export GCC_INSTALL_PREFIX=/opt/gcc/12.3
./configure --prefix="$GCC_INSTALL_PREFIX" --enable-languages=c,c++,fortran --enable-lto --disable-bootstrap --disable-multilib
make -j
make install
To use the newly-installed GCC 12 compiler, simply update your $PATH
environment variable:
export PATH=$GCC_INSTALL_PREFIX/bin:$PATH
Confirm that the gcc
command invokes GCC 12.3:
which gcc
gcc --version
You should see output similar to:
/opt/gcc/12.3/bin/gcc
gcc (GCC) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.