Skip to content

Commit fb395c7

Browse files
authored
Merge pull request #1507 from luxonis/firmware_version_upgrade
FW version upgrade
2 parents a03950e + 90166df commit fb395c7

File tree

4 files changed

+47
-15
lines changed

4 files changed

+47
-15
lines changed

bindings/python/src/DeviceBindings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,13 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack) {
607607
return d.getLeonMssCpuUsage();
608608
},
609609
DOC(dai, DeviceBase, getLeonMssCpuUsage))
610+
.def(
611+
"getProcessMemoryUsage",
612+
[](DeviceBase& d) {
613+
py::gil_scoped_release release;
614+
return d.getProcessMemoryUsage();
615+
},
616+
DOC(dai, DeviceBase, getProcessMemoryUsage))
610617
.def(
611618
"addLogCallback",
612619
[](DeviceBase& d, std::function<void(LogMessage)> callback) {

include/depthai/device/DeviceBase.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,13 @@ class DeviceBase {
592592
*/
593593
CpuUsage getLeonMssCpuUsage();
594594

595+
/**
596+
* Retrieves current Rss memory usage of the device process
597+
*
598+
* @returns Current Rss memory used
599+
*/
600+
int64_t getProcessMemoryUsage();
601+
595602
/**
596603
* Check if EEPROM is available
597604
* @returns True if EEPROM is present on board, false otherwise

src/device/DeviceBase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,10 @@ CpuUsage DeviceBase::getLeonMssCpuUsage() {
12411241
return pimpl->rpcClient->call("getLeonMssCpuUsage").as<CpuUsage>();
12421242
}
12431243

1244+
int64_t DeviceBase::getProcessMemoryUsage() {
1245+
return pimpl->rpcClient->call("getProcessMemoryUsage").as<int64_t>();
1246+
}
1247+
12441248
UsbSpeed DeviceBase::getUsbSpeed() {
12451249
return pimpl->rpcClient->call("getUsbSpeed").as<UsbSpeed>();
12461250
}

tests/stability/stability_test_depthai.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import time
44
from typing import List, Dict
55
import datetime
6+
import sys
7+
8+
MEMORY_LEAK_DETECTION_THRESHOLD = 1.05
69

710
def stability_test(fps):
811
# Creates the pipeline and a default device implicitly
@@ -13,12 +16,12 @@ def stability_test(fps):
1316
monoRight = p.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
1417
stereo = p.create(dai.node.StereoDepth)
1518
spatialDetectionNetwork = p.create(dai.node.SpatialDetectionNetwork).build(camRgb, stereo, "yolov6-nano", fps=fps)
16-
# encoderMjpeg = p.create(dai.node.VideoEncoder)
17-
# fullResCameraOutput = camRgb.requestFullResolutionOutput()
18-
# encoderMjpeg.build(fullResCameraOutput, profile=dai.VideoEncoderProperties.Profile.MJPEG)
19+
encoderMjpeg = p.create(dai.node.VideoEncoder)
20+
fullResCameraOutput = camRgb.requestFullResolutionOutput()
21+
encoderMjpeg.build(fullResCameraOutput, profile=dai.VideoEncoderProperties.Profile.MJPEG)
1922

20-
# encoderH264 = p.create(dai.node.VideoEncoder)
21-
# encoderH264.build(fullResCameraOutput, profile=dai.VideoEncoderProperties.Profile.H264_MAIN)
23+
encoderH264 = p.create(dai.node.VideoEncoder)
24+
encoderH264.build(fullResCameraOutput, profile=dai.VideoEncoderProperties.Profile.H264_MAIN)
2225

2326
# Stereo settings
2427
stereo.setExtendedDisparity(True)
@@ -40,17 +43,17 @@ def stability_test(fps):
4043
spatialDetectionNetwork.passthroughDepth.link(spatialBenchmark.input)
4144
benchmarkReportQueues["spatial"] = spatialBenchmark.report.createOutputQueue(blocking=False)
4245

43-
# H264Benchmark = p.create(dai.node.BenchmarkIn)
44-
# H264Benchmark.logReportsAsWarnings(False)
45-
# H264Benchmark.sendReportEveryNMessages(fps*5)
46-
# benchmarkReportQueues["H264"] = H264Benchmark.report.createOutputQueue(blocking=False)
47-
# encoderH264.out.link(H264Benchmark.input)
46+
H264Benchmark = p.create(dai.node.BenchmarkIn)
47+
H264Benchmark.logReportsAsWarnings(False)
48+
H264Benchmark.sendReportEveryNMessages(fps*5)
49+
benchmarkReportQueues["H264"] = H264Benchmark.report.createOutputQueue(blocking=False)
50+
encoderH264.out.link(H264Benchmark.input)
4851

49-
# MJPEGBenchmark = p.create(dai.node.BenchmarkIn)
50-
# MJPEGBenchmark.logReportsAsWarnings(False)
51-
# MJPEGBenchmark.sendReportEveryNMessages(fps*5)
52-
# # benchmarkReportQueues["MJPEG"] = MJPEGBenchmark.report.createOutputQueue(blocking=False)
53-
# # encoderMjpeg.out.link(MJPEGBenchmark.input)
52+
MJPEGBenchmark = p.create(dai.node.BenchmarkIn)
53+
MJPEGBenchmark.logReportsAsWarnings(False)
54+
MJPEGBenchmark.sendReportEveryNMessages(fps*5)
55+
benchmarkReportQueues["MJPEG"] = MJPEGBenchmark.report.createOutputQueue(blocking=False)
56+
encoderMjpeg.out.link(MJPEGBenchmark.input)
5457

5558
# IMU
5659
imu = p.create(dai.node.IMU)
@@ -66,6 +69,11 @@ def stability_test(fps):
6669
print("Starting the stability test...")
6770
tStart = time.time()
6871
p.start()
72+
73+
# Delay so the device process finishes starting up
74+
time.sleep(10)
75+
initialProcessMemoryUsage = p.getDefaultDevice().getProcessMemoryUsage()
76+
print(f"Initial depthai-device process memory usage is: {initialProcessMemoryUsage} kB")
6977
while True:
7078
for name, queue in benchmarkReportQueues.items():
7179
report = queue.get(timeout=datetime.timedelta(minutes=1)) # 1 minute timeout
@@ -77,6 +85,12 @@ def stability_test(fps):
7785
else:
7886
raise RuntimeError(f"Timeout reached for {name} benchmark report")
7987
queue.tryGetAll() # Clear the queue
88+
89+
# Detect memory leaks
90+
processMemoryUsage = p.getDefaultDevice().getProcessMemoryUsage()
91+
if processMemoryUsage > MEMORY_LEAK_DETECTION_THRESHOLD * initialProcessMemoryUsage:
92+
raise RuntimeError("Memory used by depthai-device process increased above the given threshold - potential memory leak detected")
93+
print(f"Memory used by depthai-device process: {processMemoryUsage} kB. Current time: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())}")
8094
print(f"Running for {datetime.timedelta(seconds=time.time() - tStart)}", flush=True)
8195

8296
if __name__ == "__main__":

0 commit comments

Comments
 (0)