-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Branch
main branch (1.x version, such as v1.0.0
, or dev-1.x
branch)
Prerequisite
- I have searched Issues and Discussions but cannot get the expected help.
- I have read the documentation but cannot get the expected help.
- The bug has not been fixed in the latest version.
Environment
OS: macOS (arm64, Apple Silicon M-series chip)
Python Version: 3.8 (managed via Conda)
Target Project: MMAction2
Problematic Dependency: decord
Describe the bug
Hi MMAction2 Team and Community,
I recently went through the process of installing MMAction2 on a macOS arm64 (Apple Silicon) machine and encountered significant difficulties with the decord
dependency. Standard installation methods via pip or conda for decord
failed on this platform.
After extensive troubleshooting, I found a viable solution that involves using the eva-decord
fork and specific versions of dependencies. I'm sharing this detailed process here to help other users facing similar issues and potentially to inform future documentation Verbesserungen.
Problem Summary:
The primary issue was that pip
could not find a suitable distribution for decord
because:
- The PyPI JSON Simple API for
decord
did not list any source distributions (.tar.gz). - No pre-compiled
decord
wheels forosx-arm64
were available on PyPI. - Mainstream Conda channels (dmlc, conda-forge) also lacked
osx-arm64
packages fordecord
. - Compiling the original
dmlc/decord
from source failed due to API incompatibilities with the latest FFmpeg (7.x).
Environment:
- OS: macOS (arm64, Apple Silicon M-series chip)
- Python Version: 3.8 (managed via Conda)
- Target Project: MMAction2
- Problematic Dependency:
decord
Problem Description:
Attempting to install MMAction2 on a macOS arm64 system via pip install -v -e .
failed because its dependency decord>=0.4.1
could not be satisfied. The error message was ERROR: Could not find a version that satisfies the requirement decord>=0.4.1 (from mmaction2) (from versions: none)
.
Troubleshooting and Resolution Process:
-
Initial Diagnosis:
pip
Fails to Finddecord
- Attempts with
pip install "decord>=0.4.1" -v
andpip index versions decord
both reported no matching distribution. curl -v https://pypi.org/simple/decord/
confirmed that network connectivity to PyPI Simple Index (HTML format) was working and contained entries fordecord
.- However,
curl -H "Accept: application/vnd.pypi.simple.v1+json" https://pypi.org/simple/decord/
revealed that the JSON Simple API response from PyPI did not list any source distributions (.tar.gz
) fordecord
; it only listed wheel files. This was identified as the root cause forpip
not finding a source package to compile, even with the--no-binary :all:
flag.
- Attempts with
-
Attempting Conda Installation of
decord
conda install -c dmlc decord
failed withPackagesNotFoundError
(no osx-arm64 package in the dmlc channel).conda install -c conda-forge decord
also failed withPackagesNotFoundError
(no osx-arm64 package in the conda-forge channel).- Conclusion: At the time, mainstream Conda channels did not provide pre-compiled
decord
packages forosx-arm64
.
-
Attempting to Build Original
dmlc/decord
from Source- Cloned the repository:
git clone --recursive https://github.com/dmlc/decord.git
. - Installed build dependencies: Xcode Command Line Tools, Homebrew, and then
brew install cmake ffmpeg libomp
.- An initial network issue (
Could not resolve host: github.com
) was resolved by fixing local network/DNS settings.
- An initial network issue (
- Build Failure: When attempting to compile with the latest FFmpeg installed via Homebrew (version 7.x at the time),
cmake
could find FFmpeg, but themake
stage failed with compilation errors related to symbols likeAVBSFContext
andav_bsf_free
, which had changed in newer FFmpeg APIs. This indicated an incompatibility between the originaldecord
source code and FFmpeg 7.x.
- Cloned the repository:
-
Switching to the
eva-decord
Fork- Based on a suggestion, switched to the
georgia-tech-db/eva-decord
fork (https://github.com/georgia-tech-db/eva-decord), which claimed support for Apple Silicon and newer FFmpeg versions (5.x, 6.x). - Cloned the fork:
git clone --recursive https://github.com/georgia-tech-db/eva-decord.git
.
- Based on a suggestion, switched to the
-
Adjusting FFmpeg Version for
eva-decord
Compatibility- An initial attempt to compile
eva-decord
with FFmpeg 7.x resulted incmake
success, butmake
failed during the compilation ofsrc/audio/audio_reader.cc
. Errors indicated missing members likechannels
inAVCodecParameters
andchannel_layout
inAVFrame
, pointing to an API incompatibility betweeneva-decord
(primarily supporting up to FFmpeg 6.x) and FFmpeg 7.x. - Solution: Downgrade FFmpeg.
- Uninstalled FFmpeg 7.x:
brew uninstall ffmpeg
- Installed FFmpeg 6.x (Homebrew provided an
ffmpeg@6
package):brew install ffmpeg@6
(which installed version 6.1.2_10). - Updated the
PKG_CONFIG_PATH
environment variable to point to thepkgconfig
directory of the newly installedffmpeg@6
:unset PKG_CONFIG_PATH export PKG_CONFIG_PATH="$(brew --prefix ffmpeg@6)/lib/pkgconfig:$PKG_CONFIG_PATH"
- Uninstalled FFmpeg 7.x:
- An initial attempt to compile
-
Building and Installing
eva-decord
- In the
eva-decord
source directory, compiled using the downgraded FFmpeg 6.x:The compilation process showed several warnings about deprecated FFmpeg APIs but no errors, eventually succeeding withcd eva-decord rm -rf build mkdir build && cd build cmake .. -DUSE_CUDA=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} make -j8 # or make
[100%] Built target decord
. The C++ core library was successfully built. - Installing Python Bindings - Crucial Step:
- An initial
pip install .
from theeva-decord
root directory failed, assetup.py
was not present there. - Identified Issue: After successfully building and installing
eva-decord
(from itspython/
subdirectory),pip list
showed the package name aseva-decord
, notdecord
. This would cause MMAction2's dependency resolver to fail. - Solution:
- Navigate to the
eva-decord/python/
directory. - Edit the
setup.py
file. Modify thename
parameter in thesetup()
function call fromname='eva-decord'
toname='decord'
. - Save
setup.py
. - Uninstall any previously installed versions of
eva-decord
ordecord
:pip uninstall eva-decord -y pip uninstall decord -y
- In the
eva-decord/python/
directory, reinstall using the modifiedsetup.py
:pip install . -vvv
- Navigate to the
- Verification:
pip list | grep decord
then showeddecord 0.6.0
. In Python,import decord; print(decord.__name__, decord.__version__)
confirmeddecord 0.6.0
.
- An initial
- In the
-
Installing MMAction2
- Navigated back to the
mmaction2
source directory. - Executed
pip install -v -e .
. - Success! The MMAction2 dependency resolver found the installed
decord 0.6.0
package and proceeded to install MMAction2 and its other dependencies successfully.
- Navigated back to the
Summary and Recommendations:
- Resolving the
decord
dependency for projects like MMAction2 on macOS arm64 can be challenging due to the lack of official source distributions (sdist) on PyPI and limited arm64 support in Conda channels fordecord
. - The
georgia-tech-db/eva-decord
fork serves as a viable alternative, offering better support for Apple Silicon and more recent FFmpeg versions. - Ensuring FFmpeg version compatibility is crucial when building
eva-decord
(or the originaldecord
) from source. Current experience suggests FFmpeg 6.x (e.g.,ffmpeg@6
from Homebrew) works well witheva-decord
. - Key Fix: If using a
decord
fork that uses a different package name in itssetup.py
(likeeva-decord
), it's necessary to modify itsname
parameter todecord
. This allows projects like MMAction2, which depend on the standarddecord
package name, to correctly identify the dependency. - Correctly setting the
PKG_CONFIG_PATH
environment variable to point to thelib/pkgconfig
directory of the chosen FFmpeg version is essential for CMake to locate the FFmpeg libraries.
Hopefully, this report will assist other developers facing similar challenges on macOS arm64.
Reproduces the problem - code sample
No response
Reproduces the problem - command or script
No response
Reproduces the problem - error message
No response
Additional information
No response