-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
【Hackathon 7th No.21】为 Paddle 新增 reset_max_memory_reserved/reset_max_memory_allocated API -part #70032
Conversation
modified: paddle/fluid/pybind/pybind.cc modified: paddle/phi/core/memory/stats.cc modified: paddle/phi/core/memory/stats.h modified: python/paddle/device/cuda/__init__.py
modified: paddle/fluid/pybind/pybind.cc modified: python/paddle/device/cuda/__init__.py
modified: paddle/fluid/pybind/pybind.cc modified: paddle/phi/core/memory/stats.cc modified: paddle/phi/core/memory/stats.h modified: test/cpp/fluid/memory/stats_test.cc
new file: test/legacy_test/test_cuda_memory_stats.py new file: test/legacy_test/test_cuda_reset_peak_memory_stats.py
你的PR提交成功,感谢你对开源项目的贡献! |
new file: test/legacy_test/test_cuda_reset_max_memory_allocated.py
modified: python/paddle/device/cuda/__init__.py modified: test/legacy_test/test_cuda_memory_stats.py modified: test/legacy_test/test_cuda_reset_max_memory_allocated.py modified: test/legacy_test/test_cuda_reset_peak_memory_stats.py
modified: paddle/fluid/pybind/pybind.cc modified: paddle/phi/core/memory/stats.cc modified: paddle/phi/core/memory/stats.h modified: test/cpp/fluid/memory/stats_test.cc
modified: python/paddle/device/cuda/__init__.py modified: test/legacy_test/test_cuda_reset_max_memory_allocated.py new file: test/legacy_test/test_cuda_reset_max_memory_reserved.py
|
||
def reset_max_memory_allocated(device: _CudaPlaceLike | None = None) -> None: | ||
''' | ||
Reset the peak values of GPU memory allocated to the current values. |
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.
接口说明最好和max_memory_allocated保持一致。
Reset the peak size of GPU memory that is held by the allocator of the given device.
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.
嗯,收到
|
||
EXPECT_GE(peak_value_func_(stat_type_, 0), | ||
current_value_func_(stat_type_, 0)); | ||
reset_peak_value_func_(stat_type_, 0); |
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.
在这个测试中,这一步如果reset不成功,是不是后面的检查也是会通过的?
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.
如果reset不成功,下一行(107行)的检查应该无法通过。
void ResetPeakValueTest() {
for (int64_t data : datas_) {
update_func_(stat_type_, 0, data);
EXPECT_GE(peak_value_func_(stat_type_, 0),
current_value_func_(stat_type_, 0));
// reset_peak_value_func_(stat_type_, 0);
printf("data: %ld, Peak Value: %ld, Current Value: %ld\n",data, peak_value_func_(stat_type_, 0), current_value_func_(stat_type_, 0));
EXPECT_EQ(peak_value_func_(stat_type_, 0),
current_value_func_(stat_type_, 0));
}
}
如果将reset_peak_value_func_
函数注释,测试将无法通过。下面为部分运行结果。
115: Test timeout computed to be: 10000000
115: [==========] Running 4 tests from 1 test case.
115: [----------] Global test environment set-up.
115: [----------] 4 tests from StatsTest
115: [ RUN ] StatsTest.DeviceAllocatedTest
115: data: 543149808935355, Peak Value: 45703145873829393, Current Value: 45703145873829393
115: data: 634698327471328, Peak Value: 46337844201300721, Current Value: 46337844201300721
115: data: 706215795436611, Peak Value: 47044059996737332, Current Value: 47044059996737332
115: data: 577939367795333, Peak Value: 47621999364532665, Current Value: 47621999364532665
115: data: 419479490054362, Peak Value: 48041478854587027, Current Value: 48041478854587027
115: data: 21975227714595, Peak Value: 48063454082301622, Current Value: 48063454082301622
115: data: 812939817942250, Peak Value: 48876393900243872, Current Value: 48876393900243872
115: data: 984428837942082, Peak Value: 49860822738185954, Current Value: 49860822738185954
115: data: 537304104446806, Peak Value: 50398126842632760, Current Value: 50398126842632760
115: data: 685008544452453, Peak Value: 51083135387085213, Current Value: 51083135387085213
115: data: 563352858161268, Peak Value: 51646488245246481, Current Value: 51646488245246481
115: data: 690143831596330, Peak Value: 52336632076842811, Current Value: 52336632076842811
115: data: 964829938186077, Peak Value: 53301462015028888, Current Value: 53301462015028888
115: data: 476984078018245, Peak Value: 53778446093047133, Current Value: 53778446093047133
115: data: 804403365180177, Peak Value: 54582849458227310, Current Value: 54582849458227310
115: data: -57918691189304, Peak Value: 54582849458227310, Current Value: 54524930767038006
115: /home/aistudio/test/Paddle/test/cpp/fluid/memory/stats_test.cc:109: Failure
115: Expected equality of these values:
115: peak_value_func_(stat_type_, 0)
115: Which is: 54582849458227310
115: current_value_func_(stat_type_, 0)
115: Which is: 54524930767038006
115: data: 947611269236893, Peak Value: 55472542036274899, Current Value: 55472542036274899
115: data: 752188963801927, Peak Value: 56224731000076826, Current Value: 56224731000076826
115: data: 710946451346683, Peak Value: 56935677451423509, Current Value: 56935677451423509
115: data: -49226452527666, Peak Value: 56935677451423509, Current Value: 56886450998895843
115: /home/aistudio/test/Paddle/test/cpp/fluid/memory/stats_test.cc:109: Failure
115: Expected equality of these values:
115: peak_value_func_(stat_type_, 0)
115: Which is: 56935677451423509
115: current_value_func_(stat_type_, 0)
115: Which is: 56886450998895843
115: data: -59049377393968, Peak Value: 56935677451423509, Current Value: 56827401621501875
115: /home/aistudio/test/Paddle/test/cpp/fluid/memory/stats_test.cc:109: Failure
115: Expected equality of these values:
115: peak_value_func_(stat_type_, 0)
115: Which is: 56935677451423509
115: current_value_func_(stat_type_, 0)
115: Which is: 56827401621501875
115: data: 14128239868858, Peak Value: 56935677451423509, Current Value: 56841529861370733
115: /home/aistudio/test/Paddle/test/cpp/fluid/memory/stats_test.cc:109: Failure
115: Expected equality of these values:
115: peak_value_func_(stat_type_, 0)
115: Which is: 56935677451423509
115: current_value_func_(stat_type_, 0)
115: Which is: 56841529861370733
115: data: 463298869064035, Peak Value: 57304828730434768, Current Value: 57304828730434768
modified: paddle/fluid/pybind/pybind.cc modified: python/paddle/device/cuda/__init__.py deleted: test/legacy_test/test_cuda_memory_stats.py deleted: test/legacy_test/test_cuda_reset_peak_memory_stats.py
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.
LGTM
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.
please add link of rfc and PR of chinese document in description above |
please add link of rfc and PR of chinese document in description above @jeff41404 Done |
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.
LGTM
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.
LGTM for docs
hi, @Qin-sx
|
PR Category
User Experience
PR Types
New features
Description
https://github.com/PaddlePaddle/community/blob/master/hackathon/hackathon_7th/%E3%80%90Hackathon%207th%E3%80%91%E4%B8%AA%E4%BA%BA%E6%8C%91%E6%88%98%E8%B5%9B%E2%80%94%E6%A1%86%E6%9E%B6%E5%BC%80%E5%8F%91%E4%BB%BB%E5%8A%A1%E5%90%88%E9%9B%86.md#no21-%E4%B8%BA-paddle-%E6%96%B0%E5%A2%9E-reset_peak_memory_statsreset_max_memory_allocatedmemory_stats-api