Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserWarning: video_reader video backend is not available #2216

Closed
fepegar opened this issue May 14, 2020 · 11 comments
Closed

UserWarning: video_reader video backend is not available #2216

fepegar opened this issue May 14, 2020 · 11 comments

Comments

@fepegar
Copy link
Contributor

fepegar commented May 14, 2020

馃悰 Bug

I get a "video_reader video backend is not available" warning when trying to set it.

To Reproduce

Steps to reproduce the behavior:

$ conda create -n tv python -y && conda activate tv
$ pip install numpy                                                                                               
$ pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
$ python -c "import torchvision; torchvision.set_video_backend('video_reader')"

Output:

[('__call__', <function LevelMapper.__call__ at 0x123462820>), ('__init__', <function LevelMapper.__init__ at 0x123462790>)]
[('__call__', <function BalancedPositiveNegativeSampler.__call__ at 0x123649280>), ('__init__', <function BalancedPositiveNegativeSampler.__init__ at 0x1236491f0>)]
[('__init__', <function BoxCoder.__init__ at 0x123657af0>), ('decode', <function BoxCoder.decode at 0x123657ca0>), ('decode_single', <function BoxCoder.decode_single at 0x123657d30>), ('encode', <function BoxCoder.encode at 0x123657b80>), ('encode_single', <function BoxCoder.encode_single at 0x123657c10>)]
[('__call__', <function Matcher.__call__ at 0x1234628b0>), ('__init__', <function Matcher.__init__ at 0x123649160>), ('set_low_quality_matches_', <function Matcher.set_low_quality_matches_ at 0x123462700>)]
[('__init__', <function ImageList.__init__ at 0x123657e50>), ('to', <function ImageList.to at 0x123657a60>)]
[('__init__', <function Timebase.__init__ at 0x123b8cca0>)]
[('__init__', <function VideoMetaData.__init__ at 0x123b8ce50>)]
/usr/local/Caskroom/miniconda/base/envs/tv/lib/python3.8/site-packages/torchvision/__init__.py:65: UserWarning: video_reader video backend is not available
  warnings.warn("video_reader video backend is not available")

I'm using the nightly version because I hoped this would be fixed in #2183.

I get only the warning (i.e. last two lines) in the stable pip release.

Expected behavior

No warning when I set the backend.

Environment

PyTorch version: 1.6.0.dev20200514
Is debug build: No
CUDA used to build PyTorch: None

OS: Mac OSX 10.15.4
GCC version: Could not collect
CMake version: version 3.17.2

Python version: 3.8
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip] numpy==1.18.4
[pip] torch==1.6.0.dev20200514
[pip] torchvision==0.7.0.dev20200514
[conda] numpy 1.18.4 pypi_0 pypi
[conda] torch 1.6.0.dev20200514 pypi_0 pypi
[conda] torchvision 0.7.0.dev20200514 pypi_0 pypi

Additional context

Discovered when I tried following @bjuncek advice in #1884.

@fmassa
Copy link
Member

fmassa commented May 15, 2020

Hi,

This is expected, as we don't ship video_reader backend in the pre-compiled binaries.
For enabling video_reader, you'll need to compile torchvision from source following the "From source" section in https://github.com/pytorch/vision#installation

Note that it will require ffmpeg installed in your system for the video_reader to be available. You can obtain it by installing pyav from conda.

As such, I'm closing this issue but let us know if you have issues compiling torchvision from source.

@fepegar
Copy link
Contributor Author

fepegar commented May 15, 2020

I'll try building.

This is expected, as we don't ship video_reader backend in the pre-compiled binaries.

Is this documented anywhere?

@fepegar
Copy link
Contributor Author

fepegar commented May 15, 2020

Got this after building from source and running the command I mentioned above.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/vision/torchvision/__init__.py", line 5, in <module>
    from torchvision import models
  File "/private/tmp/vision/torchvision/models/__init__.py", line 12, in <module>
    from . import detection
  File "/private/tmp/vision/torchvision/models/detection/__init__.py", line 1, in <module>
    from .faster_rcnn import *
  File "/private/tmp/vision/torchvision/models/detection/faster_rcnn.py", line 7, in <module>
    from torchvision.ops import misc as misc_nn_ops
  File "/private/tmp/vision/torchvision/ops/__init__.py", line 1, in <module>
    from .boxes import nms, box_iou
  File "/private/tmp/vision/torchvision/ops/boxes.py", line 8, in <module>
    def nms(boxes, scores, iou_threshold):
  File "/usr/local/Caskroom/miniconda/base/envs/tv/lib/python3.8/site-packages/torch/jit/__init__.py", line 1290, in script
    fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))
RuntimeError:
object has no attribute nms:
  File "/private/tmp/vision/torchvision/ops/boxes.py", line 41
        by NMS, sorted in decreasing order of scores
    """
    return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
           ~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE

Here's my environment:

PyTorch version: 1.5.0
Is debug build: No
CUDA used to build PyTorch: None

OS: Mac OSX 10.15.4
GCC version: Could not collect
CMake version: version 3.17.2

Python version: 3.8
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip] numpy==1.18.4
[pip] torch==1.5.0
[conda] numpy                     1.18.4                   pypi_0    pypi
[conda] torch                     1.5.0                    pypi_0    pypi

@fmassa
Copy link
Member

fmassa commented May 15, 2020

@fepegar

Is this documented anywhere?

it is explained in the release notes https://github.com/pytorch/vision/releases/tag/v0.4.2 but maybe we can make it more explicit in the error message

About the error you got, looks like the compilation didn't succeed properly (you might have had error messages showing up).
I would suggest first uninstalling torchvision and then re-compiling it from source.

@fepegar
Copy link
Contributor Author

fepegar commented May 15, 2020

maybe we can make it more explicit in the error message

Let me know if there's anything I can do to help.

I would suggest first uninstalling torchvision and then re-compiling it from source.

I compiled it from source in a fresh environment.

looks like the compilation didn't succeed properly (you might have had error messages showing up).

You're right. I'll see if there are issues about that and, if not, I'll create one.

@fmassa
Copy link
Member

fmassa commented May 18, 2020

@fepegar if you could send a PR modifying the error message with video_reader backend mentioning that you need to compile torchvision from source to get it, it would be great!

@fepegar
Copy link
Contributor Author

fepegar commented May 18, 2020

Ok, I will! But should I wait until #2220 is resolved?

@fmassa
Copy link
Member

fmassa commented May 18, 2020

I'm looking at #2220 now, and I think I reproduced the error

@fmassa
Copy link
Member

fmassa commented May 18, 2020

@fepegar you can send the PR improving the error message right now as it's independent on #2220 being fixed or not

@JuanFMontesinos
Copy link

Hi, I was digging into video_reader backend and this may be interesting #2490

@mrdvince
Copy link
Contributor

Hi, just an addition to this, Compiling torchvision requires a nightly version of PyTorch, this should be in the readme (took me a few to figure out why the compilation was failing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants