Nvtop - 在Linux即時監控GPU使用率
Jain Wun
Posted on May 26, 2022
- 訂閱patreon即可看到更多文章 https://www.patreon.com/wade3c
- Youtube頻道 https://www.youtube.com/c/增廣建文
同時支援Nvidia以及AMD的GPU
Install
Apt
sudo apt update
sudo apt install nvtop
Dockerfile
FROM nvidia/cuda
RUN apt-get update && \
apt-get install -y cmake libncurses5-dev libncursesw5-dev git && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/local/cuda-10.1/targets/x86_64-linux/lib/stubs/libnvidia-ml.so /usr/local/lib/libnvidia-ml.so && \
ln -s /usr/local/cuda-10.1/targets/x86_64-linux/lib/stubs/libnvidia-ml.so /usr/local/lib/libnvidia-ml.so.1 && \
cd /tmp && \
git clone https://github.com/Syllo/nvtop.git && \
mkdir -p nvtop/build && cd nvtop/build && \
cmake .. && \
make && \
make install && \
cd / && \
rm -r /tmp/nvtop && \
rm /usr/local/lib/libnvidia-ml.so && \
rm /usr/local/lib/libnvidia-ml.so.1
ENTRYPOINT ["/usr/local/bin/nvtop"]
這裡cuda用的是10.2可能得視自身情況修改 (ex: RTX30不支援)
或是可以參考nvtop repo內的Dockerfile
FAQ
- ### Unable to Locate Package
Update Source List
有可能是清單內沒有可以下載的網址,比較常發生在debian,可以去source list設定non-free
sudo vim /etc/apt/sources.list
在每行的結尾加上空格與non-free (這個做法不適用於Ubuntu)
Manual Compile
有些OS並沒有提供已經編譯好的套件供安裝,這裡就得自己compile了
撰寫文章時只支援Ubuntu 20.04/ 20.10,而18.04已經裝不了
先裝必要的套件
sudo apt install cmake libncurses5-dev libncursesw5-dev git
git clone https://github.com/Syllo/nvtop.git
mkdir -p nvtop/build && cd nvtop/build
cmake .. -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON
make
# Install globally on the system
sudo make install
# Alternatively, install without privileges at a location of your choosing
# make DESTDIR="/your/install/path" install
Reference
GitHub - Syllo/nvtop: AMD and NVIDIA GPUs htop like monitoring tool
Wrap NVTOP in docker (Impossible to initialize nvidia nvml) · Issue #42 · Syllo/nvtop
nvtop not found in Debian Buster repositories · Issue #46 · Syllo/nvtop
💖 💪 🙅 🚩
Jain Wun
Posted on May 26, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.