Compile errors when compiling samples on CentOS7 with CUDA10.0: nan.0F

I’m trying to compile CUDA samples on CentOS7 with CUDA 10.0 toolkit installed. I tried both gcc 4.8.5 and gcc 7.3.

For example, for matrixMul sample, the errors are following:

../../Common/helper_string.h: In function 'float getCmdLineArgumentFloat(int, const char**, const char*)':
../../Common/helper_string.h:228:13: error: expected ')' before numeric constant
           value = 0.f;
             ^
../../Common/helper_string.h:228:7: error: cannot convert 'double(const char*)throw ()' to 'float' in assignment
           value = 0.f;
       ^
../../Common/helper_image.h: In function 'bool compareData(const T*, const T*, unsigned int, S, float)':
../../Common/helper_image.h:545:22: error: expected ')' before numeric constant
   if (threshold == 0.0f) {

Compilation fails for every sample that has literal 0.0f or 0.0 in host code. After analyzing intermediate files (with --keep flag), I saw that cudafe++ replaces every occurance of 0.0f with nan.0F, and 0.0 with nan.0. This later leads to gcc errors.

It is reproducable via this Dockerfile:

FROM centos:centos7

RUN yum install -y wget vim make git

RUN wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda-repo-rhel7-10-0-local-10.0.130-410.48-1.0-1.x86_64 -O /tmp/cuda-repo-rhel7-10-0-local-10.0.130-410.48-1.0-1.x86_64.rpm

RUN yum install -y /tmp/cuda-repo-rhel7-10-0-local-10.0.130-410.48-1.0-1.x86_64.rpm

RUN yum install -y cuda-toolkit-10-0


CMD /bin/bash

The Dockerfile is provided just as a mean to reproduce the problem, it happens on a physical machine also. Here are the commands I used to build the matrixMul sample:

git clone https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples
git checkout v10.0
cd Samples/matrixMul
make 

Any ideas how to solve this ?

This appears to be problem with glibc version.
glibc-2.17.322.el7_9 had some printf bug.

It got solved with yum install glibc-2.17-323.el7_9