首页 > 解决方案 > 设置 python 时无法使用特定的 gcc 版本

问题描述

CUDA 9.0 和 GCC 6.x 上似乎存在一些冲突(在此处讨论)。所以我决定使用 gcc 5.5 来设置 python 包。

根据答案https://stackoverflow.com/a/25595274/5634636https://stackoverflow.com/a/16737696/5634636,我尝试运行setup.py如下:

CC=gcc-5 CXX=g++-5 python setup.py install --user

这引发了错误(我只粘贴了一部分,因为它太长了):

/usr/include/c++/6/tuple:在 'static constexpr bool std::_TC<, _Elements>::_MoveConstructibleTuple() 的实例化中 [with _UElements = {std::tuple};

看来python在编译时仍在使用g++ 6 (/usr/include/c++/ 6 /tuple) 库。如何避免使用 g++ 6?

标签: pythonc++gcc

解决方案


好像有两个地方gcc用到了。一个是 python setup 本身,另一个是nvcc. 环境变量CCCXX只指定了 python 的 gcc 版本,但它没有改变nvcc.

要更改默认使用的 gcc 版本 cuda,请执行以下操作:

sudo unlink /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/gcc-5 /usr/local/cuda/bin/gcc

/usr/bin/gcc-5您想要使用的 gcc 可以有任何路径。


推荐阅读