01Telemetry 介紹
在上一篇文章中介紹了 Intel Developer Cloud Telemetry的概念和功能,通過該功能的數(shù)據(jù)分析,可以更好地優(yōu)化產(chǎn)品方案。有關(guān) Telemetry 的工作原理和集成方法,我將在這篇文章里細(xì)細(xì)解釋。耐心看下去,相信您肯定可以在自己應(yīng)用中開啟這個功能。
02Telemetry 收集流程

圖 1-2 Telemetry收集數(shù)據(jù)流程
概括來說,對自定義 AI 模型上運(yùn)行模型優(yōu)化,由OpenVINO工具套件進(jìn)行推理,完成對 AI 模型的推理后,您就可以獲得計算節(jié)點上可用的遙測指標(biāo)。具體步驟如下:
1導(dǎo)入所有自定義模型文件(tensorflow、kaldi、onnx 等)
2使用模型優(yōu)化器以必要的精度創(chuàng)建模型中間表示(IR)文件
3創(chuàng)建用于在計算節(jié)點上提交運(yùn)行推理的作業(yè)文件(.sh)
4使用 Application Metrics Writer 啟用遙測
5為不同的計算節(jié)點提交作業(yè)并監(jiān)控作業(yè)狀態(tài)直到完成(提交作業(yè)會調(diào)用 bash 和自定義 python 文件)
6在遙測儀表板上顯示模型指標(biāo)
注意:流程里不止包含 Telemetry 。而是 AI 應(yīng)用在 DevCloud 上運(yùn)行的流程,以便您可以了解 Telemetry 功能在應(yīng)用里的位置。
03Telemetry 集成
這次依然選擇 object-detection-python 實例來介紹集成方法,應(yīng)用程序的 python 代碼中調(diào)用了 applicationMetricWriter 模塊向 Telemetry 傳遞數(shù)據(jù)指標(biāo)如,幀率、推理時間、模型名稱、推理硬件信息,下面通過具體代碼來展示詳細(xì)信息。
Step.1
登錄 JupyterLab
登錄 Intel Developer Cloud 主頁后,點擊“Bare Metal Deployment” 的 “Get Started” 按鈕,進(jìn)入 Jupyter Lab 開發(fā)環(huán)境。在左側(cè)目錄導(dǎo)航欄選擇這個路徑:
Reference-samples/iot-devcloud/openvino-dev-latest/developer-samples/python/
然后找到 object-detection-python 應(yīng)用。
Step.2
程序源碼分析
直接打開 object_detection.py ,可以看到在文件開頭部分導(dǎo)入了 applicationMetricWriter 模塊。我們可以在 Jupyter notebook 里直接查看它的函數(shù)。方法如下:

可以看到它只有兩個函數(shù),使用起來非常的簡單,我們來逐一介紹一下這兩個函數(shù)。send_inference_time() 用來向 Telemetry 數(shù)據(jù)發(fā)送每一幀推送所消耗的時間,唯一要注意的是每一幀哦。這就要求你能區(qū)分每一幀推理的時間。如果你選擇 async 模式,就需要考慮是不是適用了。 send_application_metrics 主要傳遞的是模型的名字和推理設(shè)備的名字,以便于你能更好地標(biāo)記這個任務(wù)。
看到這里,估計你的想法與我剛開始的一樣,怎么沒有看到上傳 CPU, GPU, Thermal 等數(shù)據(jù)上傳呢?其實是因為這些數(shù)據(jù)都是通用的,這塊就沒有必要放在用戶側(cè)來每次都重復(fù)寫一遍,在后端直接默認(rèn)做了。從這里我們可以看到,最重要的數(shù)據(jù)還是推理時間的上傳。
現(xiàn)在這兩個函數(shù)在程序里的調(diào)用時機(jī),這里我注釋了沒有必要的代碼,以方便觀察。
#!/usr/bin/env python
import applicationMetricWriter
...
def main():
...
try:
infer_time_start = time.time()
with open(processed_vid, "rb") as data:
while frame_count < video_len:
? ? ? ? ? ? ? ?byte = data.read(CHUNKSIZE)
? ? ? ? ? ? ? ?if not byte == b"":
? ? ? ? ? ? ? ? ? ?deserialized_bytes = np.frombuffer(byte, dtype=np.uint8)
? ? ? ? ? ? ? ? ? ?in_frame = np.reshape(deserialized_bytes, newshape=(n, c, h, w))
? ? ? ? ? ? ? ? ? ?inf_time = time.time()
? ? ? ? ? ? ? ? ? ?exec_net.start_async(request_id=current_inference,inputs={input_blob: in_frame})
? ? ? ? ? ? ? ?# Retrieve the output of an earlier inference request
? ? ? ? ? ? ? ?if previous_inference >= 0:
status = infer_requests[previous_inference].wait()
if status is not 0:
raise Exception("Infer request not completed successfully")
det_time = time.time() - inf_time
applicationMetricWriter.send_inference_time(det_time*1000)
res = output_postprocessor(exec_net.requests[previous_inference].output_blobs)
processBoxes(frame_count, res, labels_map, args.prob_threshold, width, height, result_file)
frame_count += 1
…
applicationMetricWriter.send_application_metrics(model_xml, args.device)
向右滑動查看完整代碼
step.3
Telemetry 數(shù)據(jù)訪問
等應(yīng)用程序在邊緣節(jié)點運(yùn)行結(jié)束,我們就可以去查看 Telemetry 的數(shù)據(jù)了。數(shù)據(jù)的連接您可以參考這個object-detection-python 里的方法,直接點擊下圖中框① Telemetry 按鍵獲取連接方式。

當(dāng)然您也可以自己手動生成這樣一個連接,注意上圖中框②處的 ID 號。使用 Telemetry 服務(wù)器地址拼接該 ID 號,即可訪問該數(shù)據(jù)。
https://devcloud.intel.com/edge/metrics/d/+ID
比如:https://devcloud.intel.com/edge/metrics/d/573403
訪問該路徑即可獲取 Telemetry 的數(shù)據(jù)了。

03總結(jié)
看到這相信您一定理解了 Intel Developer Cloud Telemetry 的集成方法了,它并沒有我們想象的那么復(fù)雜。我這里總結(jié)出來,只是為了方便剛開始接觸這塊的您更快上手,不用花費(fèi)太多精力就可以更快的把事情搞定。如果您在使用過程中有碰到問題,期待一起交流。
審核編輯:湯梓紅
-
英特爾
+關(guān)注
關(guān)注
61文章
10275瀏覽量
179284 -
intel
+關(guān)注
關(guān)注
19文章
3506瀏覽量
190560 -
AI
+關(guān)注
關(guān)注
89文章
38090瀏覽量
296536 -
數(shù)據(jù)分析
+關(guān)注
關(guān)注
2文章
1506瀏覽量
35937 -
Developer
+關(guān)注
關(guān)注
0文章
28瀏覽量
6652
原文標(biāo)題:Intel? Developer Cloud 之 Telemetry 數(shù)據(jù)分析 (二) | 開發(fā)者實戰(zhàn)
文章出處:【微信號:英特爾物聯(lián)網(wǎng),微信公眾號:英特爾物聯(lián)網(wǎng)】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
Intel PXA27x Processor Family Developer's Manual
數(shù)據(jù)分析需要的技能
怎么有效學(xué)習(xí)Python數(shù)據(jù)分析?
python數(shù)據(jù)分析之安裝mysql數(shù)據(jù)庫
python數(shù)據(jù)分析基礎(chǔ)之使用statasmodels進(jìn)行線性回歸
怎么做自己做得快、老板看得開心的數(shù)據(jù)分析報表?
BI數(shù)據(jù)分析軟件使用指南
電商數(shù)據(jù)分析攻略,讓你輕松搞定數(shù)據(jù)分析!
數(shù)據(jù)分析步驟
IBM Cloud Pak for Data平臺讓數(shù)據(jù)分析變得更簡單
Intel? Developer Cloud Telemetry數(shù)據(jù)分析
Intel Developer Cloud Telemetry數(shù)據(jù)分析(二)
Intel Developer Cloud Telemetry數(shù)據(jù)分析(一)

Intel Developer Cloud之Telemetry數(shù)據(jù)分析
評論