Fix: Standardize torchtext shared library loading path for multi-platform compatibility#122
Open
StarxSky wants to merge 2 commits into
Open
Fix: Standardize torchtext shared library loading path for multi-platform compatibility#122StarxSky wants to merge 2 commits into
StarxSky wants to merge 2 commits into
Conversation
…dist-packages/torchtext/lib/libtorchtext.so
Added a custom write_video function using OpenCV as a replacement for the removed torchvision.io.write_video. Included error handling for OpenCV import.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Standardize torchtext shared library loading path for multi-platform compatibility
Summary
This PR resolves a critical
OSErrorthat occurs when launchingml-cvnetson certain Unix-like or macOS environments (specifically inside localized Python virtual environments or custom containers). The error is triggered when the backend explicitly looks for thetorchtextshared library at a hardcoded global path (/usr/local/lib/...) instead of adapting to dynamic relative installation paths.Root Cause
The environment or integration logic attempted to load the standard
torchtextshared library using an rigid absolute path:On modern development environments, such as macOS (Apple Silicon via Homebrew,
pyenv, orconda) and isolated standard virtual environments, the activesite-packagesordist-packagesare not located under the global system root/usr/local/lib/. This absolute mapping causes runtime library loading to fail abruptly during framework initialization.Changes
os.pathor Python'simportlib.util/sitemodules to locatelibtorchtextrelative to the actual active Python environment dynamically, removing reliance on a hardcoded absolute prefix.commonlibrary untouched and stable.How Has This Been Tested?
ml-cvnetscore pipelines, trainers, and model architectures initialize successfully without throwing dynamic link library loading exceptions.Checklist
commonutilities.