简体   繁体   中英

Installing pytorch fails - fatal error: libavutil/motion_vector.h: No such file or directory

I'm trying to install pytorch

python setup.py install

but it fails as it can't locate 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

What I've tried so far:

Any other ideas?

Missing headers of libraries commonly indicate missing development packages. For Debian and Ubuntu the package you are looking for is most likely called libavutil-dev . Try installing this package using you package manager and re-running the pip installation. For Fedora and SUSE the package should end with -devel .

For conda installation, firstly create an env, very important because you've used pip (pip stops conda seeing it's base env).

conda create -n pytorch_env python=3.7
source activate pytorch_env

conda install -c anaconda mkl

Then install pytorch and torch vision

conda install -c pytorch pytorch torchvision

You might want to run these as administrator, for me not needed. You will need to install Caffe via

conda install -c caffe2 pytorch-nightly

There's a bug for caffe2 installation (not nightly). Corrected below,

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

Having done this I found opencv and ffmpeg were loaded .. I can only assume they were a dependency of caffe2. Thus in summary yes you can do the whole thing easily via conda once the 3.7 -> 3.6 bug is resolved

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM