nvidia-tririon-inference-server-model-analyzer

環境

Ubuntu 22.04
trition inference server version : 23.08

在git clone下來的model_analyzer資料夾下啟動docker

1
2
3
4
5
docker run -it --gpus all \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd)/examples/quick-start:$(pwd)/examples/quick-start \
-v $(pwd)/examples/quick-start/output-model-repo:$(pwd)/examples/quick-start/output-model-repo \
--net=host nvcr.io/nvidia/tritonserver:23.08-py3-sdk

假設現在所在路徑$(pwd)是/home/user/model_inference

啟動docker後會發現quick-start所在的的路徑會跟host主機一模一樣,因此下面的指令可以直接用跟host一模一樣的路徑去執行

1
2
3
4
5
model-analyzer profile \
--model-repository /home/user/model_inference/model_analyzer/examples/quick-start \
--profile-models add_sub --triton-launch-mode=docker \
--output-model-repository-path /home/user/model_inference/model_analyzer/examples/quick-start/output-model-repo/add \
--export-path profile_results

參考:

https://github.com/triton-inference-server/model_analyzer/blob/4b45d2daeb9f574d13ae0e774677c87c04ef2124/docs/quick_start.md

fiftyone讀取dataset錯誤

  • 錯誤訊息
    1
    2
    {"t":{"$date":"2025-06-04T08:11:32.830Z"},"s":"I",  "c":"CONTROL",  "id":20697,   "ctx":"-","msg":"Renamed existing log file","attr":{"oldLogPath":"/home/iisi/.fiftyone/var/lib/mongo/log/mongo.log","newLogPath":"/home/iisi/.fiftyone/var/lib/mongo/log/mongo.log.2025-06-04T08-11-32"}}
    Subprocess ['/home/iisi/2005013/model_training/YOLO/venv/lib/python3.10/site-packages/fiftyone/db/bin/mongod', '--dbpath', '/home/iisi/.fiftyone/var/lib/mongo', '--logpath', '/home/iisi/.fiftyone/var/lib/mongo/log/mongo.log', '--port', '0', '--nounixsocket'] exited with error 100:

解法

https://docs.voxel51.com/user_guide/config.html#configuring-a-mongodb-connection

用自建的mongo db

You can achieve this by adding the following entry to your ~/.fiftyone/config.json file:
environment variable

1
export FIFTYONE_DATABASE_URI=mongodb://[username:password@]host[:port]

VSCode_CMake_GoogleTest

重點:

下面這兩行要放在最外面的 CMakeLists.txt 中,這樣才能在build資料夾啟動ctest

1
2
include(CTest)
enable_testing()

讓VSCode的Ctest可以下中斷點

參考:
https://stackoverflow.com/a/76447033/22299707

https://github.com/microsoft/vscode-cmake-tools/blob/defc0b5369c64467c3466b1cee3faba9f9633a6a/docs/debug-launch.md#debugging-tests

launch.json

1
2
3
4
5
6
7
8
9
{
"name": "(ctest) Launch",
"type": "cppdbg",
"cwd": "${cmake.testWorkingDirectory}",
"request": "launch",
"program": "${cmake.testProgram}",
"args": [ "${cmake.testArgs}" ],
// other options...
}

參考:
https://github.com/esweet431/box2d-lite/blob/vs-launch/CMakePresets.json

cmake google test配置

範例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
find_package(Threads REQUIRED)


include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG 52eb8108c5bdec04579160ae17225d66034bd723 # release-1.17.0
)
FetchContent_MakeAvailable(googletest)
enable_testing()

# Create a libgmock target to be used as a dependency by test programs

add_subdirectory(testplate)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
include(GoogleTest)
file(GLOB SRCS *.cpp)
add_executable(testplate ${SRCS})


target_link_libraries(testplate
gtest_main
libtestplate
)

gtest_add_tests(TARGET testplate
TEST_SUFFIX .noArgs
TEST_LIST noArgsTests
)

#gtest_add_tests(TARGET testplate
# EXTRA_ARGS --someArg someValue
# TEST_SUFFIX .withArgs
# TEST_LIST withArgsTests
#)

set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
#set_tests_properties(${withArgsTests} PROPERTIES TIMEOUT 20)

參考:
https://cmake.org/cmake/help/latest/module/FetchContent.html#integrating-with-find-package

https://cmake.org/cmake/help/v3.31/module/GoogleTest.html#command:gtest_add_tests

Ubuntu加入WindowsAD

查詢AD server
文件SSSD
https://documentation.ubuntu.com/server/how-to/sssd/with-active-directory/#sssd-with-active-directory

echo %logonserver%
nslookup

範例:
Microsoft Windows [Version 10.0.19045.5011]
(c) Microsoft Corporation. All rights reserved.

C:\Users\2005013>echo %logonserver%
\IEDC022

C:\Users\2005013>nslookup \IEDC022
Server: DNS221.iead.local
Address: 192.168.16.44

Name: IEDC022.iead.local
Address: 192.168.16.32

C:\Users\2005013>

確保 DNS 配置正確

將 AD 的 DNS 伺服器地址添加到 nameserver,例如:

1
2
nameserver <AD_DNS_SERVER_IP>
search <AD_DOMAIN>

範例
nameserver 192.168.11.32
search iiiid.local

GPT

GitHub Copilot: 在你的情境下,使用 SSSD 整合 Ubuntu Server 與 Windows Active Directory (AD) 是最適合的選擇。SSSD 提供了與 AD 的良好整合,並且支援 Linux 系統的身份驗證和授權,讓擁有 AD 帳號的用戶可以登入 Ubuntu Server。


為什麼選擇 SSSD?

  1. 跨平台支援:SSSD 是 Linux 上的身份驗證解決方案,專為與 AD 整合設計。
  2. 簡化管理:SSSD 支援 Kerberos 和 LDAP,能直接與 AD 通信,並且可以緩存身份驗證數據,減少對 AD 的依賴。
  3. 靈活性:除了身份驗證,SSSD 還支援基於 AD 群組的授權控制。
  4. 穩定性:SSSD 是 Ubuntu 官方推薦的解決方案,並且有良好的社群支持。

實現步驟

以下是將 Ubuntu Server 加入 Windows AD 並允許 AD 用戶登入的基本步驟:

1. 安裝必要的套件

在 Ubuntu Server 上安裝 SSSD 和相關工具:

1
2
sudo apt update
sudo apt install sssd-ad sssd-tools realmd adcli krb5-user packagekit

2. 確保 DNS 配置正確

AD 的身份驗證依賴正確的 DNS 設定,請確保 Ubuntu Server 能解析 AD 網域名稱:

1
sudo nano /etc/resolv.conf

將 AD 的 DNS 伺服器地址添加到 nameserver,例如:

1
2
nameserver <AD_DNS_SERVER_IP>
search <AD_DOMAIN>

3. 加入 AD 網域

使用 realm 工具將 Ubuntu Server 加入 AD 網域:

1
sudo realm join --user=<AD_ADMIN_USERNAME> <AD_DOMAIN>

系統會提示輸入 AD 管理員的密碼,成功後會自動配置 SSSD。

4. 驗證網域加入狀態

確認 Ubuntu Server 已成功加入 AD:

1
realm list

你應該能看到 AD 網域的相關資訊。

5. 配置 SSSD

檢查或修改 SSSD 配置檔案 /etc/sssd/sssd.conf,確保內容類似以下:

1
2
3
4
5
6
7
8
9
[sssd]
services = nss, pam
domains = <AD_DOMAIN>

[domain/<AD_DOMAIN>]
id_provider = ad
access_provider = ad
override_homedir = /home/%d/%u
default_shell = /bin/bash

保存後,重啟 SSSD:

1
sudo systemctl restart sssd

6. 測試 AD 用戶登入

嘗試使用 AD 用戶登入 Ubuntu Server:

1
ssh <AD_USERNAME>@<UBUNTU_SERVER_IP>

如果配置正確,AD 用戶應該能成功登入。

7. 可選:限制登入權限

如果你希望只允許特定 AD 群組的用戶登入,可以在 /etc/sssd/sssd.conf 中添加:

1
2
access_provider = ad
ad_access_filter = (memberOf=CN=<GROUP_NAME>,OU=<OU_NAME>,DC=<DOMAIN>,DC=<COM>)

重啟 SSSD 後,只有屬於該群組的用戶才能登入。


結論

使用 SSSD 是將 Ubuntu Server 加入 Windows AD 的最佳方式,因為它提供了穩定、高效且靈活的身份驗證解決方案。完成上述配置後,AD 用戶即可使用其帳號登入 Ubuntu Server,並且可以根據需求進一步限制登入權限。

參考:

https://poweradm.com/join-ubuntu-debian-active-directory-domain/

使用gst-shark

安裝

git clone https://github.com/RidgeRun/gst-shark/
apt install octave epstool babeltrace gtk-doc-tools
apt install graphviz libgraphviz-dev

編譯

sudo apt install python3 python3-pip ninja-build
pip3 install –user meson
sudo cp ~/.local/bin/meson /usr/bin/meson

meson builddir –prefix /usr/
ninja -C builddir

安裝

ninja install -C builddir

如果有更動gst-shark的程式碼,則需要重新編譯安裝

ninja -C builddir
ninja install -C builddir

在deepstream使用gst-shark的時候會需要修改以下程式碼並且重新編譯,以免出錯
gst_shark_tracer_hook_pad_push_pre,要檢查GST_OBJECT_PARENT的結果是不是NULL,是就return,修改如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* My hooks */
static void
gst_shark_tracer_hook_pad_push_pre (GObject * object, GstClockTime ts,
GstPad * pad, GstBuffer * buffer)
{
GstSharkTracer *self = GST_SHARK_TRACER (object);
GstSharkTracerPrivate *priv = GST_SHARK_TRACER_PRIVATE (self);
GCallback hook;
const gchar *elname;

GstObject* gst_obj = GST_OBJECT_PARENT (pad);
if (gst_obj == NULL){
return;
}
elname = GST_OBJECT_NAME (gst_obj);
if (FALSE == gst_shark_tracer_element_is_filtered (self, elname)) {
return;
}

hook = g_hash_table_lookup (priv->hooks, "pad-push-pre");
g_return_if_fail (hook);

((void (*)(GObject *, GstClockTime, GstPad *, GstBuffer *)) hook) (object, ts,
pad, buffer);
}

使用

export GST_SHARK_LOCATION=/root/apps/iisi-ds64/iisi-ds63/my_exp/shark
export GST_DEBUG=”GST_TRACER:7”
export GST_TRACERS=”queuelevel”

執行deepstream,並且用q結束程式,確認shark底下的metadata有資料

下面是產生圖片的方式

cd gst-shark/scripts/graphics

Display the plot on the screen

./gstshark-plot /root/apps/iisi-ds64/iisi-ds63/my_exp/shark -p

Save the plot to a PDF

./gstshark-plot /root/apps/iisi-ds64/iisi-ds63/my_exp/shark -s pdf

Save the plot to a PNG

./gstshark-plot /root/apps/iisi-ds64/iisi-ds63/my_exp/shark -s png

gstreamer使用gdb的方法

git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git
cd gstreamer/
git checkout 1.20.3

pip3 install –user meson

meson setup builddir

ninja -C builddir

測試gst環境成功
https://www.collabora.com/news-and-blog/blog/2020/03/19/getting-started-with-gstreamer-gst-build/
1.在程式subprojects/gst-plugins-base/gst/videotestsrc/gstvideotestsrc.c中加料
在gst_video_test_src_start()中加上,故意讓程式報錯跳出

1
GST_ERROR_OBJECT (src, "Starting to debug videotestsrc, is there an error ?");

2.ninja -C build重新編譯程式,可以注意到這次編譯只會編譯被更新的檔案
3.執行GST_DEBUG=videotestsrc:1 gst-launch-1.0 videotestsrc num-buffers=1 ! fakevideosink,並出現錯誤,表示測試成功

1
2
3
4
5
6
7
8
9
10
11
12
Setting pipeline to PAUSED ...
0:00:00.225273663 21743 0x565528ab7100 ERROR videotestsrc gstvideotestsrc.c:1216:gst_video_test_src_start: Starting to debug videotestsrc, is there an error ?
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.033464391
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ..

使用gst環境(類似python的venv)
python3 gst-env.py
以下連結說明有更新的環境變數
https://gstreamer.freedesktop.org/documentation/installing/building-from-source-using-meson.html#how-does-it-work

此時許多環境變數被自動設置,包含pkg-config也被設置,可以用pkg-config –cflags gstreamer-1.0檢查gstreamer的路徑,如此一來讓cmake編譯也可以連結到自行編譯的程式,並且包含gdb下中斷點需要的資訊

把deepstream的gst-plugin的變數加進來,這樣才找的到deepstream的plugin
export GST_PLUGIN_PATH=/opt/nvidia/deepstream/deepstream/lib/gst-plugins:$GST_PLUGIN_PATH

gdb下中斷點
gst_element_factory_make

vscode要在debug的那一個terimal執行gst-env.py才能讓中斷點停在gstreamer的程式上面