记录问题
环境:
ubuntu16.04
cuda-9.0
pytorch 1.4
gcc6.5
安装spatial-correlation-sampler出现如下错误:
/usr/include/c++/6/tuple: In instantiation of ‘static constexpr bool std::_TC<, _Elements>::_NonNestedTuple() [with _SrcTuple = std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor>&&; bool = true; _Elements = {at::Tensor, at::Tensor, at::Tensor, at::Tensor}]’:
/usr/include/c++/6/tuple:686:422: required by substitution of ‘template<class ... _UElements, class _Dummy, typename std::enable_if<((std::_TC<(1ul == sizeof... (_UElements)), at::Tensor, at::Tensor, at::Tensor, at::Tensor>::_MoveConstructibleTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), at::Tensor, at::Tensor, at::Tensor, at::Tensor>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && std::_TC<(std::is_same<_Dummy, void>::value && (1ul == 1)), at::Tensor, at::Tensor, at::Tensor, at::Tensor>::_NonNestedTuple<tuple<_Elements ...>&&>()), bool>::type > constexpr std::tuple< >::tuple(std::tuple<_Args1 ...>&&) [with _UElements = {at::Tensor, at::Tensor, at::Tensor, at::Tensor}; _Dummy = void; typename std::enable_if<((std::_TC<(1ul == sizeof... (_UElements)), at::Tensor, at::Tensor, at::Tensor, at::Tensor>::_MoveConstructibleTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), at::Tensor, at::Tensor, at::Tensor, at::Tensor>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && std::_TC<(std::is_same<_Dummy, void>::value && (1ul == 1)), at::Tensor, at::Tensor, at::Tensor, at::Tensor>::_NonNestedTuple<tuple<_Elements ...>&&>()), bool>::type = ]’
/usr/local/lib/python2.7/dist-packages/torch/lib/include/ATen/Functions.h:3493:99: required from here
/usr/include/c++/6/tuple:495:244: error: wrong number of template arguments (5, should be 2)
return _and<_not<is_same<tuple<_Elements...>,
^
/usr/include/c++/6/type_traits:1558:8: note: provided for ‘template<class _From, class _To> struct std::is_convertible’
struct is_convertible
^~~~~~~~~~~~~~
/usr/include/c++/6/tuple:502:1: error: body of constexpr function ‘static constexpr bool std::_TC<, _Elements>::_NonNestedTuple() [with _SrcTuple = std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor>&&; bool = true; _Elements = {at::Tensor, at::Tensor, at::Tensor, at::Tensor}]’ not a return-statement
}
^
error: command '/usr/local/cuda/bin/nvcc' failed with exit status 1
后查阅资料,找到相关问题说是由于gcc版本的问题。
在问题解答中指出:
nvcc 9.0 is not compatible with gcc>5.
cuda 9.2 supports gcc >=5
cuda 9.0 supports gcc<=5
所以我最终的解决办法是:
CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 CUDA_HOME=/usr/local/cuda-9.0/ pip install spatial-correlation-sampler
采用这个命令成功安装了spatial-correlation-sampler.
之后报出: 找不到 libcudart.so.9.0
按照之前的解决办法,在pycharm软件的run——>Edit configuration——>Environment variables添加环境变量:
LD_LIBRARY_PATH,设置值为/usr/local/cuda-9.0/lib64
或者在底部Terminal面板下运行:
sudo ldconfig /usr/local/cuda-9.0/lib64
问题即可解决!