fix: Make libcudart.so loading more robust for Docker environments#152
Open
chan-yuu wants to merge 1 commit into
Open
fix: Make libcudart.so loading more robust for Docker environments#152chan-yuu wants to merge 1 commit into
chan-yuu wants to merge 1 commit into
Conversation
Problem:
The distributed training initialization fails with OSError when running in Docker
containers that have CUDA runtime but not the full toolkit, because the code
directly calls ctypes.CDLL('libcudart.so') which may fail if:
- LD_LIBRARY_PATH is not set correctly
- Only versioned .so files exist (e.g., libcudart.so.12.x)
- CUDA libraries are in non-standard paths
Solution:
- Add _load_libcudart() helper that searches multiple paths:
- Standard CUDA paths (/usr/local/cuda/lib64)
- PyTorch bundled CUDA libraries
- System library paths
- Versioned .so files
- Gracefully handle missing library with a warning instead of crash
- L2 cache optimization is optional, so training can proceed without it
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.
Problem
The distributed training initialization fails with
OSError: libcudart.so: cannot open shared object filewhen running in Docker containers that have CUDA runtime but notthe full toolkit installed.
The current code directly calls
ctypes.CDLL("libcudart.so")which may fail if:LD_LIBRARY_PATHis not set correctly.sofiles exist (e.g.,libcudart.so.x)Solution
_load_libcudart()helper function that searches multiple paths:/usr/local/cuda/lib64)/usr/lib/x86_64-linux-gnu).sofiles via glob patternTesting
Tested with Docker containers using NVIDIA CUDA runtime-only images.
