Skip to content

Conversation

@JAEarly
Copy link

@JAEarly JAEarly commented Nov 13, 2025

Added when investigated issues related to #1023.
Doesn't fix the underlying issue, but improves error reporting for users.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2025
@JAEarly JAEarly changed the title Improve ffmpeg load error reporting Improve load_torchcodec_shared_libraries error reporting Nov 13, 2025
@NicolasHug
Copy link
Contributor

Thanks for the PR @JAEarly

Can you share what the old and new tracebacks look like?

@JAEarly
Copy link
Author

JAEarly commented Nov 18, 2025

This should help with issues such as #1006

@JAEarly
Copy link
Author

JAEarly commented Nov 18, 2025

Old:

>       raise RuntimeError(
            f"""Could not load libtorchcodec. Likely causes:
              1. FFmpeg is not properly installed in your environment. We support
                 versions 4, 5, 6, and 7 on all platforms, and 8 on Mac and Linux.
              2. The PyTorch version ({torch.__version__}) is not compatible with
                 this version of TorchCodec. Refer to the version compatibility
                 table:
                 https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
              3. Another runtime dependency; see exceptions below.
            The following exceptions were raised as we tried to load libtorchcodec:
            """
            f"{traceback}"
        )
E       RuntimeError: Could not load libtorchcodec. Likely causes:
E                 1. FFmpeg is not properly installed in your environment. We support
E                    versions 4, 5, 6, and 7 on all platforms, and 8 on Mac and Linux.
E                 2. The PyTorch version (2.9.1) is not compatible with
E                    this version of TorchCodec. Refer to the version compatibility
E                    table:
E                    https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
E                 3. Another runtime dependency; see exceptions below.
E               The following exceptions were raised as we tried to load libtorchcodec:
E
E       [start of libtorchcodec loading traceback]
E       FFmpeg version 8: Could not load this library: /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core8.dylib
E       FFmpeg version 7: Could not load this library: /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core7.dylib
E       FFmpeg version 6: Could not load this library: /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core6.dylib
E       FFmpeg version 5: Could not load this library: /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core5.dylib
E       FFmpeg version 4: Could not load this library: /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core4.dylib
E       [end of libtorchcodec loading traceback].

.venv/lib/python3.10/site-packages/torchcodec/_core/ops.py:69: RuntimeError

New:

>       raise RuntimeError(
            f"""Could not load libtorchcodec. Likely causes:
              1. FFmpeg is not properly installed in your environment. We support
                 versions 4, 5, 6, and 7 on all platforms, and 8 on Mac and Linux.
              2. The PyTorch version ({torch.__version__}) is not compatible with
                 this version of TorchCodec. Refer to the version compatibility
                 table:
                 https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
              3. Another runtime dependency; see exceptions below.
            The following exceptions were raised as we tried to load libtorchcodec:
            """
            f"{full_traceback}"
        )
E       RuntimeError: Could not load libtorchcodec. Likely causes:
E                 1. FFmpeg is not properly installed in your environment. We support
E                    versions 4, 5, 6, and 7 on all platforms, and 8 on Mac and Linux.
E                 2. The PyTorch version (2.9.1) is not compatible with
E                    this version of TorchCodec. Refer to the version compatibility
E                    table:
E                    https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
E                 3. Another runtime dependency; see exceptions below.
E               The following exceptions were raised as we tried to load libtorchcodec:
E
E       [start of libtorchcodec loading traceback]
E       FFmpeg version 8: Traceback (most recent call last):
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torch/_ops.py", line 1488, in load_library
E           ctypes.CDLL(path)
E         File "/nix/store/ra1l4hyhxw3zlq62y8vg6fpxysq9ln6s-python3-3.10.16/lib/python3.10/ctypes/__init__.py", line 374, in __init__
E           self._handle = _dlopen(self._name, mode)
E       OSError: dlopen(/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core8.dylib, 0x0006): Library not loaded: @rpath/libavutil.60.dylib
E         Referenced from: <5D38709A-E4F4-3C1B-A53D-CBBDCAC56C91> /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core8.dylib
E         Reason: no LC_RPATH's found
E
E       The above exception was the direct cause of the following exception:
E
E       Traceback (most recent call last):
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/_core/ops.py", line 52, in load_torchcodec_shared_libraries
E           torch.ops.load_library(core_library_path)
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torch/_ops.py", line 1490, in load_library
E           raise OSError(f"Could not load this library: {path}") from e
E       OSError: Could not load this library: /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core8.dylib
E
E       FFmpeg version 7: Traceback (most recent call last):
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torch/_ops.py", line 1488, in load_library
E           ctypes.CDLL(path)
E         File "/nix/store/ra1l4hyhxw3zlq62y8vg6fpxysq9ln6s-python3-3.10.16/lib/python3.10/ctypes/__init__.py", line 374, in __init__
E           self._handle = _dlopen(self._name, mode)
E       OSError: dlopen(/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core7.dylib, 0x0006): Library not loaded: @rpath/libavutil.59.dylib
E         Referenced from: <D3303F7C-612B-31D2-BBE7-8824565D3187> /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core7.dylib
E         Reason: no LC_RPATH's found
E
E       The above exception was the direct cause of the following exception:
E
E       Traceback (most recent call last):
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/_core/ops.py", line 52, in load_torchcodec_shared_libraries
E           torch.ops.load_library(core_library_path)
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torch/_ops.py", line 1490, in load_library
E           raise OSError(f"Could not load this library: {path}") from e
E       OSError: Could not load this library: /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core7.dylib
E
E       FFmpeg version 6: Traceback (most recent call last):
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torch/_ops.py", line 1488, in load_library
E           ctypes.CDLL(path)
E         File "/nix/store/ra1l4hyhxw3zlq62y8vg6fpxysq9ln6s-python3-3.10.16/lib/python3.10/ctypes/__init__.py", line 374, in __init__
E           self._handle = _dlopen(self._name, mode)
E       OSError: dlopen(/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core6.dylib, 0x0006): Library not loaded: @rpath/libavutil.58.dylib
E         Referenced from: <AD6D6E09-CED2-3AB1-A98A-AAAE9D2F0689> /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core6.dylib
E         Reason: no LC_RPATH's found
E
E       The above exception was the direct cause of the following exception:
E
E       Traceback (most recent call last):
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/_core/ops.py", line 52, in load_torchcodec_shared_libraries
E           torch.ops.load_library(core_library_path)
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torch/_ops.py", line 1490, in load_library
E           raise OSError(f"Could not load this library: {path}") from e
E       OSError: Could not load this library: /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core6.dylib
E
E       FFmpeg version 5: Traceback (most recent call last):
E         File "/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torch/_ops.py", line 1488, in load_library
E           ctypes.CDLL(path)
E         File "/nix/store/ra1l4hyhxw3zlq62y8vg6fpxysq9ln6s-python3-3.10.16/lib/python3.10/ctypes/__init__.py", line 374, in __init__
E           self._handle = _dlopen(self._name, mode)
E       OSError: dlopen(/Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core5.dylib, 0x0006): Library not loaded: @rpath/libavutil.57.dylib
E         Referenced from: <AD04BD63-F8C4-3823-98F4-1D58CB19DB81> /Users/user/Projects/some_project/.venv/lib/python3.10/site-packages/torchcodec/libtorchcodec_core5.dylib
E         Reason: no LC_RPATH's found
E
E       The above exception was the direct cause of the following exception:
E

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

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants