Search code examples
c++11gcccudanvcc

Using CUDA 7.0 with gcc 5.2.0 and c++11


I am trying to compile a C++ file with nvcc. The command looks like this:

nvcc -std=c++11 file.cu -o file

The compiler versions are as follows:

$ nvcc --version
Cuda compilation tools, release 7.0, V7.0.27
$ gcc --version
gcc (GCC) 5.2.0

The errors look like nvcc is not compatible with the latest gcc version.

/usr/include/c++/5.2.0/bits/stl_iterator_base_types.h(154): error: class "std::vector<Pixel, std::allocator<Pixel>>" has no member "iterator_category"
      detected during:
        instantiation of class "std::__iterator_traits<_Iterator, void> [with _Iterator=std::vector<Pixel, std::allocator<Pixel>>]"
/usr/include/c++/5.2.0/type_traits(1492): error: class "std::__is_convertible_helper<<error-type>, std::input_iterator_tag, false>" has no member class "type"
      detected during instantiation of class "std::is_convertible<_From, _To> [with _From=<error-type>, _To=std::input_iterator_tag]"
/usr/include/c++/5.2.0/type_traits(1492): error: not a class or struct name
      detected during instantiation of class "std::is_convertible<_From, _To> [with _From=<error-type>, _To=std::input_iterator_tag]" 
[...]

Has anyone ran into a similar issue? Googling did not help me there. Maybe I am missing something here cuda is still new to me.

Thanks in advance!


Solution

  • Because the CUDA tool chain allows mixing of device and host code in the same source file, it requires fairly tight integration with the host tool chain. As a consequence, the CUDA toolchain will in general not work with host tool chains that are newer than the version NVIDIA tested and supports.

    Each CUDA release comes with a "Getting Started" document that states which version(s) of the host tool chain are supported. There are three OS-specific versions of this document; the information in your questions suggests that you are on a Linux platform so you would want to consult the Linux version of "Getting Started".

    Since CUDA 7.0 is the latest released version of CUDA at this time, the Linux version of the "Getting Started" document can also be found online here. It shows that various versions of gcc 4.8 and gcc 4.9 are supported, depending on which specific version of Linux you use.