-
Notifications
You must be signed in to change notification settings - Fork 70
[WIP] Feature/cuslide2 nvimagecodec api implementation #957
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
cdinea
wants to merge
16
commits into
rapidsai:main
Choose a base branch
from
cdinea:feature/cuslide2-nvimagecodec-api-implementation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] Feature/cuslide2 nvimagecodec api implementation #957
cdinea
wants to merge
16
commits into
rapidsai:main
from
cdinea:feature/cuslide2-nvimagecodec-api-implementation
Conversation
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
….com/cdinea/cucim into feature/cuslide2-nvimagecodec-plugin
… decoder Related: Performance test failures in test_read_region_memory_usage.py
- Fix libjpeg-turbo cmake configuration for both cuslide and cuslide2 - Update nvimgcodec cmake dependency configuration - Update examples CMakeLists - Update build scripts and documentation
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.
nvImageCodec Integration
🐛 Problem Summary
Performance tests for the cuslide2 plugin were failing with two critical bugs:
num_workers > 1)🔧 What This PR Fixes
1. Thread Safety Issue → Segmentation Faults
Root Cause:
NvImageCodecManagersingleton used a shared decoder instancetest_tiff_iteratorSolution:
std::mutex decoder_mutex_to protect decoder operationsnvimgcodecDecoderDecode()calls now usestd::lock_guard<std::mutex>Code Changes:
2. Memory Leak Issue → 19 GB Memory Growth
Root Cause:
cucim_malloc()stored in smart pointersmalloc()/cudaMalloc()test_read_random_region_cpu_memleak, ~19 GB leak intest_tiff_iteratorSolution:
*dest != nullptr)decode_jpeg_nvimgcodec()anddecode_jpeg2k_nvimgcodec()Code Changes:
✅ Test Results
Before Fixes
After Fixes
Specific Test Results
test_read_region_cuda_memleaktest_read_region_cpu_memleaktest_read_random_region_cpu_memleak[jpeg]test_read_random_region_cpu_memleak[deflate]test_read_random_region_cpu_memleak[raw]test_tiff_iterator[jpeg]test_tiff_iterator[deflate]test_tiff_iterator[raw]📝 Changes Made
Core Fix
cpp/plugins/cucim.kit.cuslide2/src/cuslide/nvimgcodec/nvimgcodec_decoder.cpp#include <mutex>std::mutex decoder_mutex_member toNvImageCodecManagerget_mutex()accessor methoddecode_jpeg_nvimgcodec()to use pre-allocated buffersdecode_jpeg2k_nvimgcodec()to use pre-allocated buffersBuild Configuration Updates
cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmakecpp/plugins/cucim.kit.cuslide2/cmake/deps/libjpeg-turbo.cmakecpp/plugins/cucim.kit.cuslide2/cmake/deps/nvimgcodec.cmakeexamples/cpp/CMakeLists.txtrun(build script)notebooks/input/README.mdTest Script Added
test_cuslide2_with_generated_image.py🔍 Technical Details
Thread Safety Pattern
Uses mutex-protected singleton decoder:
Memory Management Pattern
Uses caller-allocated buffer pattern:
*destparameterPerformance Impact
🎯 Impact
Fixes Critical Production Issues
Use Cases Now Supported
num_workers > 1)🧪 Testing
Manual Testing
Automated Testing
📚 Related Context
Performance Test Failures
This PR fixes the performance test failures reported in:
tests/performance/clara/test_read_region_memory_usage.py::test_tiff_iteratortests/performance/clara/test_read_region_memory_usage.py::test_read_random_region_cpu_memleakcuslide2 Integration
Part of the cuslide2 plugin with nvImageCodec GPU acceleration:
✨ Highlights
🔗 Branch Information
Branch:
feature/cuslide2-nvimagecodec-api-implementationCommits: 3 commits
c0eec0d- test: Add test script for cuslide2 with generated imagesf6cb1ca- build: Update CMake and build configurations for cuslide2fdcb4c7- fix(cuslide2): Add thread safety and fix memory leaks in nvImageCodec decoder✅ Checklist
🙏 Review Notes
Key Files to Review:
cpp/plugins/cucim.kit.cuslide2/src/cuslide/nvimgcodec/nvimgcodec_decoder.cpp- Main bug fixestest_cuslide2_with_generated_image.py- Validation test scriptTesting Suggestions:
pytest tests/performance/ -vpython test_cuslide2_with_generated_image.pyQuestions for Reviewers: