先放解决方法:
使用了早版本的pytorch源码中的pytorch/caffes/utils/threadpool 和 pytorch/caffes/utils/math。
我把这个utils文件放在网盘里啦。
链接:https://pan.baidu.com/s/1LwzCpCxCNRUG26M3u8nbcg
提取码:tlxr
详细记录如下:
在服务器上第一次安装成功densepose之后服务器重装系统了,第二遍安装时出现这个问题。具体问题如下:
首先,顺便记录一下我的densepose安装过程:
1. 依照 https://github.com/Johnqczhang/densepose_installation/blob/master/README.md 安装densepose
(顺便记录一下其中的要点,pytorch必须安装1.1.0版本!!gcc必须4.9.2!!)
2. 其中detectron还依照 https://github.com/facebookresearch/Detectron/blob/master/INSTALL.md 另外安装了一下(我记得第一遍安装的时候detectronm没有另外安装,然而第二遍安装的时候报错了,所以尝试了一下这个方法。不过导致make成功之后,最后出现了一个找不到libcaffe2_detectron_custom_ops_gpu.so的问题,顺便说一下这个问题的解决方法:直接find命令搜了一下这个文件所在的位置,然后将所在的build文件夹拷贝进缺失的地方即可。)
回到正题,
在densepose安装过程中,最后执行到cmake ..&&make时出现如下错误:
(gaze360-3.7-3) xdn@xwfx:~/project/Gaze360/densepose/build$ make
Scanning dependencies of target caffe2_detectron_custom_ops
[ 12%] Building CXX object CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/pool_points_interp.cc.o
In file included from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/utils/math.h:18:0,
from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/utils/filler.h:8,
from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/core/operator_schema.h:16,
from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/core/net.h:18,
from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/core/operator.h:17,
from /home/xdn/project/Gaze360/densepose/detectron/ops/pool_points_interp.h:15,
from /home/xdn/project/Gaze360/densepose/detectron/ops/pool_points_interp.cc:10:
/home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/utils/math/broadcast.h:11:1: error: ‘TORCH_API’ does not name a type
TORCH_API void AffineChannel(
^
In file included from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/utils/math.h:19:0,
from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/utils/filler.h:8,
from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/core/operator_schema.h:16,
from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/core/net.h:18,
from /home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/core/operator.h:17,
from /home/xdn/project/Gaze360/densepose/detectron/ops/pool_points_interp.h:15,
from /home/xdn/project/Gaze360/densepose/detectron/ops/pool_points_interp.cc:10:
/home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/utils/math/elementwise.h:11:1: error: ‘TORCH_API’ does not name a type
TORCH_API void Exp(int N, const T* X, T* Y, Context* context);
^
/home/xdn/anaconda3/envs/gaze360-3.7-3/lib/python3.7/site-packages/torch/include/caffe2/utils/math/elementwise.h:13:1: error: ‘TORCH_API’ does not name a type
TORCH_API void Log(int N, const T* X, T* Y, Context* context);…………
原因分析:
我的pytorch本来是通过conda安装的,utils/math这个文件是我们最后下载pytorch源码拷贝进去的(相当于一个补丁)。我想起来第一遍安装时没有这个问题。于是看了我下载的pytorch/caffe2/utils/math/elementwise.h和之前第一次安装时下载的有啥区别,发现真的有:
一个是TORCH_API void Exp(int N, const T* X, T* Y, Context* context); 一个是CAFFE2_API void Exp(int N, const T* X, T* Y, Context* context);
问题发现,应该是两次下载的pytorch源码不同(可能是这个源码更新了吧)
所以我使用了早版本的pytorch源码中的pytorch/caffes/utils/threadpool 和 pytorch/caffes/utils/math。问题解决了~
我把这个utils文件放在网盘里啦。
链接:https://pan.baidu.com/s/1LwzCpCxCNRUG26M3u8nbcg
提取码:tlxr