CUDA version X complains about not supporting gcc version Y - what to do?

和自甴很熟 提交于 2019-11-29 01:40:14

This solution is relevant to multiple combinations of CUDA and GCC versions.


You can tell CUDA's nvcc to use a specific version of gcc. So, suppose you want gcc 4.7 for use with CUDA 6. You run:

sudo apt-get install gcc-4.7 g++-4.7

and then add the following switch to your nvcc command-line:

nvcc --compiler-bindir /usr/bin/gcc-4.7  # rest of the command line here

If you're building with CMake, add an appropriate setting before looking for CUDA to your CMakeLists.txt, e.g.:

set(CUDA_HOST_COMPILER /usr/bin/gcc-4.7)  # -> ADD THIS LINE <-
find_package(CUDA)

Also, it seems clang can compile CUDA as well, maybe that's worth experimenting with (although you would have to build it appropriately).

Note: Some Linux (or other OS) distributions don't have packages for multiple versions of gcc (in the same release of the OS distribution). I would advise against trying to install a package from another release of the distribution on an older release, and consider building gcc instead. That's not entirely trivial but it is quite doable - and of course, it's your only option if you don't have root access to your machine.

Switch back to a supported config. They are listed in the getting started document for any recent CUDA distribution.

For your particular configuration you have currently listed, you might have better luck with CUDA 7 RC, which is now available to registered developers.

Conchylicultor

I had a similar issue with CUDA Toolkit 7.5 and gcc 5.2.1.

I did modify the host_config.h file in /usr/local/cuda/include/:

Just remove the lines where it check the gcc version. It did solve my problem.

Credits goes to Darren Garvey (https://groups.google.com/forum/#!topic/torch7/WaNmWZqMnzw)

Very often you will find that CUDA has had newer releases by the time you encounter this problem. For example, the original formulation of the question was about CUDA 6 and GCC 4.9; CUDA 7 supported GCC 4.9. CUDA 8 supports GCC 5.x . And so on.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!