1. 论文《Neural Markov Random Field for Stereo Matching》
根据官方给的编译命令,其实make.sh脚本文件里只有一句命令:
python setup.py build install
在build的过程中报错如下:
running build
running build_py
copying modules/ms_deform_attn.py -> build/lib.linux-aarch64-cpython-38/modules
copying modules/__init__.py -> build/lib.linux-aarch64-cpython-38/modules
copying functions/__init__.py -> build/lib.linux-aarch64-cpython-38/functions
copying functions/ms_deform_attn_func.py -> build/lib.linux-aarch64-cpython-38/functions
copying functions/downsample_func.py -> build/lib.linux-aarch64-cpython-38/functions
running build_ext
building 'MultiScaleDeformableAttention' extension
Emitting ninja build file /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
1.11.1.git.kitware.jobserver-1
g++ -pthread -B /home/zkhy/miniconda3/envs/NMRF/compiler_compat -Wl,--sysroot=/ -pthread -shared -B /home/zkhy/miniconda3/envs/NMRF/compiler_compat -L/home/zkhy/miniconda3/envs/NMRF/lib -Wl,-rpath=/home/zkhy/miniconda3/envs/NMRF/lib -Wl,--no-as-needed -Wl,--sysroot=/ /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/home/zkhy/data/NMRF-main/ops/src/cpu/ms_deform_attn_cpu.o /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/home/zkhy/data/NMRF-main/ops/src/cuda/downsample_cuda.o /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/home/zkhy/data/NMRF-main/ops/src/cuda/ms_deform_attn_cuda.o /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/home/zkhy/data/NMRF-main/ops/src/vision.o -L/home/zkhy/.local/lib/python3.8/site-packages/torch/lib -L/usr/local/cuda/lib64 -lc10 -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda -o build/lib.linux-aarch64-cpython-38/MultiScaleDeformableAttention.cpython-38-aarch64-linux-gnu.so
g++: error: /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/home/zkhy/data/NMRF-main/ops/src/cpu/ms_deform_attn_cpu.o: 没有那个文件或目录
g++: error: /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/home/zkhy/data/NMRF-main/ops/src/cuda/downsample_cuda.o: 没有那个文件或目录
g++: error: /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/home/zkhy/data/NMRF-main/ops/src/cuda/ms_deform_attn_cuda.o: 没有那个文件或目录
g++: error: /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/home/zkhy/data/NMRF-main/ops/src/vision.o: 没有那个文件或目录
error: command '/usr/bin/g++' failed with exit code 1
且不管这个文件路径是否有问题,先看看这个报错。不存在的这些目标文件是编译没成功的。虽然build没成功但是生成了build.ninja文件,那么就可以通过ninja来构建了,通过下面的命令。
ninja -C /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38
很顺利地一次性成功了,输出日志如下,注意要有[1/4]....[4/4]这样表示完成度的才算成功。
ninja: Entering directory `/home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38'
[1/4] c++ -MMD -MF /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpytho...TENSION_NAME=MultiScaleDeformableAttention -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
[3/4] /usr/local/cuda/bin/nvcc -DWITH_CUDA -I/home/zkhy/data/NMRF-main/ops/src ...e=arch=compute_87,code=compute_87 -gencode=arch=compute_87,code=sm_87 -std=c++14
/home/zkhy/data/NMRF-main/ops/src/cuda/ms_deform_im2col_cuda.cuh(261): warning: variable "q_col" was declared but never referenced
[4/4] c++ -MMD -MF /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpytho...TENSION_NAME=MultiScaleDeformableAttention -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/zkhy/data/NMRF-main/ops/src/vision.cpp:11:
......
51 | if (value.type().is_cuda())
| ^
In file included from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/ATen/core/Tensor.h:3,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/ATen/DeviceGuard.h:4,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/ATen/ATen.h:11,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8,
from /home/zkhy/.local/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
from /home/zkhy/data/NMRF-main/ops/src/cpu/ms_deform_attn_cpu.h:12,
from /home/zkhy/data/NMRF-main/ops/src/ms_deform_attn.h:13,
from /home/zkhy/data/NMRF-main/ops/src/vision.cpp:11:
/home/zkhy/.local/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:210:30: note: declared here
210 | DeprecatedTypeProperties & type() const {
|
如此一来也就生成目标文件了,那么接下来就用回最初的命令,构建生成库文件吧!
sh make.sh
running build
running build_py
copying modules/ms_deform_attn.py -> build/lib.linux-aarch64-cpython-38/modules
copying modules/__init__.py -> build/lib.linux-aarch64-cpython-38/modules
copying functions/__init__.py -> build/lib.linux-aarch64-cpython-38/functions
copying functions/ms_deform_attn_func.py -> build/lib.linux-aarch64-cpython-38/functions
copying functions/downsample_func.py -> build/lib.linux-aarch64-cpython-38/functions
running build_ext
building 'MultiScaleDeformableAttention' extension
Emitting ninja build file /home/zkhy/data/NMRF-main/ops/build/temp.linux-aarch64-cpython-38/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
1.11.1.git.kitware.jobserver-1
......
Installed /home/zkhy/miniconda3/envs/NMRF/lib/python3.8/site-packages/MultiScaleDeformableAttention-1.0-py3.8-linux-aarch64.egg
Processing dependencies for MultiScaleDeformableAttention==1.0
Finished processing dependencies for MultiScaleDeformableAttention==1.0