最近在鼓捣光流网络,之前用过别人的liteflownet,现在更新到了liteflownet3了,想着git下来玩玩,项目传送门在这里
问题1和解决方法完之后就遇到了编译问题
问题如下,这只是其中前面的部分而以
(torch18cuda101) a@a:~/pytorch-liteflownet3/correlation_package$ python setup.py install
running install
running bdist_egg
running egg_info
writing correlation_cuda.egg-info/PKG-INFO
writing dependency_links to correlation_cuda.egg-info/dependency_links.txt
writing top-level names to correlation_cuda.egg-info/top_level.txt
/home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/utils/cpp_extension.py:369: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
warnings.warn(msg.format('we could not find ninja.'))
reading manifest file 'correlation_cuda.egg-info/SOURCES.txt'
writing manifest file 'correlation_cuda.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building 'correlation_cuda' extension
gcc -pthread -B /home/a/anaconda3/envs/torch18cuda101/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include -I/home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/TH -I/home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/a/anaconda3/envs/torch18cuda101/include/python3.7m -c correlation_cuda.cc -o build/temp.linux-x86_64-3.7/correlation_cuda.o -std=c++11 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -DTORCH_EXTENSION_NAME=correlation_cuda -D_GLIBCXX_USE_CXX11_ABI=0
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:0,
from correlation_cuda.cc:1:
/home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4:2: error: #error C++14 or later compatible compiler is required to use PyTorch.
#error C++14 or later compatible compiler is required to use PyTorch.
^~~~~
In file included from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:0,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3,
from correlation_cuda.cc:1:
/home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/ATen/ATen.h:4:2: error: #error C++14 or later compatible compiler is required to use ATen.
#error C++14 or later compatible compiler is required to use ATen.
^~~~~
In file included from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/c10/util/ArrayRef.h:19:0,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/c10/core/DispatchKey.h:7,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/c10/core/Backend.h:4,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/c10/core/Layout.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/ATen/core/TensorBody.h:4,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/ATen/Tensor.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/ATen/Context.h:4,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/ATen/ATen.h:9,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8,
from /home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3,
from correlation_cuda.cc:1:
/home/a/anaconda3/envs/torch18cuda101/lib/python3.7/site-packages/torch/include/c10/util/C++17.h:24:2: error: #error You need C++14 to compile PyTorch
#error You need C++14 to compile PyTorch
^~~~~
后续我到处找解决方法,都没有一个可以直接解决的方法,后来我看到了这篇文章,这篇文章给了我灵感,然后我就去看了以下setup.py文件,发现了下面这个部分
cxx_args = ['-std=c++11']
我看文章中写着c++14之类的,然后这里也只有11,我就很纳闷是不是这个东西的问题(个人不动编译…),然后我改成了下面的样子,这个部分的报错就没问题了。
cxx_args = ['-std=c++11', '-std=c++14']问题2和解决办法
后续我又遇到了新问题,
/usr/include/c++/7/bits/basic_string.tcc: In instantiation of ‘static std::basic_string<_CharT, _Traits, _Alloc>::_Rep* std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_create(std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char16_t; _Traits = std::char_traits; _Alloc = std::allocator ; std::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’: /usr/include/c++/7/bits/basic_string.tcc:578:28: required from ‘static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&, std::forward_iterator_tag) [with _FwdIterator = const char16_t*; _CharT = char16_t; _Traits = std::char_traits ; _Alloc = std::allocator ]’ /usr/include/c++/7/bits/basic_string.h:5042:20: required from ‘static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct_aux(_InIterator, _InIterator, const _Alloc&, std::__false_type) [with _InIterator = const char16_t*; _CharT = char16_t; _Traits = std::char_traits ; _Alloc = std::allocator ]’ /usr/include/c++/7/bits/basic_string.h:5063:24: required from ‘static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&) [with _InIterator = const char16_t*; _CharT = char16_t; _Traits = std::char_traits ; _Alloc = std::allocator ]’ /usr/include/c++/7/bits/basic_string.tcc:656:134: required from ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char16_t; _Traits = std::char_traits ; _Alloc = std::allocator ; std::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’ /usr/include/c++/7/bits/basic_string.h:6688:95: required from here /usr/include/c++/7/bits/basic_string.tcc:1067:16: error: cannot call member function ‘void std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_set_sharable() [with _CharT = char16_t; _Traits = std::char_traits ; _Alloc = std::allocator ]’ without object __p->_M_set_sharable(); ~~~~~~~~~^~ /usr/include/c++/7/bits/basic_string.tcc: In instantiation of ‘static std::basic_string<_CharT, _Traits, _Alloc>::_Rep* std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_create(std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char32_t; _Traits = std::char_traits ; _Alloc = std::allocator ; std::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’: /usr/include/c++/7/bits/basic_string.tcc:578:28: required from ‘static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&, std::forward_iterator_tag) [with _FwdIterator = const char32_t*; _CharT = char32_t; _Traits = std::char_traits ; _Alloc = std::allocator ]’ /usr/include/c++/7/bits/basic_string.h:5042:20: required from ‘static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct_aux(_InIterator, _InIterator, const _Alloc&, std::__false_type) [with _InIterator = const char32_t*; _CharT = char32_t; _Traits = std::char_traits ; _Alloc = std::allocator ]’ /usr/include/c++/7/bits/basic_string.h:5063:24: required from ‘static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&) [with _InIterator = const char32_t*; _CharT = char32_t; _Traits = std::char_traits ; _Alloc = std::allocator ]’ /usr/include/c++/7/bits/basic_string.tcc:656:134: required from ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char32_t; _Traits = std::char_traits ; _Alloc = std::allocator ; std::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’ /usr/include/c++/7/bits/basic_string.h:6693:95: required from here /usr/include/c++/7/bits/basic_string.tcc:1067:16: error: cannot call member function ‘void std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_set_sharable() [with _CharT = char32_t; _Traits = std::char_traits ; _Alloc = std::allocator ]’ without object error: command '/usr/local/cuda/bin/nvcc' failed with exit status 1
这个问题还算好解决,我直接搜了一下就出来了,文章在这
按照文章的方式,改了一下保存就没问题了。
其他想说的我看了一下,liteflownet3是在liteflownet1上改的,同样也参考了flownet,就是nvidia的项目,然后里面用的算子好像根flownet是一样的,所以我估计上面的解决办法可以解决类似的问题。



