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的程式上面

IPMI

Windows

ipmiutil
https://ipmiutil.sourceforge.net/

設定BMC IP

1
ipmiutil.exe lan -e -I  10.179.12.230

Linux

ipmitool
安裝:

1
sudo apt-get install ipmitool

修改BMC IP

1
ipmitool lan set 1 ipaddr

調整Supermicro X12主機板風扇轉速

1
2
3
4
# 調整為全速模式
sudo ipmitool raw 0x30 0x45 0x01 0x01
#調整風扇轉速為30%
sudo ipmitool raw 0x30 0x70 0x66 0x01 0x00 0x30

要在 Supermicro X12 主機板上使用 ipmitool 調整風扇轉速,您可以按照以下步驟進行:

  1. 安裝 ipmitool:
    在您的管理主機上,確保已安裝 ipmitool。在基於 Debian 的系統上,您可以使用以下命令安裝:

    1
    sudo apt-get install ipmitool

    在 CentOS 系統上,則使用:

    1
    yum install ipmitool
  2. 設置風扇控制模式為手動:
    默認情況下,主機板可能處於自動風扇控制模式。為了手動調整風扇轉速,您需要將風扇模式設置為全速(Full Speed)模式,這樣可以防止自動調節覆蓋您的手動設置。使用以下命令:

    1
    ipmitool -H <IPMI_IP地址> -U <用戶名> -P <密碼> raw 0x30 0x45 0x01 0x01

    其中,<IPMI_IP地址><用戶名><密碼> 分別替換為您的 IPMI 接口的實際 IP 地址、用戶名和密碼。此命令將風扇模式設置為全速運行。 citeturn0search8

  3. 手動設置風扇轉速:
    您可以使用以下命令手動設置風扇轉速:

    1
    ipmitool -H <IPMI_IP地址> -U <用戶名> -P <密碼> raw 0x30 0x70 0x66 0x01 <區域> <轉速百分比>

    其中,<區域> 參數決定了調整哪個風扇區域的轉速:

    • 0x00:系統區域風扇(通常為 CPU、GPU 等核心部件的風扇),對應風扇編號為 FAN1、FAN2 等。
    • 0x01:周邊設備區域風扇(通常為磁盤等外圍設備的風扇),對應風扇編號為 FANA、FANB 等。

    <轉速百分比> 以十六進制表示風扇轉速的百分比,範圍從 0x01(1%)到 0x64(100%)。例如,設置系統區域風扇轉速為 36%(即 0x24):

    1
    ipmitool -H <IPMI_IP地址> -U <用戶名> -P <密碼> raw 0x30 0x70 0x66 0x01 0x00 0x24

    請根據您的實際需求調整風扇轉速百分比。 citeturn0search8

  4. 調整風扇轉速閾值(可選):
    如果您發現風扇轉速不穩定,可能是因為風扇轉速低於主機板設置的下限閾值,導致風扇強制以高轉速運行。您可以使用以下命令調整風扇的下限閾值:

    1
    ipmitool -H <IPMI_IP地址> -U <用戶名> -P <密碼> sensor thresh <風扇編號> lower <LNC> <LC> <LNR>

    其中,<風扇編號> 為您要調整的風扇(如 FAN1),<LNC><LC><LNR> 分別為下限非臨界值、下限臨界值和下限不可恢復值。例如,將 FAN1 的下限閾值設置為 100:

    1
    ipmitool -H <IPMI_IP地址> -U <用戶名> -P <密碼> sensor thresh FAN1 lower 100 100 100

    這樣可以防止風扇因低於閾值而導致的不穩定運行。 citeturn0search0

注意事項:

  • 在進行上述操作時,請確保您具有管理員權限,並且已正確連接到主機板的 IPMI 接口。

  • 調整風扇轉速時,請密切關注系統溫度,確保不會因過度降低風扇轉速而導致硬體過熱。

  • 不同的 Supermicro 主機板型號可能存在差異,建議參考您的主機板使用手冊或官方文檔以獲取更多詳細資訊。

Ubuntu-Safe-Graphic解決安裝時顯卡驅動問題

安裝Ubuntu如果遇到顯示卡驅動問題,可以選用Ubuntu safe graphic模式安裝,這樣就不會遇到顯卡驅動問題了。

Nvidia Driver安裝

使用Ubuntu driver管理器安裝(推薦)

https://ubuntu.com/server/docs/nvidia-drivers-installation

移除舊驅動

https://docs.nvidia.com/datacenter/tesla/driver-installation-guide/#removing-nvidia-driver

1
2
sudo apt-get remove --purge -V "nvidia-driver*" "libxnvctrl*"
sudo apt-get autoremove --purge -V

手動停用nouveau driver
檢查nouveau有沒被載入
lsmod | grep nouveau

停用nouveau

1
2
3
4
5
6
7
8
cat <<EOF | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
options nouveau modeset=0
EOF

sudo update-initramfs -u

sudo reboot

https://docs.nvidia.com/ai-enterprise/deployment/vmware/latest/nouveau.html#disable-nouveau

nouveau driver會自動被安裝程式停用,校啟用可以依照以下指示重新啟用。(可能會失敗)

1
2
One or more modprobe configuration files to disable Nouveau have been written.  You will need to reboot your system and possibly rebuild the initramfs before these changes can take effect.  Note if you later wish to reenable Nouveau, you will    
need to delete these files: /usr/lib/modprobe.d/nvidia-installer-disable-nouveau.conf, /etc/modprobe.d/nvidia-installer-disable-nouveau.conf

安裝驅動

https://docs.nvidia.com/datacenter/tesla/driver-installation-guide/#frequently-asked-questions

https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Installation.html#install-nvidia-driver-535-183-06-for-data-center-gpus-and-560-35-03-for-rtx-gpus

類別之間的關係

在物件導向程式設計(OOP)中,類別(class)之間的關係可以分為以下幾種類型:


1. 繼承關係(Inheritance)

  • 描述:子類別繼承父類別的屬性和方法,並可以擴展或重寫這些方法。
  • 用途:表示「is-a」關係,子類別是一種父類別的特殊化。
  • 範例
    1
    2
    3
    4
    5
    6
    7
    class Animal:
    def speak(self):
    print("Animal speaks")

    class Dog(Animal): # Dog 繼承自 Animal
    def speak(self):
    print("Dog barks")

2. 組合關係(Composition)

  • 描述:一個類別包含另一個類別的實例,形成「has-a」關係。
  • 用途:用於表示部分-整體或擁有關係。
  • 範例
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    class Engine:
    def start(self):
    print("Engine starts")

    class Car:
    def __init__(self):
    self.engine = Engine() # Car 擁有一個 Engine 實例

    def drive(self):
    self.engine.start()
    print("Car is driving")

3. 關聯關係(Association)

  • 描述:一個類別和另一個類別之間有某種業務邏輯上的聯繫,但並不擁有對方的實例。
  • 用途:表示「使用」或「合作」的關係。
  • 範例
    1
    2
    3
    4
    5
    6
    7
    class Driver:
    def drive(self, car):
    car.drive()

    class Car:
    def drive(self):
    print("Car is being driven")

4. 聚合關係(Aggregation)

  • 描述:一個類別包含另一個類別的實例,但兩者是弱依賴的關係,子物件的生命周期獨立於父物件。
  • 用途:表示「部分-整體」的關係,但部分可以獨立存在。
  • 範例
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    class Wheel:
    def rotate(self):
    print("Wheel rotates")

    class Car:
    def __init__(self, wheels):
    self.wheels = wheels # Car 擁有 Wheels,但 Wheels 可以獨立存在

    def drive(self):
    for wheel in self.wheels:
    wheel.rotate()

5. 依賴關係(Dependency)

  • 描述:一個類別暫時依賴於另一個類別的功能,但不是永久的關聯。
  • 用途:通常用於方法或函數中的參數傳遞。
  • 範例
    1
    2
    3
    4
    5
    6
    7
    class Printer:
    def print_document(self, document):
    print(f"Printing: {document}")

    class User:
    def use_printer(self, printer):
    printer.print_document("MyDocument.pdf")

額外說明

  • 這些關係可以搭配使用,例如繼承 + 組合的模式經常出現在大型系統中。
  • 適當選擇關係有助於提升程式的可讀性、可重用性和維護性。

參考:
https://realpython.com/inheritance-composition-python/
Association,Aggregation,Composition and Inheritance的差異
https://itexpertsconsultant.wordpress.com/tag/class-diagram/
UML關係圖
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
https://www.umlboard.com/docs/relations/