XuehaiPan / nvitop

An interactive NVIDIA-GPU process viewer and beyond, the one-stop solution for GPU process management.
https://nvitop.readthedocs.io
Apache License 2.0
4.56k stars 144 forks source link

[BUG] ERROR: Failed to initialize `curses` (curs_set() returned ERR) in tmux environment #97

Closed slacklife closed 11 months ago

slacklife commented 11 months ago

Required prerequisites

What version of nvitop are you using?

1.3.0

Operating system and version

Ubuntu 18.04.5 LTS

NVIDIA driver version

470.103.01

NVIDIA-SMI

│   1 2721979 C     N/A  8231MiB   0   N/A   N/A   N/A  No Such Process                            │
                                                                                                      ├──────────────────────────────────────────────────────────────────────────────────────────────────┤
                                                                                                                                                                                                          │   2 1819872 C     N/A 67.46GiB  97   N/A   N/A   N/A  No Such Process                            │
                                                       │   2 2721979 C     N/A  8231MiB   0   N/A   N/A   N/A  No Such Process                            │
                                                                                                                                                           ├──────────────────────────────────────────────────────────────────────────────────────────────────┤
        │   3 1819873 C     N/A 61.67GiB  98   N/A   N/A   N/A  No Such Process                            │
                                                                                                            │   3 2721979 C     N/A  7185MiB   0   N/A   N/A   N/A  No Such Process                            │
                                                                                                                                                                                                                ╘══════════════════════════════════════════════════════════════════════════════════════════════════╛
                                                             ERROR: Failed to initialize `curses` (curs_set() returned ERR)

Python environment

gpustat==1.1.1 nvidia-cublas-cu11==11.10.3.66 nvidia-cuda-cupti-cu11==11.7.101 nvidia-cuda-nvrtc-cu11==11.7.99 nvidia-cuda-runtime-cu11==11.7.99 nvidia-cudnn-cu11==8.5.0.96 nvidia-cufft-cu11==10.9.0.58 nvidia-curand-cu11==10.2.10.91 nvidia-cusolver-cu11==11.4.0.1 nvidia-cusparse-cu11==11.7.4.91 nvidia-htop==1.0.5 nvidia-ml-py==12.535.108 nvidia-nccl-cu11==2.14.3 nvidia-nvtx-cu11==11.7.91 py3nvml==0.2.7

Problem description

It works in normal shell. However, it fails in tmux 3.1 environment. It report ERROR: Failed to initialize `curses` (curs_set() returned ERR)

I have tried the solution here.

sudo apt install python3-dev python3-pip /usr/bin/python3`` -m pip install --user nvitop ~/.local/bin/nvitop

But it produced the same issue, no matter in the conda environment or not. It only differs when using tmux or not.

Steps to Reproduce

The Python snippets (if any):

Command lines:

nvitop

Traceback

No response

Logs

No response

Expected behavior

No response

Additional context

No response

XuehaiPan commented 11 months ago

It works in normal shell. However, it fails in tmux 3.1 environment. It report ERROR: Failed to initialize `curses` (curs_set() returned ERR)

It only differs when using tmux or not.

Hi @slacklife, can you try to set:

set -g default-terminal "tmux-256color"
set -g utf8 on

in your tmux.conf? Then you need to reload your tmux configuration.

slacklife commented 11 months ago

Thanks for your comment, but it didn't work. set -g utf8 on is for an old version of tmux. They were set in a way so they don't error in newer versions. Please refer to here

set -g default-terminal "tmux-256color" is my default setting in my .tmux.conf

Are there any other solutions to solve my problem?

XuehaiPan commented 11 months ago

@slacklife Do you set your TERM environment variable correctly in your tmux shell? For example:

export TERM="xterm-256color"
export LC_ALL="en_US.UTF-8"
slacklife commented 11 months ago

It works magically! Many thanks! Nvitop is a great tool!

XuehaiPan commented 11 months ago

It works magically!

Glad to hear that. You could put these in your shell profile (e.g., ~/.bashrc, ~/.zshrc) to automatically set these variables on startup.

export TERM="xterm-256color"
export LC_ALL="en_US.UTF-8"