question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Torchvision doesn't compile against ffmpeg-5

See original GitHub issue

🐛 Describe the bug

Steps to reproduce:

  1. Install torchvision nightly from conda: conda install -y -c pytorch-nightly torchvision. This will also install ffmpeg-5 from conda
  2. Compile torchvision from source: python setup.py install
  3. The compile fails with the following error:
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:21:36: error: use of enum ‘AVLockOp’ without previous declaration
 int ffmpeg_lock(void** mutex, enum AVLockOp op) {
                                    ^~~~~~~~
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp: In function ‘int ffmpeg::{anonymous}::ffmpeg_lock(void**, int)’:
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:24:10: error: ‘AV_LOCK_CREATE’ was not declared in this scope
     case AV_LOCK_CREATE:
          ^~~~~~~~~~~~~~
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:24:10: note: suggested alternative: ‘AV_LOG_TRACE’
     case AV_LOCK_CREATE:
          ^~~~~~~~~~~~~~
          AV_LOG_TRACE
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:27:10: error: ‘AV_LOCK_OBTAIN’ was not declared in this scope
     case AV_LOCK_OBTAIN:
          ^~~~~~~~~~~~~~
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:27:10: note: suggested alternative: ‘CLOCK_TAI’
     case AV_LOCK_OBTAIN:
          ^~~~~~~~~~~~~~
          CLOCK_TAI
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:30:10: error: ‘AV_LOCK_RELEASE’ was not declared in this scope
     case AV_LOCK_RELEASE:
          ^~~~~~~~~~~~~~~
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:30:10: note: suggested alternative: ‘AV_LOG_VERBOSE’
     case AV_LOCK_RELEASE:
          ^~~~~~~~~~~~~~~
          AV_LOG_VERBOSE
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:33:10: error: ‘AV_LOCK_DESTROY’ was not declared in this scope
     case AV_LOCK_DESTROY:
          ^~~~~~~~~~~~~~~
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:33:10: note: suggested alternative: ‘AV_LOG_ERROR’
     case AV_LOCK_DESTROY:
          ^~~~~~~~~~~~~~~
          AV_LOG_ERROR
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp: In lambda function:
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:206:5: error: ‘av_lockmgr_register’ was not declared in this scope
     av_lockmgr_register(&ffmpeg_lock);
     ^~~~~~~~~~~~~~~~~~~
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp: In member function ‘virtual bool ffmpeg::Decoder::init(const ffmpeg::DecoderParameters&, ffmpeg::DecoderInCallback&&, std::vector<ffmpeg::DecoderMetadata>*)’:
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:280:33: error: invalid conversion from ‘const AVInputFormat*’ to ‘AVInputFormat*’ [-fpermissive]
       fmt = av_find_input_format(fmtName);
             ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp: In member function ‘int ffmpeg::Decoder::getFrame(size_t)’:
/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:509:27: warning: ‘void av_init_packet(AVPacket*)’ is deprecated [-Wdeprecated-declarations]
   av_init_packet(&avPacket);
                           ^
In file included from /home/ec2-user/anaconda3/envs/pr-ci/include/libavcodec/avcodec.h:45:0,
                 from /home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/defs.h:12,
                 from /home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/seekable_buffer.h:3,
                 from /home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.h:5,
                 from /home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder/decoder.cpp:1:
/home/ec2-user/anaconda3/envs/pr-ci/include/libavcodec/packet.h:506:6: note: declared here
 void av_init_packet(AVPacket *pkt);
      ^~~~~~~~~~~~~~
[15/16] c++ -MMD -MF /home/ec2-user/nvme/srcs/vision/build/temp.linux-x86_64-3.7/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video_reader/video_reader.o.d -pthread -B /home/ec2-user/anaconda3/envs/pr-ci/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video_reader -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc -I/home/ec2-user/anaconda3/envs/pr-ci/include -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/TH -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/TH -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/THC -I/home/ec2-user/anaconda3/envs/pr-ci/include/python3.7m -c -c /home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video_reader/video_reader.cpp -o /home/ec2-user/nvme/srcs/vision/build/temp.linux-x86_64-3.7/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video_reader/video_reader.o -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=video_reader -D_GLIBCXX_USE_CXX11_ABI=1
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
[16/16] c++ -MMD -MF /home/ec2-user/nvme/srcs/vision/build/temp.linux-x86_64-3.7/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video/video.o.d -pthread -B /home/ec2-user/anaconda3/envs/pr-ci/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/decoder -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video_reader -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc -I/home/ec2-user/anaconda3/envs/pr-ci/include -I/home/ec2-user/nvme/srcs/vision/torchvision/csrc -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/TH -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/TH -I/home/ec2-user/anaconda3/envs/pr-ci/lib/python3.7/site-packages/torch/include/THC -I/home/ec2-user/anaconda3/envs/pr-ci/include/python3.7m -c -c /home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video/video.cpp -o /home/ec2-user/nvme/srcs/vision/build/temp.linux-x86_64-3.7/home/ec2-user/nvme/srcs/vision/torchvision/csrc/io/video/video.o -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=video_reader -D_GLIBCXX_USE_CXX11_ABI=1
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++

The error doesn’t happen with an older version of ffmpeg e.g. 4.4.1

Versions

Torchvision nightly + main branch

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
r-barnescommented, Mar 20, 2022

ffmpeg 4.1 under LLVM-12 has instances of undefined behaviour due to null pointer arithmetic which cause failures under address sanitizer testing, so having ffmpeg 5 compatibility is pretty important.

1reaction
bjuncekcommented, Mar 17, 2022

@datumbox sorry for the delay – it is on my list for tomorrow

Read more comments on GitHub >

github_iconTop Results From Across the Web

When I in pytorch on the official website to install torch and ...
When I in pytorch on the official website to install torch and vision, I can't use CUDA. if I use pytorch on this...
Read more >
Installing torchvision from source libavcodec/avcodec.h not ...
I am trying to install torchvision from source, was able to get pytorch installed (needed it from source to use GPU) and now...
Read more >
TorchVision不编译FFMPEG-5:Torchvision doesn't compile ...
Torchvision doesn't compile against ffmpeg-5 Describe the bug 重现步骤: Install torchvision nightly from conda: conda install-y-c ...
Read more >
How to install torchvision from source? - vision - PyTorch Forums
The build output indicates that FFMPEG is not actually being used. Compiling extensions with following flags: WITH_CPP_MODELS_TEST: False ...
Read more >
Install PyTorch on Jetson Nano - Q-engineering
A thorough guide on how to install PyTorch 1.8.1 on your Jetson Nano ... If there is not enough swap memory, the compilation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found