基于nvidia gpu监控工具gpustat的使用(ubuntu下)
1.首先检查pip是否已安装,默认Linux(指ubuntu18.04和centos7.5)自带python版本为2.7 ,且没有pip工具pip --version#python2--查看pip版本,用于验证pip是否已安装未安装的话使用以下命令(默认为root的用户)centos下:yum install pipubuntu下:apt-get install p...
·
1.首先检查pip是否已安装,默认Linux(指ubuntu18.04和centos7.5)自带python版本为2.7 ,且没有pip工具
pip --version #python2--查看pip版本,用于验证pip是否已安装
未安装的话使用以下命令(默认为root的用户)
centos下:
yum install pip
ubuntu下:
apt-get install pip
2.安装完成再次使用“pip --version”查看pip是否安装成功,同时查看pip版本(我自己安装时系统默认安装pip版本为9.0.3),如下图即为pip安装成功
3.安装gpustat
pip install gpustat
测试使用
watch --color -n1 gpustat -cpu
安装过程可能出现的问题:
1.若错误信息提示如下,说明pip版本太低,则需要升级pip版本:
You are using pip version 9.0.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
升级命令,则是缺少
python -m pip install --upgrade pip
2.若错误信息如下,说明缺少python-dev库
Processing /root/.cache/pip/wheels/2b/47/e0/5795c4ce1bf6e5f42df33e6f265b4c980d4d2b7bf527d090e9/gpustat-0.6.0-py2-none-any.whl
Requirement already satisfied: nvidia-ml-py>=7.352.0 in /usr/local/lib/python2.7/dist-packages (from gpustat) (375.53.1)
Requirement already satisfied: six>=1.7 in /usr/local/lib/python2.7/dist-packages (from gpustat) (1.14.0)
Collecting psutil
Using cached psutil-5.7.0.tar.gz (449 kB)
Collecting blessings>=1.6
Using cached blessings-1.7-py2-none-any.whl (26 kB)
Building wheels for collected packages: psutil
Building wheel for psutil (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-y4obCv/psutil/setup.py'"'"'; __file__='"'"'/tmp/pip-install-y4obCv/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-VB11PO
cwd: /tmp/pip-install-y4obCv/psutil/
Complete output (44 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psaix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
creating build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/__init__.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/__main__.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/runner.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_system.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_process.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-2.7/psutil/tests
running build_ext
building 'psutil._psutil_linux' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/psutil
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-5Z483E/python2.7-2.7.17=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=570 -DPSUTIL_LINUX=1 -I/usr/include/python2.7 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_common.o
psutil/_psutil_common.c:9:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for psutil
Running setup.py clean for psutil
Failed to build psutil
Installing collected packages: psutil, blessings, gpustat
Running setup.py install for psutil ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-y4obCv/psutil/setup.py'"'"'; __file__='"'"'/tmp/pip-install-y4obCv/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-VXx2nT/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/psutil
cwd: /tmp/pip-install-y4obCv/psutil/
Complete output (44 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psaix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
creating build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/__init__.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/__main__.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/runner.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_system.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_process.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-2.7/psutil/tests
running build_ext
building 'psutil._psutil_linux' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/psutil
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-5Z483E/python2.7-2.7.17=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=570 -DPSUTIL_LINUX=1 -I/usr/include/python2.7 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_common.o
psutil/_psutil_common.c:9:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-y4obCv/psutil/setup.py'"'"'; __file__='"'"'/tmp/pip-install-y4obCv/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-VXx2nT/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/psutil Check the logs for full command output.
python-dev库安装:
注意:python-dev的包在centos的yum中不叫python-dev,而是python-devel.
#需要指定python版本,以我自己为例
python --version
Python 2.7.17
#则安装对应版本的包
apt install python2.7-dev #ubuntu下
yum install python2.7-devel #centos下
更多推荐
已为社区贡献2条内容
所有评论(0)