rbonghi / jetson_stats

📊 Simple package for monitoring and control your NVIDIA Jetson [Orin, Xavier, Nano, TX] series
https://rnext.it/jetson_stats
GNU Affero General Public License v3.0
2.17k stars 264 forks source link

jtop crashes with ZeroDivisionError on custom power single-cpu power model #199

Closed jonashoechst closed 1 year ago

jonashoechst commented 2 years ago

When jtop is started with a custom single-cpu power model (other cores deactivated) it will crash when changing to the CPU pane. It seems to be an edge case not handled correctly. I'm pretty sure it can be fixed easily :-)

To Reproduce

  1. Add a custom power mode, as described in NVIDIAs documentation, i.e. edit /etc/nvpmodel.conf and append:
    < POWER_MODEL ID=2 NAME=MIN >
    CPU_ONLINE CORE_0 1
    CPU_ONLINE CORE_1 0
    CPU_ONLINE CORE_2 0
    CPU_ONLINE CORE_3 0
    CPU_A57 MIN_FREQ  0
    CPU_A57 MAX_FREQ 614000
    #CPU_A57 MAX_FREQ 918000
    GPU_POWER_CONTROL_ENABLE GPU_PWR_CNTL_EN on
    GPU MIN_FREQ 0
    GPU MAX_FREQ 230000000
    GPU_POWER_CONTROL_DISABLE GPU_PWR_CNTL_DIS auto
    EMC MAX_FREQ 1600000000
  2. Restart jetson_stats, i.e. sudo systemctl restart jetson_stats
  3. Open jtop
  4. Goto CPU pane
  5. Crash!
Traceback (most recent call last):
  File "/usr/local/bin/jtop", line 11, in <module>
    load_entry_point('jetson-stats==3.1.2', 'console_scripts', 'jtop')()
  File "/usr/local/lib/python3.6/dist-packages/jtop/__main__.py", line 148, in main
    curses.wrapper(JTOPGUI, jetson, [ALL, GPU, CPU, MEM, CTRL, INFO], init_page=args.page, loop=args.loop, seconds=LOOP_SECONDS)
  File "/usr/lib/python3.6/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python3.6/dist-packages/jtop/gui/jtopgui.py", line 109, in __init__
    self.run(loop, seconds)
  File "/usr/local/lib/python3.6/dist-packages/jtop/gui/jtopgui.py", line 138, in run
    self.draw()
  File "/usr/local/lib/python3.6/dist-packages/jtop/gui/lib/common.py", line 80, in wrapped
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/jtop/gui/jtopgui.py", line 153, in draw
    page.draw(self.key, self.mouse)
  File "/usr/local/lib/python3.6/dist-packages/jtop/gui/lib/common.py", line 120, in wrapped
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/jtop/gui/pcpu.py", line 94, in draw
    x_size = (width - x_offset - 6) // (n_cpu // 2)
ZeroDivisionError: integer division or modulo by zero

Additional context

$ jetson_release -v
 - NVIDIA Jetson Nano (Developer Kit Version)
   * Jetpack 4.6 [L4T 32.6.1]
   * NV Power Mode: BE - Type: 2
   * jetson_stats.service: active
 - Board info:
   * Type: Nano (Developer Kit Version)
   * SOC Family: tegra210 - ID:33
   * Module: P3448-0000 - Board: P3449-0000
   * Code Name: porg
   * Boardids: 3448
   * CUDA GPU architecture (ARCH_BIN): 5.3
   * Serial Number: 1424720068740
 - Libraries:
   * CUDA: 10.2.300
   * cuDNN: 8.2.1.32
   * TensorRT: 8.0.1.6
   * Visionworks: 1.6.0.501
   * OpenCV: 4.1.1 compiled CUDA: NO
   * VPI: ii libnvvpi1 1.1.15 arm64 NVIDIA Vision Programming Interface library
   * Vulkan: 1.2.70
 - jetson-stats:
   * Version 3.1.2
   * Works on Python 3.6.9
$ jtop -v
jtop 3.1.2
rbonghi commented 1 year ago

This error should now be fixed with the latest release 4.0 try to install and check again

sudo -H pip install -U jetson-stats