NVCC cannot compile std::ratio_multiply

The code below cannot be compiled with NVCC using GCC 6.4, because it has issues with the std::ratio_multiply. I have no problems in compiling it with the host compiler itself. What can I do to solve this?

#include <iostream>
#include <ratio> 
int main()
{
    typedef std::ratio<2, 3> r0;
    typedef std::ratio_multiply<r0, r0> r;
    std::cout << r::num << '/' << r::den << '\n';
}

The error is:

test2.cu: In function ‘int main()’:
test2.cu:8:21: error: ‘const intmax_t std::__ratio_multiply<std::ratio<2l, 3l>, std::ratio<2l, 3l> >::__gcd1’ is private within this context
std::cout << r::num << ‘/’ << r::den << ‘\n’;
^~~
/nfs/admin/hpc/sw/RedHatEnterpriseServer7/GCCcore/6.4.0/include/c++/6.4.0/ratio:289:32: note: declared private here
static const intmax_t __gcd1 =

According to the support matrix in the “Linux Installation Guide”, gcc 6.4.0 is not a supported configuration on RHEL 7.x:

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

“not supported” means NVIDIA has not tested this combination with CUDA and it also means that there is a high likelihood it “does not work” with CUDA.

I would suggest switching to a supported configuration. If you are facing issues with a supported configuration, consider filing a bug with NVIDIA.

I would suggest filing a bug. The instructions are linked in a sticky post at the top of this forum.

I tried it on Fedora 29/CUDA 10.1/gcc 8.3.1 (a supported config) and it will not compile using nvcc.

The usual workaround suggestions, since std:: library code is generally not usable in CUDA device code, is to partition your code that requires it into .cpp files, and tie together your code in .cpp files and .cu files with wrapper functions as needed.

If you file a bug, the development team may come back to you at some point with more targetted workaround suggestions.