30系显卡安装FLowNet2.0

FlowNet2.0需要安装correlation模块,这个模块在别的任务中也被使用,例如VOS中的FEELVOS。此模块通过cuda编写,在当时支持低版本的torch和cuda版本,现在想将其迁移到30系显卡的机器上,30系显卡对torch和cuda版本有一定的要求,比如仅支持torch>1.7以及cuda>11的版本

flownet2: github
pytorch: previous version

低版本torch和cuda

如果有低版本需求的话,可以看flownet上github issue界面,这里有能够work的torch版本

高版本torch和cuda

这里以torch2.0,cuda11.3为例,当然使用低版本的torch版本也是ok的

需要将flownet中的correlation_package做如下处理,首先将setup.py中的cxx_args = ['-std=c++11']改为cxx_args = ['-std=c++14']

然后在修改correlation_cuda.cc文件

  • 在顶部添加#include <ATen/cuda/CUDAContext.h>
  • at::globalContext().getCurrentCUDAStream()改为at::cuda::getCurrentCUDAStream()
  • #include <torch/torch.h>改为#include <torch/extension.h>

其中前两点在原来的flownet中已经更改了,直接更改第三点即可

然后进入到correlation_package中,运行python setup.py install即可安装成功,其余两个package也同理

下面给出安装过程以及最后的successfully

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
(pytorch2.0) wangyh@A16:/data/wangyh/data4/video_shadow_detection/40_others_fps/vos_feelvos/models/correlation_package$ python setup.py install
running install
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running bdist_egg
running egg_info
creating correlation_cuda.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
writing manifest file 'correlation_cuda.egg-info/SOURCES.txt'
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/utils/cpp_extension.py:476: 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
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/utils/cpp_extension.py:388: UserWarning: The detected CUDA version (11.3) has a minor version mismatch with the version that was used to compile PyTorch (11.8). Most likely this shouldn't be a problem.
warnings.warn(CUDA_MISMATCH_WARN.format(cuda_str_version, torch.version.cuda))
building 'correlation_cuda' extension
creating build
creating build/temp.linux-x86_64-cpython-310
gcc -pthread -B /home/wangyh/miniconda3/envs/pytorch2.0/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/wangyh/miniconda3/envs/pytorch2.0/include -fPIC -O2 -isystem /home/wangyh/miniconda3/envs/pytorch2.0/include -fPIC -I/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include -I/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/TH -I/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/wangyh/miniconda3/envs/pytorch2.0/include/python3.10 -c correlation_cuda.cc -o build/temp.linux-x86_64-cpython-310/correlation_cuda.o -std=c++14 -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
/usr/local/cuda/bin/nvcc -I/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include -I/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/TH -I/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/wangyh/miniconda3/envs/pytorch2.0/include/python3.10 -c correlation_cuda_kernel.cu -o build/temp.linux-x86_64-cpython-310/correlation_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_70,code=compute_70 -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 -std=c++17
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/core/TensorImpl.h(77): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/ATen/core/qualified_name.h(73): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/core/TensorImpl.h(77): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/ATen/core/qualified_name.h(73): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/core/TensorImpl.h(77): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/ATen/core/qualified_name.h(73): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/core/TensorImpl.h(77): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/ATen/core/qualified_name.h(73): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=size_t, one_sided=false, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/core/TensorImpl.h(77): here

/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/c10/util/irange.h(54): warning: pointless comparison of unsigned integer with zero
detected during:
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator==(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
(61): here
instantiation of "__nv_bool c10::detail::integer_iterator<I, one_sided, <unnamed>>::operator!=(const c10::detail::integer_iterator<I, one_sided, <unnamed>> &) const [with I=std::size_t, one_sided=true, <unnamed>=0]"
/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/include/ATen/core/qualified_name.h(73): here

creating build/lib.linux-x86_64-cpython-310
g++ -pthread -B /home/wangyh/miniconda3/envs/pytorch2.0/compiler_compat -shared -Wl,-rpath,/home/wangyh/miniconda3/envs/pytorch2.0/lib -Wl,-rpath-link,/home/wangyh/miniconda3/envs/pytorch2.0/lib -L/home/wangyh/miniconda3/envs/pytorch2.0/lib -Wl,-rpath,/home/wangyh/miniconda3/envs/pytorch2.0/lib -Wl,-rpath-link,/home/wangyh/miniconda3/envs/pytorch2.0/lib -L/home/wangyh/miniconda3/envs/pytorch2.0/lib build/temp.linux-x86_64-cpython-310/correlation_cuda.o build/temp.linux-x86_64-cpython-310/correlation_cuda_kernel.o -L/home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/torch/lib -L/usr/local/cuda/lib64 -lc10 -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda -o build/lib.linux-x86_64-cpython-310/correlation_cuda.cpython-310-x86_64-linux-gnu.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-cpython-310/correlation_cuda.cpython-310-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg
creating stub loader for correlation_cuda.cpython-310-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/correlation_cuda.py to correlation_cuda.cpython-310.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying correlation_cuda.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying correlation_cuda.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying correlation_cuda.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying correlation_cuda.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
__pycache__.correlation_cuda.cpython-310: module references __file__
creating dist
creating 'dist/correlation_cuda-0.0.0-py3.10-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing correlation_cuda-0.0.0-py3.10-linux-x86_64.egg
creating /home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/correlation_cuda-0.0.0-py3.10-linux-x86_64.egg
Extracting correlation_cuda-0.0.0-py3.10-linux-x86_64.egg to /home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages
Adding correlation-cuda 0.0.0 to easy-install.pth file

Installed /home/wangyh/miniconda3/envs/pytorch2.0/lib/python3.10/site-packages/correlation_cuda-0.0.0-py3.10-linux-x86_64.egg
Processing dependencies for correlation-cuda==0.0.0
Finished processing dependencies for correlation-cuda==0.0.0
Error: API rate limit exceeded for 18.204.137.164. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)