Skip to content

Make LMDB an optional dependency#473

Open
sruthi0107 wants to merge 2 commits into
ROCm:developfrom
sruthi0107:fix/lmdb-optional
Open

Make LMDB an optional dependency#473
sruthi0107 wants to merge 2 commits into
ROCm:developfrom
sruthi0107:fix/lmdb-optional

Conversation

@sruthi0107
Copy link
Copy Markdown
Contributor

Motivation

On some OS configurations, LMDB may not be available, causing the rocAL build to fail even though LMDB is only needed for
Caffe/Caffe2 LMDB readers. This change makes LMDB an optional dependency. When LMDB is not present, the build succeeds and LMDB reader APIs return clear error messages at runtime.

Technical Details

  • C++ headers/sources: wrap Caffe/Caffe2 LMDB readers and metadata readers with #ifdef ROCAL_LMDB
  • API layer: LMDB data loader and metadata functions throw descriptive errors when called without LMDB support
  • Pybind: conditionally expose LMDB bindings; Python layer checks availability with hasattr() before calling
  • Packaging: remove liblmdb-dev/lmdb-devel from required package lists
  • Setup script: comment out LMDB packages
  • ReadMe: LMDB marked as an optional dependency

Test Plan

Three-phase validation:

  1. Baseline (clean develop, LMDB present)
  2. Feature branch + LMDB - verify zero regressions vs baseline
  3. Feature branch - LMDB - verify graceful degradation

Each phase verifies:

  • CMake configure + build
  • C++ ctests (21 tests)
  • PyBind ctests (6 tests)
  • Python API tests (15 tests: unit_test, coco_reader, decoder, tf_classification, tf_detection, video_pipeline, numpy_reader,
    web_dataset_reader, external_source, pipeline, pipeline_serialize, caffe_reader x2, caffe2_reader x2)

Test Result

Test Layer Phase 1 (baseline) Phase 2 (branch + LMDB) Phase 3 (branch - LMDB)
Build PASS PASS, ROCAL_LMDB defined PASS, no LMDB linked
C++ ctests (21) 21/21 PASS 21/21 PASS 21/21 PASS
PyBind ctests (6) 6/6 PASS 6/6 PASS 6/6 PASS
Python non-LMDB (11) 11/11 PASS 11/11 PASS 11/11 PASS
Python LMDB (4) 4/4 PASS 4/4 PASS Clean RuntimeError (expected)

Without LMDB, Caffe/Caffe2 reader tests produce clear RuntimeError: rocAL was built without LMDB support. No segfaults or undefined symbols.

LMDB is only needed for Caffe/Caffe2 LMDB readers. Gate all LMDB-dependent
code behind ROCAL_LMDB, which CMake defines automatically when liblmdb is
found. When LMDB is not present, the build succeeds and LMDB reader APIs
return clear error messages at runtime.

Changes:
- CMake: LMDB discovery is no longer fatal; sets -DROCAL_LMDB when found
- C++ headers/sources: wrap Caffe/Caffe2 LMDB readers and metadata readers
  with #ifdef ROCAL_LMDB
- API layer: LMDB data loader and metadata functions throw descriptive
  errors when called without LMDB support
- Pybind: conditionally expose LMDB bindings; Python layer checks
  availability with hasattr() before calling
- Packaging: remove liblmdb-dev/lmdb-devel from required package lists
- Setup script: comment out LMDB packages (now optional)
LMBD → LMDB, and note that it is only needed for Caffe/Caffe2 LMDB
reader support.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ocAL/source/meta_data/meta_data_reader_factory.cpp 0.00% 1 Missing ⚠️
rocAL/source/readers/image/reader_factory.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #473      +/-   ##
===========================================
+ Coverage    75.67%   75.69%   +0.02%     
===========================================
  Files          318      318              
  Lines        26277    26289      +12     
===========================================
+ Hits         19885    19899      +14     
+ Misses        6392     6390       -2     
Files with missing lines Coverage Δ
rocAL/include/meta_data/caffe_meta_data_reader.h 0.00% <ø> (ø)
...clude/meta_data/caffe_meta_data_reader_detection.h 0.00% <ø> (ø)
.../include/readers/image/caffe2_lmdb_record_reader.h 100.00% <ø> (ø)
...L/include/readers/image/caffe_lmdb_record_reader.h 100.00% <ø> (ø)
rocAL/include/readers/image/image_reader.h 88.64% <ø> (ø)
rocAL/source/api/rocal_api_data_loaders.cpp 78.50% <100.00%> (+0.08%) ⬆️
rocAL/source/api/rocal_api_info.cpp 80.91% <100.00%> (+0.72%) ⬆️
rocAL/source/meta_data/caffe2_meta_data_reader.cpp 77.32% <ø> (ø)
...ce/meta_data/caffe2_meta_data_reader_detection.cpp 74.24% <ø> (ø)
rocAL/source/meta_data/caffe_meta_data_reader.cpp 74.68% <ø> (ø)
... and 5 more

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant