Monitoring Nvidia GPU deploying cuPQC, Influxdb and Grafana components. This repository provides a Dockerized GPU monitoring setup that collects NVIDIA GPU power draw metrics using Telegraf, stores them in InfluxDB, and visualizes the data in Grafana.
To pull and run the container from Docker Hub:
docker pull demogoikon/gpu-monitor:latest
docker run -d --runtime=nvidia --name=gpu-monitor demogoikon/gpu-monitorThis pulls and starts the container with cuPQC, Telegraf, InfluxDB.
The steps that has been followed to setup this container are described below:
cuPQC is an NVIDIA CUDA-based library for Post-Quantum Cryptography. We followed the steps below to install it inside our container.
To install the cuPQC (CUDA Post-Quantum Cryptography) library within your Docker container, follow these steps:
Note: Initially we have ensured that our Docker container met all cuPQC requirements, including the appropriate CUDA Toolkit version and supported GPU architecture. requirements
Visit the NVIDIA cuPQC Downloads page to obtain the latest version of the cuPQC library current latest version.
Assuming you've downloaded the cuPQC package (cupqc-.tar.gz) to your host machine, you can copy it into your running Docker container using the following command:
docker cp cupqc-<version>.tar.gz <container_id>:/root/Replace with the actual version number and <container_id> with your container's ID or name.
Ensure NVIDIA GPU support is enabled inside Docker.(Guide to Run CUDA WSL Docker)
Enter you Docker container's shell:
docker exec -it <container_id> /bin/bashNavigate to the directory containing the package and extract it:
cd /root/
tar -xzf cupqc-<version>.tar.gz- Compile and link CUDA-based cuPQC examples using Nvidia's nvcc compiler using the Makefile in the 'example' - - folder. (path example: ~/cupqc/cupqc-pkg-0.2.0/example)
./example_ml_dsa
./example_ml_kemTelegraf collects GPU power draw metrics from nvidia-smi and sends them to InfluxDB.
You need first to setup a database for your data to be stored. You can follow the installation guide of Influxdb or CAM repository to deploy a database and set telegraf configuration to send your data there.
apt update && apt install telegraf -y- Modify the following sections:
Data Collection Interval:
[agent]
interval = "1s"InfluxDB Configuration:
[[outputs.influxdb_v2]]
urls = ["http://<influxdb_IP_address>:8086"]
token = "$INFLUX_TOKEN"
organization = "<organization_name>"
bucket = "<bucket_name>"Nvidia_smi plugin enabling
[[inputs.nvidia_smi]]
bin_path = "/usr/bin/nvidia-smi"
timeout = "5s"
[[outputs.influxdb_v2]]
urls = ["http://<influxdb_IP_adress>:8086"]
token = "YOUR_INFLUXDB_TOKEN"
organization = "name_of_organization"
bucket = "name_of_bucket"telegraf --config /etc/telegraf/telegraf.conf- Now Telegraf sends GPU metrics to InfluxDB.
- The python snippet provided enables recovering Nvidia GPU's power draw.
Update the snippet with the correct IP address, organization, bucket and token
# InfluxDB settings
INFLUXDB_URL = "http://<influxdb_IP_address>:8086/api/v2/write"
INFLUXDB_BUCKET = "<bucket_name>"
INFLUXDB_ORG = "<organization_name>"
INFLUXDB_TOKEN = "<influxdb****token>"- Execute the python script included in this repository to ensure power draw metrics will appear as expected.
python3 /root/gpu_power_monitor.py &- As a prerequisite you have to install and setup Grafana as described in Grafana Documentation or in step 3 of CAM repository.
Launch the Grafana UI at http://:3000 in your browser and the following Grafana login page should greet you.
-
Log in with the default credentials (admin / admin), and set new username and password.
-
Click on the Add your first data source button.
-
Choose “Connections → Data sources” on the side menu and click the “+ Add new data source” button.
-
Click the InfluxDB button.
-
On the next page, select “Flux” from the dropdown menu as the query language. Flux supports InfluxDB v2.x and is easier to set up and configure. Enter the following values:
-
Enter the following values (example image below):
HTTP:
URL: 'http://<Influxdb_IP_Address>:8087'
Auth:
User: <Your_UserName>
Password: <Your_Influxdb_Password>
InlfuxDB Details:
Organization: <organization_name>
Token: <Influxdb_Token>
Bucket: <bucket_name>
Min time interval: 300ms
Max series: 10000
- Click the
Save and Testbutton to verify the setup. The next message should be displayed.
The next step is to set up Grafana Dashboard.
-
Click on the button with the four squares and select “Dashboards” to open the “Import” dashboard screen. Follow the next steps and create a dashboard for each of your physical machines.
-
From the
Import dashboardload the provided .json file which contains the dedicated dashboard setup.
- If grafana doesn't let you upload .json file then you should copy and paste the content of .json file in the
Import via dashboard JSON modelframe and then press load. - In the provided .json file it is assumed that the username is
localadminand the name of the bucket isdocker_nvidia_bucketorDesktop_GPU. If otherwise please change those values in the entire .json file with the ones that match your setup.
- In the
Dashboardsmenu select the name of the imported dashboard.
You may see that every panel displays “No data”. In that case commit the following changes in order to enable the “No data” panels:
-
Hover your mouse over a panel and click the right top button with the three vertical dots to expand the drop down menu and select
edit -
Make sure that in
Data sourcefield is selected the name of your bucket and in the flux language code you see the correct name of your bucket, username -
Then click the “Query inspector” button and on the side menu that will appear click the “refresh” button. You should now see your metrics displayed. Exit the side menu and click “Apply” on the top right area.
-
Repeat the steps above to every panel that displays “no data”
-
Set the refresh rate to
300msto enable fast panel data updates.