├── LICENSE
├── README.md
├── gpuGraph.png
└── gpuGraph.py
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-2019 Jetsonhacks
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # gpuGraph
2 | A very simple moving graph of GPU activity for the NVIDIA Jetson Nano Developer Kit. This allows visualization of GPU utilization.
3 |
4 | 
5 |
6 | The graph is implemented as an animated Python Matplotlib graph. The app requires the Python Matplotlib library.
7 |
8 | For Python 2.7, Matplotlib may be installed as follows:
9 |
10 | $ sudo apt-get install python-matplotlib
11 |
12 | For Python 3, Matplotlib may be installed as follows:
13 |
14 | $ sudo apt-get install python3-matplotlib
15 |
16 | You can run the app:
17 |
18 | $ ./gpuGraph.py
19 |
20 | or:
21 |
22 | $ python gpuGraph.py
23 |
24 | or:
25 |
26 | $ python3 gpuGraph.py
27 |
28 |
Release Notes
29 |
30 | Initial Release March, 2019
31 | * L4T 232.1.0 (JetPack 4.2)
32 | * Tested on Jetson Nano Developer Kit
33 |
34 |
--------------------------------------------------------------------------------
/gpuGraph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JetsonHacksNano/gpuGraph/09a27e27bbb37830872eed7240e05b117fc05032/gpuGraph.png
--------------------------------------------------------------------------------
/gpuGraph.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # MIT License
3 | # Copyright (c) 2018-2019 Jetsonhacks
4 | import sys
5 | import os
6 | import numpy as np
7 | import matplotlib.pyplot as plt
8 | from matplotlib.animation import FuncAnimation
9 | from collections import deque
10 |
11 | gpuLoadFile="/sys/devices/gpu.0/load"
12 | # On the Jetson Nano this is a symbolic link to:
13 | # gpuLoadFile="/sys/devices/platform/host1x/57000000.gpu/load"
14 |
15 | fig = plt.figure(figsize=(6,2))
16 | plt.subplots_adjust(top=0.85, bottom=0.30)
17 | fig.set_facecolor('#F2F1F0')
18 | fig.canvas.set_window_title('GPU Activity Monitor')
19 |
20 | # Subplot for the GPU activity
21 | gpuAx = plt.subplot2grid((1,1), (0,0), rowspan=2, colspan=1)
22 |
23 | # For the comparison
24 | gpuLine, = gpuAx.plot([],[])
25 |
26 | # The line points in x,y list form
27 | gpuy_list = deque([0]*240)
28 | gpux_list = deque(np.linspace(60,0,num=240))
29 |
30 | fill_lines=0
31 |
32 | def initGraph():
33 | global gpuAx
34 | global gpuLine
35 | global fill_lines
36 |
37 |
38 | gpuAx.set_xlim(60, 0)
39 | gpuAx.set_ylim(-5, 105)
40 | gpuAx.set_title('GPU History')
41 | gpuAx.set_ylabel('GPU Usage (%)')
42 | gpuAx.set_xlabel('Seconds');
43 | gpuAx.grid(color='gray', linestyle='dotted', linewidth=1)
44 |
45 | gpuLine.set_data([],[])
46 | fill_lines=gpuAx.fill_between(gpuLine.get_xdata(),50,0)
47 |
48 | return [gpuLine] + [fill_lines]
49 |
50 | def updateGraph(frame):
51 | global fill_lines
52 | global gpuy_list
53 | global gpux_list
54 | global gpuLine
55 | global gpuAx
56 |
57 |
58 | # Now draw the GPU usage
59 | gpuy_list.popleft()
60 | with open(gpuLoadFile, 'r') as gpuFile:
61 | fileData = gpuFile.read()
62 | # The GPU load is stored as a percentage * 10, e.g 256 = 25.6%
63 | gpuy_list.append(int(fileData)/10)
64 | gpuLine.set_data(gpux_list,gpuy_list)
65 | fill_lines.remove()
66 | fill_lines=gpuAx.fill_between(gpux_list,0,gpuy_list, facecolor='cyan', alpha=0.50)
67 |
68 | return [gpuLine] + [fill_lines]
69 |
70 |
71 | # Keep a reference to the FuncAnimation, so it does not get garbage collected
72 | animation = FuncAnimation(fig, updateGraph, frames=200,
73 | init_func=initGraph, interval=250, blit=True)
74 |
75 | plt.show()
76 |
77 |
78 |
--------------------------------------------------------------------------------