CUDA版本X抱怨不支持gcc版本Y -该怎么办?

时间:2021-11-07 19:37:03

The question is about a specific combination of versions but is relevant more generally.

问题是关于一个具体的版本组合,但更一般的是相关的。

I've just dist-upgraded from Kubuntu 12.04 to 14.04. Now, when I want to compile CUDA code (with CUDA 6.5), I get:

我刚从Kubuntu的12.04升级到14.04。现在,当我想编译CUDA代码(使用CUDA 6.5)时,我得到:

#error -- unsupported GNU version! gcc 4.9 and up are not supported!

I installed gcc-4.8 (and 4.7), and tried to use the symlinks-in-/usr/local/cuda/bin solution suggested here:

我安装了gcc-4.8(和4.7),并尝试使用在这里建议的symlinks- /usr/local/cuda/bin解决方案:

CUDA incompatible with my gcc version

CUDA与我的gcc版本不兼容。

but this doesn't work. What should I do?

但这是行不通的。我应该做什么?

4 个解决方案

#1


19  

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

这个解决方案与CUDA和GCC版本的多个组合有关。


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:

您可以告诉CUDA的nvcc使用一个特定版本的gcc。因此,假设您希望gcc 4.7用于CUDA 6。你运行:

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

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

然后将下面的转换添加到nvcc命令行:

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.:

如果你正在使用CMake,在寻找CUDA到你的CMakeLists之前添加一个适当的设置。三种,例如:

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).

而且,clang也可以编译CUDA,也许这是值得尝试的(尽管您需要适当地构建它)。

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.

注意:一些Linux(或其他OS)发行版没有针对多个版本的gcc的包(在相同版本的OS发行版中)。我建议不要尝试在旧版本的发行版中安装一个包,而应该考虑构建gcc。这并不完全是微不足道的,但它是相当可行的——当然,如果您没有根访问您的机器,它是您唯一的选择。

#2


2  

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

切换回支持的配置。它们在最近的CUDA发行版中被列出。

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

对于您当前列出的特定配置,您可能会更幸运地使用CUDA 7 RC,它现在可以向注册的开发人员使用。

#3


1  

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

我对CUDA Toolkit 7.5和gcc 5.2.1也有类似的问题。

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

我确实修改了host_config。在/usr/local/cuda/include/ h文件:

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

只需删除它检查gcc版本的行。它确实解决了我的问题。

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

积分到Darren Garvey (https://groups.google.com/forum/#!topic/torch7/WaNmWZqMnzw)

#4


1  

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.

通常你会发现CUDA在遇到这个问题时已经有了更新的版本。例如,最初的问题是关于CUDA 6和GCC 4.9;CUDA 7支持GCC 4.9。CUDA 8支持GCC 5。x。等等。

#1


19  

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

这个解决方案与CUDA和GCC版本的多个组合有关。


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:

您可以告诉CUDA的nvcc使用一个特定版本的gcc。因此,假设您希望gcc 4.7用于CUDA 6。你运行:

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

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

然后将下面的转换添加到nvcc命令行:

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.:

如果你正在使用CMake,在寻找CUDA到你的CMakeLists之前添加一个适当的设置。三种,例如:

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).

而且,clang也可以编译CUDA,也许这是值得尝试的(尽管您需要适当地构建它)。

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.

注意:一些Linux(或其他OS)发行版没有针对多个版本的gcc的包(在相同版本的OS发行版中)。我建议不要尝试在旧版本的发行版中安装一个包,而应该考虑构建gcc。这并不完全是微不足道的,但它是相当可行的——当然,如果您没有根访问您的机器,它是您唯一的选择。

#2


2  

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

切换回支持的配置。它们在最近的CUDA发行版中被列出。

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

对于您当前列出的特定配置,您可能会更幸运地使用CUDA 7 RC,它现在可以向注册的开发人员使用。

#3


1  

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

我对CUDA Toolkit 7.5和gcc 5.2.1也有类似的问题。

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

我确实修改了host_config。在/usr/local/cuda/include/ h文件:

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

只需删除它检查gcc版本的行。它确实解决了我的问题。

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

积分到Darren Garvey (https://groups.google.com/forum/#!topic/torch7/WaNmWZqMnzw)

#4


1  

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.

通常你会发现CUDA在遇到这个问题时已经有了更新的版本。例如,最初的问题是关于CUDA 6和GCC 4.9;CUDA 7支持GCC 4.9。CUDA 8支持GCC 5。x。等等。