-
Notifications
You must be signed in to change notification settings - Fork 175
Restore resource_cast memory limit check #1231
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
base: release/26.06
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,13 +9,18 @@ | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #include <utilities/macros.cuh> | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #include <cuda/memory_resource> | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #include <thrust/host_vector.h> | ||||||||||||||||||||||||||||
| #include <thrust/tuple.h> | ||||||||||||||||||||||||||||
| #include <algorithm> | ||||||||||||||||||||||||||||
| #include <mutex> | ||||||||||||||||||||||||||||
| #include <raft/core/device_span.hpp> | ||||||||||||||||||||||||||||
| #include <raft/util/cuda_utils.cuh> | ||||||||||||||||||||||||||||
| #include <raft/util/cudart_utils.hpp> | ||||||||||||||||||||||||||||
| #include <rmm/device_uvector.hpp> | ||||||||||||||||||||||||||||
| #include <rmm/mr/limiting_resource_adaptor.hpp> | ||||||||||||||||||||||||||||
| #include <rmm/mr/per_device_resource.hpp> | ||||||||||||||||||||||||||||
| #include <shared_mutex> | ||||||||||||||||||||||||||||
| #include <unordered_map> | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -242,7 +247,19 @@ inline size_t get_device_memory_size() | |||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| size_t free_mem, total_mem; | ||||||||||||||||||||||||||||
| RAFT_CUDA_TRY(cudaMemGetInfo(&free_mem, &total_mem)); | ||||||||||||||||||||||||||||
| // TODO (bdice): Restore limiting adaptor check after updating CCCL to support resource_cast | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| auto res = rmm::mr::get_current_device_resource_ref(); | ||||||||||||||||||||||||||||
| auto limiting_adaptor = cuda::mr::resource_cast<rmm::mr::limiting_resource_adaptor>(&res); | ||||||||||||||||||||||||||||
| if (limiting_adaptor) { | ||||||||||||||||||||||||||||
| printf("limiting_adaptor->get_allocation_limit(): %fMiB\n", | ||||||||||||||||||||||||||||
| limiting_adaptor->get_allocation_limit() / (double)1e6); | ||||||||||||||||||||||||||||
| printf("used_mem: %fMiB\n", limiting_adaptor->get_allocated_bytes() / (double)1e6); | ||||||||||||||||||||||||||||
| printf("free_mem: %fMiB\n", | ||||||||||||||||||||||||||||
| (limiting_adaptor->get_allocation_limit() - limiting_adaptor->get_allocated_bytes()) / | ||||||||||||||||||||||||||||
| (double)1e6); | ||||||||||||||||||||||||||||
|
Comment on lines
+254
to
+259
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix unit mismatch in memory diagnostics. Line 254, Line 256, and Line 257 label values as Suggested patch- printf("limiting_adaptor->get_allocation_limit(): %fMiB\n",
- limiting_adaptor->get_allocation_limit() / (double)1e6);
- printf("used_mem: %fMiB\n", limiting_adaptor->get_allocated_bytes() / (double)1e6);
+ constexpr double bytes_per_mib = 1024.0 * 1024.0;
+ printf("limiting_adaptor->get_allocation_limit(): %fMiB\n",
+ limiting_adaptor->get_allocation_limit() / bytes_per_mib);
+ printf("used_mem: %fMiB\n", limiting_adaptor->get_allocated_bytes() / bytes_per_mib);
printf("free_mem: %fMiB\n",
- (limiting_adaptor->get_allocation_limit() - limiting_adaptor->get_allocated_bytes()) /
- (double)1e6);
+ (limiting_adaptor->get_allocation_limit() - limiting_adaptor->get_allocated_bytes()) /
+ bytes_per_mib);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| return std::min(total_mem, limiting_adaptor->get_allocation_limit()); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return total_mem; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the printf