Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named '_curses' #156

Open
Pagey opened this issue May 31, 2023 · 2 comments
Open

ModuleNotFoundError: No module named '_curses' #156

Pagey opened this issue May 31, 2023 · 2 comments
Labels

Comments

@Pagey
Copy link

Pagey commented May 31, 2023

Describe the bug

getting "ModuleNotFoundError: No module named '_curses'" when running on a freshly installed gpustat (1.1) on an EC2 instance

Screenshots or Program Output

> ubuntu@..$ pip install gpustat
Collecting gpustat
  Downloading gpustat-1.1.tar.gz (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 12.4 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting nvidia-ml-py>=11.450.129 (from gpustat)
  Downloading nvidia_ml_py-11.525.112-py3-none-any.whl (35 kB)
Requirement already satisfied: psutil>=5.6.0 in /opt/tensorflow/lib/python3.10/site-packages (from gpustat) (5.9.5)
Collecting blessed>=1.17.1 (from gpustat)
  Downloading blessed-1.20.0-py2.py3-none-any.whl (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.4/58.4 kB 7.2 MB/s eta 0:00:00
Requirement already satisfied: wcwidth>=0.1.4 in /opt/tensorflow/lib/python3.10/site-packages (from blessed>=1.17.1->gpustat) (0.2.6)
Requirement already satisfied: six>=1.9.0 in /opt/tensorflow/lib/python3.10/site-packages (from blessed>=1.17.1->gpustat) (1.16.0)
Building wheels for collected packages: gpustat
  Building wheel for gpustat (pyproject.toml) ... done
  Created wheel for gpustat: filename=gpustat-1.1-py3-none-any.whl size=26280 sha256=39e7fec469c2a02d32fc0f0ae0fc121d504a72129af5451fa7046df2efe4f155
  Stored in directory: /home/ubuntu/.cache/pip/wheels/ee/d0/2c/1e02440645c2318ba03aea99993a44a9108dc8f74de0bd370b
Successfully built gpustat
Installing collected packages: nvidia-ml-py, blessed, gpustat
Successfully installed blessed-1.20.0 gpustat-1.1 nvidia-ml-py-11.525.112
ubuntu@..$
ubuntu@..$
ubuntu@..$ gpustat
Traceback (most recent call last):
  File "/opt/tensorflow/bin/gpustat", line 5, in <module>
    from gpustat import main
  File "/opt/tensorflow/lib/python3.10/site-packages/gpustat/__init__.py", line 16, in <module>
    from .core import GPUStat, GPUStatCollection
  File "/opt/tensorflow/lib/python3.10/site-packages/gpustat/core.py", line 21, in <module>
    from blessed import Terminal
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/__init__.py", line 14, in <module>
    from blessed.terminal import Terminal  # type: ignore
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/terminal.py", line 21, in <module>
    from .keyboard import (_time_left,
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/keyboard.py", line 19, in <module>
    import curses
  File "/usr/local/lib/python3.10/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'

Please provide the output of gpustat --debug and nvidia-smi. Or attach screenshots if applicable.

> ubuntu@..$ gpustat --debug
Traceback (most recent call last):
  File "/opt/tensorflow/bin/gpustat", line 5, in <module>
    from gpustat import main
  File "/opt/tensorflow/lib/python3.10/site-packages/gpustat/__init__.py", line 16, in <module>
    from .core import GPUStat, GPUStatCollection
  File "/opt/tensorflow/lib/python3.10/site-packages/gpustat/core.py", line 21, in <module>
    from blessed import Terminal
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/__init__.py", line 14, in <module>
    from blessed.terminal import Terminal  # type: ignore
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/terminal.py", line 21, in <module>
    from .keyboard import (_time_left,
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/keyboard.py", line 19, in <module>
    import curses
  File "/usr/local/lib/python3.10/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
ubuntu@..$ nvidia-smi
Wed May 31 18:54:12 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.12    Driver Version: 525.85.12    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA A10G         On   | 00000000:00:1E.0 Off |                    0 |
|  0%   21C    P8    14W / 300W |      0MiB / 23028MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
ubuntu@..$

Environment information:

  • OS: Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-1036-aws x86_64)
  • NVIDIA Driver version: 525.85.12
  • The name(s) of GPU card: [can be omitted if screenshot attached]
  • gpustat version: 1.1
  • pynvml version: 11.525.112

Installed from AMI: Deep Learning AMI GPU TensorFlow 2.12.0 (Ubuntu 20.04) 20230529
ami-02106eb87ff145f00 (64-bit (x86))

Additional context

Installed on a new EC2 instance from above mentioned AMI- pip install output pasted above

@Pagey Pagey added the bug label May 31, 2023
@wookayin
Copy link
Owner

wookayin commented Jun 1, 2023

Thank you for the detailed report. It is that your system python is broken, in particular the curses standard library. You can also reproduce this with

$ python
>>> import curses

so this wouldn't be a problem of gpustat nor any other third-party packages.

I think it's because the minimal EC2 image does not have ncurses installed on the system. Most UNIX system should have ncurses installed by default, but the minimal AMI image does not.

Please try installing ncurses:

sudo apt-get update
sudo apt-get install -y libncurses5-dev libncursesw5-dev

See also https://bugs.python.org/issue43728

@Pagey
Copy link
Author

Pagey commented Jun 1, 2023

ubuntu@..$ sudo apt-get update
Hit:1 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:4 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64  InRelease
Hit:5 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64  InRelease
Hit:6 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease
Get:7 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:8 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2611 kB]
Get:9 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [16.8 kB]
Get:10 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1067 kB]
Get:11 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [24.9 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2229 kB]
Get:13 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [358 kB]
Get:14 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [13.0 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [1833 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [256 kB]
Get:17 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [842 kB]
Get:18 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [18.4 kB]
Fetched 9605 kB in 2s (5386 kB/s)
Reading package lists... Done
ubuntu@..$ sudo apt-get install -y libncurses5-dev libncursesw5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libncurses-dev
Suggested packages:
  ncurses-doc
The following NEW packages will be installed:
  libncurses-dev libncurses5-dev libncursesw5-dev
0 upgraded, 3 newly installed, 0 to remove and 38 not upgraded.
Need to get 342 kB of archives.
After this operation, 2410 kB of additional disk space will be used.
Get:1 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 libncurses-dev amd64 6.2-0ubuntu2.1 [340 kB]
Get:2 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 libncurses5-dev amd64 6.2-0ubuntu2.1 [984 B]
Get:3 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 libncursesw5-dev amd64 6.2-0ubuntu2.1 [988 B]
Fetched 342 kB in 0s (15.1 MB/s)
Selecting previously unselected package libncurses-dev:amd64.
(Reading database ... 147493 files and directories currently installed.)
Preparing to unpack .../libncurses-dev_6.2-0ubuntu2.1_amd64.deb ...
Unpacking libncurses-dev:amd64 (6.2-0ubuntu2.1) ...
Selecting previously unselected package libncurses5-dev:amd64.
Preparing to unpack .../libncurses5-dev_6.2-0ubuntu2.1_amd64.deb ...
Unpacking libncurses5-dev:amd64 (6.2-0ubuntu2.1) ...
Selecting previously unselected package libncursesw5-dev:amd64.
Preparing to unpack .../libncursesw5-dev_6.2-0ubuntu2.1_amd64.deb ...
Unpacking libncursesw5-dev:amd64 (6.2-0ubuntu2.1) ...
Setting up libncurses-dev:amd64 (6.2-0ubuntu2.1) ...
Setting up libncursesw5-dev:amd64 (6.2-0ubuntu2.1) ...
Setting up libncurses5-dev:amd64 (6.2-0ubuntu2.1) ...
Processing triggers for man-db (2.9.1-1) ...
ubuntu@..$
ubuntu@..$
ubuntu@..$ gpustat -i
Traceback (most recent call last):
  File "/opt/tensorflow/bin/gpustat", line 5, in <module>
    from gpustat import main
  File "/opt/tensorflow/lib/python3.10/site-packages/gpustat/__init__.py", line 16, in <module>
    from .core import GPUStat, GPUStatCollection
  File "/opt/tensorflow/lib/python3.10/site-packages/gpustat/core.py", line 31, in <module>
    from blessed import Terminal
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/__init__.py", line 14, in <module>
    from blessed.terminal import Terminal  # type: ignore
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/terminal.py", line 21, in <module>
    from .keyboard import (_time_left,
  File "/opt/tensorflow/lib/python3.10/site-packages/blessed/keyboard.py", line 19, in <module>
    import curses
  File "/usr/local/lib/python3.10/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
ubuntu@..$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants