1

我正在尝试安装 pytorch

python setup.py install

但它失败了,因为它无法定位libavutil/motion_vector.h

[ 66%] Building CXX object caffe2/CMakeFiles/torch.dir/video/video_input_op.cc.o
In file included from /root/pytorch/caffe2/video/video_input_op.h:15:0,
                 from /root/pytorch/caffe2/video/video_input_op.cc:1:
/root/pytorch/caffe2/video/video_decoder.h:15:37: fatal error: libavutil/motion_vector.h: No such file or directory
 #include <libavutil/motion_vector.h>
                                     ^
compilation terminated.
[ 66%] Building CXX object caffe2/CMakeFiles/torch.dir/video/video_io.cc.o
make[2]: *** [caffe2/CMakeFiles/torch.dir/video/video_input_op.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /root/pytorch/caffe2/video/video_io.h:6:0,
                 from /root/pytorch/caffe2/video/video_io.cc:1:
/root/pytorch/caffe2/video/video_decoder.h:15:37: fatal error: libavutil/motion_vector.h: No such file or directory
 #include <libavutil/motion_vector.h>
                                     ^
compilation terminated.
make[2]: *** [caffe2/CMakeFiles/torch.dir/video/video_io.cc.o] Error 1
make[1]: *** [caffe2/CMakeFiles/torch.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 759, in <module>
    build_deps()
  File "setup.py", line 321, in build_deps
    cmake=cmake)
  File "/root/pytorch/tools/build_pytorch_libs.py", line 63, in build_caffe2
    cmake.build(my_env)
  File "/root/pytorch/tools/setup_helpers/cmake.py", line 330, in build
    self.run(build_args, my_env)
  File "/root/pytorch/tools/setup_helpers/cmake.py", line 143, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '12']' returned non-zero exit status 2

到目前为止我已经尝试过:

还有其他想法吗?

4

2 回答 2

0

缺少库头通常表示缺少开发包。对于 Debian 和 Ubuntu,您要查找的软件包很可能称为libavutil-dev. 尝试使用包管理器安装此包并重新运行 pip 安装。对于 Fedora 和 SUSE,软件包应以-devel.

于 2019-09-16T07:21:40.617 回答
0

对于 conda 安装,首先创建一个 env,这非常重要,因为您已经使用了 pip(pip 会阻止 conda 看到它是基本 env)。

conda create -n pytorch_env python=3.7
source activate pytorch_env

conda install -c anaconda mkl

然后安装pytorch和torch vision

conda install -c pytorch pytorch torchvision

您可能想以管理员身份运行这些,因为我不需要。您需要通过以下方式安装 Caffe

conda install -c caffe2 pytorch-nightly

caffe2 安装有一个错误(不是每晚)。更正如下,

conda create -n pytorch_env python=3.6
source activate pytorch_env
conda install -c caffe2 caffe2

完成此操作后,我发现opencvffmpeg加载了.. 我只能假设它们是 caffe2 的依赖项。因此,总而言之,是的,一旦解决了 3.7 -> 3.6 错误,您就可以通过 conda 轻松完成整个事情

于 2019-09-16T14:49:22.767 回答