According to the NVIDIA Docs: On all platforms, the default host compiler executable (gcc and g++ on Linux and cl.exe on Windows) found in the current execution search path will be used, unless specified otherwise with appropriate options (see File and Path Specifications).
I found that a code written in C/C++ that is compiled with nvcc does not use the default gnu compiler in the system. It seems that I updated the GNU compiler and nvcc is still using the old gnu version. I can check it if I compile a program with nvcc, check the GNU version, add the flag -ccbin g+±9, compile again and check again:
#> echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
> gcc -v
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
#> nvcc --version
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
#> nvcc -O3 --compiler-options -use_fast_math -Xcompiler -fopenmp -gencode arch=compute_75,code=sm_75 test_nvcc_openmp.cpp -o bin/test_nvcc_openmp
#> strings -a bin/test_nvcc_openmp |grep “GCC: (”
GCC: (Ubuntu 8.4.0-3ubuntu2) 8.4.0
add the flag -ccbin g+±9
#> nvcc -O3 -ccbin g+±9 --compiler-options -use_fast_math -Xcompiler -fopenmp -gencode arch=compute_75,code=sm_75 test_nvcc_openmp.cpp -o bin/test_nvcc_openmp
#> strings -a bin/test_nvcc_openmp |grep “GCC: (”
GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Best,
Pablo.