jetsontools 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jetsontools-0.0.1/LICENSE +21 -0
- jetsontools-0.0.1/MANIFEST.in +3 -0
- jetsontools-0.0.1/PKG-INFO +58 -0
- jetsontools-0.0.1/README.md +2 -0
- jetsontools-0.0.1/pyproject.toml +176 -0
- jetsontools-0.0.1/setup.cfg +4 -0
- jetsontools-0.0.1/src/jetsontools/__init__.py +105 -0
- jetsontools-0.0.1/src/jetsontools/_scripts/jetson_libraries.sh +123 -0
- jetsontools-0.0.1/src/jetsontools/_scripts/jetson_variables.sh +207 -0
- jetsontools-0.0.1/src/jetsontools/_tegrastats.py +145 -0
- jetsontools-0.0.1/src/jetsontools/info/__init__.py +23 -0
- jetsontools-0.0.1/src/jetsontools/info/__main__.py +11 -0
- jetsontools-0.0.1/src/jetsontools/info/_info.py +182 -0
- jetsontools-0.0.1/src/jetsontools/py.typed +0 -0
- jetsontools-0.0.1/src/jetsontools.egg-info/PKG-INFO +58 -0
- jetsontools-0.0.1/src/jetsontools.egg-info/SOURCES.txt +17 -0
- jetsontools-0.0.1/src/jetsontools.egg-info/dependency_links.txt +1 -0
- jetsontools-0.0.1/src/jetsontools.egg-info/requires.txt +30 -0
- jetsontools-0.0.1/src/jetsontools.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Justin Davis
|
|
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.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: jetsontools
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Tools for working with NVIDIA Jetson devices.
|
|
5
|
+
Author-email: Justin Davis <davisjustin302@gmail.com>
|
|
6
|
+
Maintainer-email: Justin Davis <davisjustin302@gmail.com>
|
|
7
|
+
Project-URL: Homepage, https://github.com/justincdavis/jetsontools
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/justincdavis/jetsontools/issues
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Natural Language :: English
|
|
21
|
+
Classifier: Intended Audience :: Developers
|
|
22
|
+
Classifier: Intended Audience :: Education
|
|
23
|
+
Classifier: Intended Audience :: Science/Research
|
|
24
|
+
Classifier: Intended Audience :: Education
|
|
25
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: <=3.13,>=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: typing_extensions>=4.0.0
|
|
31
|
+
Provides-Extra: ci
|
|
32
|
+
Requires-Dist: pyupgrade>=3.10; extra == "ci"
|
|
33
|
+
Requires-Dist: ruff>=0.4.5; extra == "ci"
|
|
34
|
+
Requires-Dist: mypy>=1.10.0; extra == "ci"
|
|
35
|
+
Requires-Dist: types-setuptools>=57.0.0; extra == "ci"
|
|
36
|
+
Requires-Dist: types-tqdm>=4.66.0; extra == "ci"
|
|
37
|
+
Provides-Extra: test
|
|
38
|
+
Requires-Dist: pytest>=6.2.0; extra == "test"
|
|
39
|
+
Requires-Dist: hypothesis[numpy]>=6.98.0; extra == "test"
|
|
40
|
+
Requires-Dist: pybboxes>=0.1.6; extra == "test"
|
|
41
|
+
Provides-Extra: docs
|
|
42
|
+
Requires-Dist: sphinx>=6.1.0; extra == "docs"
|
|
43
|
+
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
44
|
+
Requires-Dist: myst_parser>=1.0.0; extra == "docs"
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: jetsontools[jit]; extra == "dev"
|
|
47
|
+
Requires-Dist: jetsontools[ci]; extra == "dev"
|
|
48
|
+
Requires-Dist: jetsontools[test]; extra == "dev"
|
|
49
|
+
Requires-Dist: jetsontools[docs]; extra == "dev"
|
|
50
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
51
|
+
Requires-Dist: wheel>=0.37.0; extra == "dev"
|
|
52
|
+
Requires-Dist: bumpver>=2023.1126; extra == "dev"
|
|
53
|
+
Requires-Dist: pyclean>=2.7.0; extra == "dev"
|
|
54
|
+
Requires-Dist: pyright>=1.1.348; extra == "dev"
|
|
55
|
+
Requires-Dist: seaborn>=0.13.0; extra == "dev"
|
|
56
|
+
|
|
57
|
+
# jetsontools
|
|
58
|
+
Tools for working with NVIDIA Jetson devices.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "jetsontools"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{name="Justin Davis", email="davisjustin302@gmail.com"},
|
|
10
|
+
]
|
|
11
|
+
maintainers = [
|
|
12
|
+
{name="Justin Davis", email="davisjustin302@gmail.com"},
|
|
13
|
+
]
|
|
14
|
+
description = "Tools for working with NVIDIA Jetson devices."
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.8",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Operating System :: POSIX :: Linux",
|
|
28
|
+
"Natural Language :: English",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"Intended Audience :: Education",
|
|
31
|
+
"Intended Audience :: Science/Research",
|
|
32
|
+
"Intended Audience :: Education",
|
|
33
|
+
"Intended Audience :: End Users/Desktop",
|
|
34
|
+
"Typing :: Typed",
|
|
35
|
+
]
|
|
36
|
+
requires-python=">=3.8, <=3.13"
|
|
37
|
+
dependencies = [
|
|
38
|
+
"typing_extensions>=4.0.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
"Homepage" = "https://github.com/justincdavis/jetsontools"
|
|
43
|
+
"Bug Tracker" = "https://github.com/justincdavis/jetsontools/issues"
|
|
44
|
+
|
|
45
|
+
[project.optional-dependencies]
|
|
46
|
+
ci = [
|
|
47
|
+
"pyupgrade>=3.10",
|
|
48
|
+
"ruff>=0.4.5",
|
|
49
|
+
"mypy>=1.10.0",
|
|
50
|
+
"types-setuptools>=57.0.0",
|
|
51
|
+
"types-tqdm>=4.66.0",
|
|
52
|
+
]
|
|
53
|
+
test = [
|
|
54
|
+
"pytest>=6.2.0",
|
|
55
|
+
"hypothesis[numpy]>=6.98.0",
|
|
56
|
+
"pybboxes>=0.1.6",
|
|
57
|
+
]
|
|
58
|
+
docs = [
|
|
59
|
+
"sphinx>=6.1.0",
|
|
60
|
+
"sphinx-rtd-theme>=1.3.0",
|
|
61
|
+
"myst_parser>=1.0.0",
|
|
62
|
+
]
|
|
63
|
+
dev = [
|
|
64
|
+
"jetsontools[jit]",
|
|
65
|
+
"jetsontools[ci]",
|
|
66
|
+
"jetsontools[test]",
|
|
67
|
+
"jetsontools[docs]",
|
|
68
|
+
"twine>=4.0.0",
|
|
69
|
+
"wheel>=0.37.0",
|
|
70
|
+
"bumpver>=2023.1126",
|
|
71
|
+
"pyclean>=2.7.0",
|
|
72
|
+
"pyright>=1.1.348",
|
|
73
|
+
"seaborn>=0.13.0",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[tool.bumpver]
|
|
77
|
+
current_version = "0.0.1"
|
|
78
|
+
version_pattern = "MAJOR.MINOR.PATCH"
|
|
79
|
+
commit_message = "Bump version {old_version} -> {new_version}"
|
|
80
|
+
commit = true
|
|
81
|
+
tag = true
|
|
82
|
+
push = false
|
|
83
|
+
|
|
84
|
+
[tool.bumpver.file_patterns]
|
|
85
|
+
"pyproject.toml" = ['current_version = "{version}"', 'version = "{version}"']
|
|
86
|
+
"src/jetsontools/__init__.py" = ["{version}"]
|
|
87
|
+
"docs/conf.py" = ["{version}"]
|
|
88
|
+
|
|
89
|
+
[tool.setuptools.packages.find]
|
|
90
|
+
where = ["src"]
|
|
91
|
+
|
|
92
|
+
[tool.setuptools.package-data]
|
|
93
|
+
"jetsontools" = ["py.typed"]
|
|
94
|
+
|
|
95
|
+
[tool.ruff]
|
|
96
|
+
fix = true
|
|
97
|
+
show-fixes = true
|
|
98
|
+
target-version = "py38"
|
|
99
|
+
builtins = ["_"]
|
|
100
|
+
line-length = 88
|
|
101
|
+
indent-width = 4
|
|
102
|
+
|
|
103
|
+
[tool.ruff.format]
|
|
104
|
+
quote-style = "double"
|
|
105
|
+
indent-style = "space"
|
|
106
|
+
skip-magic-trailing-comma = false
|
|
107
|
+
line-ending = "auto"
|
|
108
|
+
docstring-code-format = true
|
|
109
|
+
docstring-code-line-length = "dynamic"
|
|
110
|
+
|
|
111
|
+
[tool.ruff.lint]
|
|
112
|
+
select = ["ALL"]
|
|
113
|
+
ignore = ["PLR", "C901", "E501", "D203", "D212", "ERA", "DOC502"]
|
|
114
|
+
fixable = ["ALL"]
|
|
115
|
+
unfixable = []
|
|
116
|
+
exclude = [
|
|
117
|
+
".bzr",
|
|
118
|
+
".direnv",
|
|
119
|
+
".eggs",
|
|
120
|
+
".git",
|
|
121
|
+
".git-rewrite",
|
|
122
|
+
".hg",
|
|
123
|
+
".mypy_cache",
|
|
124
|
+
".nox",
|
|
125
|
+
".pants.d",
|
|
126
|
+
".pytype",
|
|
127
|
+
".ruff_cache",
|
|
128
|
+
".svn",
|
|
129
|
+
".tox",
|
|
130
|
+
".venv",
|
|
131
|
+
"__pypackages__",
|
|
132
|
+
"_build",
|
|
133
|
+
"buck-out",
|
|
134
|
+
"build",
|
|
135
|
+
"dist",
|
|
136
|
+
"node_modules",
|
|
137
|
+
"venv",
|
|
138
|
+
]
|
|
139
|
+
per-file-ignores = {}
|
|
140
|
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
141
|
+
|
|
142
|
+
[tool.mypy]
|
|
143
|
+
python_version = "3.8"
|
|
144
|
+
warn_unused_configs = true
|
|
145
|
+
warn_redundant_casts = true
|
|
146
|
+
warn_unused_ignores = false
|
|
147
|
+
strict_equality = true
|
|
148
|
+
check_untyped_defs = true
|
|
149
|
+
disallow_subclassing_any = true
|
|
150
|
+
disallow_untyped_decorators = true
|
|
151
|
+
disallow_any_generics = false
|
|
152
|
+
disallow_untyped_calls = true
|
|
153
|
+
disallow_incomplete_defs = true
|
|
154
|
+
disallow_untyped_defs = true
|
|
155
|
+
no_implicit_reexport = true
|
|
156
|
+
warn_return_any = true
|
|
157
|
+
|
|
158
|
+
[tool.pyright]
|
|
159
|
+
include = ["src"]
|
|
160
|
+
exclude = ["**/node_modules",
|
|
161
|
+
"**/__pycache__",
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
ignore = ["scripts/*"]
|
|
165
|
+
|
|
166
|
+
defineConstant = {DEBUG = true}
|
|
167
|
+
stubPath = "typings"
|
|
168
|
+
reportMissingImports = true
|
|
169
|
+
reportMissingTypeStubs = false
|
|
170
|
+
|
|
171
|
+
pythonVersion = "3.8"
|
|
172
|
+
pythonPlatform = "Linux"
|
|
173
|
+
|
|
174
|
+
executionEnvironments = [
|
|
175
|
+
{ root = "src", pythonVersion = "3.8", stubPath = "typings" },
|
|
176
|
+
]
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Copyright (c) 2024 Justin Davis (davisjustin302@gmail.com)
|
|
2
|
+
#
|
|
3
|
+
# MIT License
|
|
4
|
+
# ruff: noqa: E402, I001
|
|
5
|
+
"""
|
|
6
|
+
Package for bounding boxes and their operations.
|
|
7
|
+
|
|
8
|
+
Submodules
|
|
9
|
+
----------
|
|
10
|
+
info
|
|
11
|
+
Tools for getting information about the Jetson device.
|
|
12
|
+
|
|
13
|
+
Classes
|
|
14
|
+
-------
|
|
15
|
+
Tegrastats
|
|
16
|
+
Runs tegrastats in a separate process and stores output in a file.
|
|
17
|
+
|
|
18
|
+
Functions
|
|
19
|
+
---------
|
|
20
|
+
set_log_level
|
|
21
|
+
Set the log level for the jetsontools package.
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
# setup the logger before importing anything else
|
|
28
|
+
import logging
|
|
29
|
+
import os
|
|
30
|
+
import sys
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# Created from answer by Dennis at:
|
|
34
|
+
# https://stackoverflow.com/questions/7621897/python-logging-module-globally
|
|
35
|
+
def _setup_logger(level: str | None = None) -> None:
|
|
36
|
+
if level is not None:
|
|
37
|
+
level = level.upper()
|
|
38
|
+
level_map: dict[str | None, int] = {
|
|
39
|
+
"DEBUG": logging.DEBUG,
|
|
40
|
+
"INFO": logging.INFO,
|
|
41
|
+
"WARNING": logging.WARNING,
|
|
42
|
+
"WARN": logging.WARNING,
|
|
43
|
+
"ERROR": logging.ERROR,
|
|
44
|
+
"CRITICAL": logging.CRITICAL,
|
|
45
|
+
None: logging.WARNING,
|
|
46
|
+
}
|
|
47
|
+
try:
|
|
48
|
+
log_level = level_map[level]
|
|
49
|
+
except KeyError:
|
|
50
|
+
log_level = logging.WARNING
|
|
51
|
+
|
|
52
|
+
# create logger
|
|
53
|
+
logger = logging.getLogger(__package__)
|
|
54
|
+
logger.setLevel(log_level)
|
|
55
|
+
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")
|
|
56
|
+
stdout_handler = logging.StreamHandler(sys.stdout)
|
|
57
|
+
stdout_handler.setLevel(log_level)
|
|
58
|
+
stdout_handler.setFormatter(formatter)
|
|
59
|
+
logger.addHandler(stdout_handler)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def set_log_level(level: str) -> None:
|
|
63
|
+
"""
|
|
64
|
+
Set the log level for the jetsontools package.
|
|
65
|
+
|
|
66
|
+
Parameters
|
|
67
|
+
----------
|
|
68
|
+
level : str
|
|
69
|
+
The log level to set. One of "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL".
|
|
70
|
+
|
|
71
|
+
Raises
|
|
72
|
+
------
|
|
73
|
+
ValueError
|
|
74
|
+
If the level is not one of the allowed values.
|
|
75
|
+
|
|
76
|
+
"""
|
|
77
|
+
if level.upper() not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
|
|
78
|
+
err_msg = f"Invalid log level: {level}"
|
|
79
|
+
raise ValueError(err_msg)
|
|
80
|
+
_setup_logger(level)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
level = os.getenv("JETSONTOOLS_LOG_LEVEL")
|
|
84
|
+
_setup_logger(level)
|
|
85
|
+
_log = logging.getLogger(__name__)
|
|
86
|
+
if level is not None and level.upper() not in [
|
|
87
|
+
"DEBUG",
|
|
88
|
+
"INFO",
|
|
89
|
+
"WARNING",
|
|
90
|
+
"ERROR",
|
|
91
|
+
"CRITICAL",
|
|
92
|
+
]:
|
|
93
|
+
_log.warning(f"Invalid log level: {level}. Using default log level: WARNING")
|
|
94
|
+
|
|
95
|
+
from . import info
|
|
96
|
+
from ._tegrastats import Tegrastats
|
|
97
|
+
|
|
98
|
+
__all__ = [
|
|
99
|
+
"Tegrastats",
|
|
100
|
+
"info",
|
|
101
|
+
"set_log_level",
|
|
102
|
+
]
|
|
103
|
+
__version__ = "0.0.1"
|
|
104
|
+
|
|
105
|
+
_log.info(f"Initialized jetsontools with version {__version__}")
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# This file is part of the jetson_stats package (https://github.com/rbonghi/jetson_stats or http://rnext.it).
|
|
3
|
+
# Copyright (c) 2020 Raffaello Bonghi.
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU Affero General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Read CUDA version
|
|
20
|
+
if [ -f /usr/local/cuda/version.txt ]; then
|
|
21
|
+
JETSON_CUDA=$(cat /usr/local/cuda/version.txt | sed 's/\CUDA Version //g')
|
|
22
|
+
elif [ -f /usr/local/cuda/bin/nvcc ]; then
|
|
23
|
+
JETSON_CUDA=$(/usr/local/cuda/bin/nvcc --version | egrep -o "V[0-9]+.[0-9]+.[0-9]+" | cut -c2-)
|
|
24
|
+
else
|
|
25
|
+
JETSON_CUDA="NOT_INSTALLED"
|
|
26
|
+
fi
|
|
27
|
+
# Jetson CUDA version
|
|
28
|
+
export JETSON_CUDA
|
|
29
|
+
|
|
30
|
+
# Read from OpenCV if is installed CUDA
|
|
31
|
+
opencv_read_cuda()
|
|
32
|
+
{
|
|
33
|
+
# Red if use CUDA or not
|
|
34
|
+
local OPENCV_VERSION_VERBOSE=$(opencv_version --verbose | grep "Use Cuda" )
|
|
35
|
+
if [ ! -z "$OPENCV_VERSION_VERBOSE" ]; then
|
|
36
|
+
# Read status of CUDA
|
|
37
|
+
local OPENCV_CUDA_FLAG=$(echo $OPENCV_VERSION_VERBOSE | cut -f2 -d ':' | tr -s ' ' | cut -d' ' -f2 )
|
|
38
|
+
if [ "$OPENCV_CUDA_FLAG" == "NO" ]; then
|
|
39
|
+
# Set NO if cuda is not installed
|
|
40
|
+
echo "NO"
|
|
41
|
+
else
|
|
42
|
+
# Set YES if cuda is installed
|
|
43
|
+
echo "YES"
|
|
44
|
+
fi
|
|
45
|
+
return
|
|
46
|
+
fi
|
|
47
|
+
# read NVIDIA CUDA version
|
|
48
|
+
OPENCV_VERSION_VERBOSE=$(opencv_version --verbose | grep "NVIDIA CUDA" )
|
|
49
|
+
if [ ! -z "$OPENCV_VERSION_VERBOSE" ]; then
|
|
50
|
+
# get information
|
|
51
|
+
local OPENCV_CUDA_FLAG=$(echo $OPENCV_VERSION_VERBOSE | cut -f2 -d ':' | tr -s ' ' | cut -d' ' -f4 | cut -d',' -f1 )
|
|
52
|
+
OPENCV_CUDA_FLAG=${OPENCV_CUDA_FLAG//[[:blank:]]/}
|
|
53
|
+
# Set YES if cuda is installed
|
|
54
|
+
echo "YES"
|
|
55
|
+
return
|
|
56
|
+
fi
|
|
57
|
+
echo "NO"
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if hash opencv_version 2>/dev/null; then
|
|
62
|
+
JETSON_OPENCV="$(opencv_version)"
|
|
63
|
+
# Read information about cuda status
|
|
64
|
+
JETSON_OPENCV_CUDA=$(opencv_read_cuda)
|
|
65
|
+
else
|
|
66
|
+
JETSON_OPENCV="NOT_INSTALLED"
|
|
67
|
+
JETSON_OPENCV_CUDA="NO"
|
|
68
|
+
fi
|
|
69
|
+
# Opencv variables
|
|
70
|
+
export JETSON_OPENCV
|
|
71
|
+
export JETSON_OPENCV_CUDA
|
|
72
|
+
|
|
73
|
+
# Extract cuDNN version
|
|
74
|
+
JETSON_CUDNN=$(dpkg -l 2>/dev/null | grep -m1 "libcudnn")
|
|
75
|
+
if [ ! -z "$JETSON_CUDNN" ] ; then
|
|
76
|
+
JETSON_CUDNN=$(echo $JETSON_CUDNN | sed 's/.*libcudnn[0-9] \([^ ]*\).*/\1/' | cut -d '-' -f1 )
|
|
77
|
+
else
|
|
78
|
+
JETSON_CUDNN="NOT_INSTALLED"
|
|
79
|
+
fi
|
|
80
|
+
# Export NVIDIA CuDNN Library
|
|
81
|
+
export JETSON_CUDNN
|
|
82
|
+
|
|
83
|
+
# Extract TensorRT version
|
|
84
|
+
JETSON_TENSORRT=$(dpkg -l 2>/dev/null | grep -m1 " tensorrt ")
|
|
85
|
+
if [ ! -z "$JETSON_TENSORRT" ] ; then
|
|
86
|
+
JETSON_TENSORRT=$(echo $JETSON_TENSORRT | sed 's/.*tensorrt \([^ ]*\).*/\1/' | cut -d '-' -f1 )
|
|
87
|
+
else
|
|
88
|
+
JETSON_TENSORRT="NOT_INSTALLED"
|
|
89
|
+
fi
|
|
90
|
+
# Export NVIDIA CuDNN TensorRT
|
|
91
|
+
export JETSON_TENSORRT
|
|
92
|
+
|
|
93
|
+
# Extract Visionworks version
|
|
94
|
+
JETSON_VISIONWORKS=$(dpkg -l 2>/dev/null | grep -m1 "libvisionworks")
|
|
95
|
+
if [ ! -z "$JETSON_VISIONWORKS" ] ; then
|
|
96
|
+
JETSON_VISIONWORKS=$(echo $JETSON_VISIONWORKS | sed 's/.*libvisionworks \([^ ]*\).*/\1/' )
|
|
97
|
+
else
|
|
98
|
+
JETSON_VISIONWORKS="NOT_INSTALLED"
|
|
99
|
+
fi
|
|
100
|
+
# Export NVIDIA CuDNN VisionWorks
|
|
101
|
+
export JETSON_VISIONWORKS
|
|
102
|
+
|
|
103
|
+
# Extract VPI
|
|
104
|
+
JETSON_VPI=$(dpkg -l 2>/dev/null | grep -m1 "vpi")
|
|
105
|
+
if [ ! -z "$JETSON_VPI" ] ; then
|
|
106
|
+
JETSON_VPI=$(echo $JETSON_VPI | sed 's/.*vpi[0-9] \([^ ]*\).*/\1/' | cut -d '-' -f1 )
|
|
107
|
+
else
|
|
108
|
+
JETSON_VPI="NOT_INSTALLED"
|
|
109
|
+
fi
|
|
110
|
+
# Export VPI
|
|
111
|
+
export JETSON_VPI
|
|
112
|
+
|
|
113
|
+
# Vulkan
|
|
114
|
+
JETSON_VULKAN_INFO=$(which vulkaninfo)
|
|
115
|
+
if [ ! -z $JETSON_VULKAN_INFO ] ; then
|
|
116
|
+
JETSON_VULKAN_INFO=$($JETSON_VULKAN_INFO 2> /dev/null | grep -m1 "Vulkan Instance Version")
|
|
117
|
+
JETSON_VULKAN_INFO=$(echo $JETSON_VULKAN_INFO | sed 's/.*: \([^ ]*\).*/\1/' )
|
|
118
|
+
else
|
|
119
|
+
JETSON_VULKAN_INFO="NOT_INSTALLED"
|
|
120
|
+
fi
|
|
121
|
+
# Export VPI
|
|
122
|
+
export JETSON_VULKAN_INFO
|
|
123
|
+
#EOF
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# This file is part of the jetson_stats package (https://github.com/rbonghi/jetson_stats or http://rnext.it).
|
|
3
|
+
# Copyright (c) 2020 Raffaello Bonghi.
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU Affero General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# TODO Add enviroments variables:
|
|
20
|
+
# - UID -> https://devtalk.nvidia.com/default/topic/996988/jetson-tk1/chip-uid/post/5100481/#5100481
|
|
21
|
+
# - GCID, BOARD, EABI
|
|
22
|
+
|
|
23
|
+
###########################
|
|
24
|
+
#### JETPACK DETECTION ####
|
|
25
|
+
###########################
|
|
26
|
+
# Write version of jetpack installed
|
|
27
|
+
# https://developer.nvidia.com/embedded/jetpack-archive
|
|
28
|
+
jetson_jetpack()
|
|
29
|
+
{
|
|
30
|
+
local JETSON_L4T=$1
|
|
31
|
+
local JETSON_JETPACK=""
|
|
32
|
+
case $JETSON_L4T in
|
|
33
|
+
"35.1.0") JETSON_JETPACK="5.0.2" ;;
|
|
34
|
+
"34.1.1") JETSON_JETPACK="5.0.1 DP" ;;
|
|
35
|
+
"34.1.0") JETSON_JETPACK="5.0 DP" ;;
|
|
36
|
+
"32.7.3") JETSON_JETPACK="4.6.3" ;;
|
|
37
|
+
"32.7.2") JETSON_JETPACK="4.6.2" ;;
|
|
38
|
+
"32.7.1") JETSON_JETPACK="4.6.1" ;;
|
|
39
|
+
"32.6.1") JETSON_JETPACK="4.6" ;;
|
|
40
|
+
"32.5.1" | "32.5.2") JETSON_JETPACK="4.5.1" ;;
|
|
41
|
+
"32.5.0" | "32.5") JETSON_JETPACK="4.5" ;;
|
|
42
|
+
"32.4.4") JETSON_JETPACK="4.4.1" ;;
|
|
43
|
+
"32.4.3") JETSON_JETPACK="4.4" ;;
|
|
44
|
+
"32.4.2") JETSON_JETPACK="4.4 DP" ;;
|
|
45
|
+
"32.3.1") JETSON_JETPACK="4.3" ;;
|
|
46
|
+
"32.2.3") JETSON_JETPACK="4.2.3" ;;
|
|
47
|
+
"32.2.1") JETSON_JETPACK="4.2.2" ;;
|
|
48
|
+
"32.2.0" | "32.2") JETSON_JETPACK="4.2.1" ;;
|
|
49
|
+
"32.1.0" | "32.1") JETSON_JETPACK="4.2" ;;
|
|
50
|
+
"31.1.0" | "31.1") JETSON_JETPACK="4.1.1" ;;
|
|
51
|
+
"31.0.2") JETSON_JETPACK="4.1" ;;
|
|
52
|
+
"31.0.1") JETSON_JETPACK="4.0" ;;
|
|
53
|
+
"28.4.0") JETSON_JETPACK="3.3.3" ;;
|
|
54
|
+
"28.2.1") JETSON_JETPACK="3.3 | 3.2.1" ;;
|
|
55
|
+
"28.2.0" | "28.2") JETSON_JETPACK="3.2" ;;
|
|
56
|
+
"28.1.0" | "28.1") JETSON_JETPACK="3.1" ;;
|
|
57
|
+
"27.1.0" | "27.1") JETSON_JETPACK="3.0" ;;
|
|
58
|
+
"24.2.1") JETSON_JETPACK="3.0 | 2.3.1" ;;
|
|
59
|
+
"24.2.0" | "24.2") JETSON_JETPACK="2.3" ;;
|
|
60
|
+
"24.1.0" | "24.1") JETSON_JETPACK="2.2.1 | 2.2" ;;
|
|
61
|
+
"23.2.0" | "23.2") JETSON_JETPACK="2.1" ;;
|
|
62
|
+
"23.1.0" | "23.1") JETSON_JETPACK="2.0" ;;
|
|
63
|
+
"21.5.0" | "21.5") JETSON_JETPACK="2.3.1 | 2.3" ;;
|
|
64
|
+
"21.4.0" | "21.4") JETSON_JETPACK="2.2 | 2.1 | 2.0 | 1.2 DP" ;;
|
|
65
|
+
"21.3.0" | "21.3") JETSON_JETPACK="1.1 DP" ;;
|
|
66
|
+
"21.2.0" | "21.2") JETSON_JETPACK="1.0 DP" ;;
|
|
67
|
+
*) JETSON_JETPACK="UNKNOWN" ;;
|
|
68
|
+
esac
|
|
69
|
+
# return type jetpack
|
|
70
|
+
echo $JETSON_JETPACK
|
|
71
|
+
}
|
|
72
|
+
###########################
|
|
73
|
+
|
|
74
|
+
JETSON_MODEL="UNKNOWN"
|
|
75
|
+
# Extract jetson model name
|
|
76
|
+
if [ -f /sys/firmware/devicetree/base/model ]; then
|
|
77
|
+
JETSON_MODEL=$(tr -d '\0' < /sys/firmware/devicetree/base/model)
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
# Extract jetson chip id
|
|
81
|
+
JETSON_CHIP_ID=""
|
|
82
|
+
if [ -f /sys/module/tegra_fuse/parameters/tegra_chip_id ]; then
|
|
83
|
+
JETSON_CHIP_ID=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id)
|
|
84
|
+
fi
|
|
85
|
+
# Ectract type board
|
|
86
|
+
JETSON_SOC=""
|
|
87
|
+
if [ -f /proc/device-tree/compatible ]; then
|
|
88
|
+
# Extract the last part of name
|
|
89
|
+
JETSON_SOC=$(tr -d '\0' < /proc/device-tree/compatible | sed -e 's/.*,//')
|
|
90
|
+
fi
|
|
91
|
+
# Extract boardids if exists
|
|
92
|
+
JETSON_BOARDIDS=""
|
|
93
|
+
if [ -f /proc/device-tree/nvidia,boardids ]; then
|
|
94
|
+
JETSON_BOARDIDS=$(tr -d '\0' < /proc/device-tree/nvidia,boardids)
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
# Code name
|
|
98
|
+
JETSON_CODENAME=""
|
|
99
|
+
JETSON_MODULE="UNKNOWN"
|
|
100
|
+
JETSON_CARRIER="UNKNOWN"
|
|
101
|
+
list_hw_boards()
|
|
102
|
+
{
|
|
103
|
+
# Extract from DTS the name of the boards available
|
|
104
|
+
# Reference:
|
|
105
|
+
# 1. https://unix.stackexchange.com/questions/251013/bash-regex-capture-group
|
|
106
|
+
# 2. https://unix.stackexchange.com/questions/144298/delete-the-last-character-of-a-string-using-string-manipulation-in-shell-script
|
|
107
|
+
local s=$1
|
|
108
|
+
local regex='p([0-9-]+)' # Equivalent to p([\d-]*-)
|
|
109
|
+
while [[ $s =~ $regex ]]; do
|
|
110
|
+
local board_name=$(echo "P${BASH_REMATCH[1]}" | sed 's/-*$//' )
|
|
111
|
+
# Load jetson type
|
|
112
|
+
# If jetson type is not empty the module name is the same
|
|
113
|
+
if [ $JETSON_MODULE = "UNKNOWN" ] ; then
|
|
114
|
+
JETSON_MODULE=$board_name
|
|
115
|
+
echo "JETSON_MODULE=\"$JETSON_MODULE\""
|
|
116
|
+
else
|
|
117
|
+
JETSON_CARRIER=$board_name
|
|
118
|
+
echo "JETSON_CARRIER=\"$JETSON_CARRIER\""
|
|
119
|
+
fi
|
|
120
|
+
# Find next match
|
|
121
|
+
s=${s#*"${BASH_REMATCH[1]}"}
|
|
122
|
+
done
|
|
123
|
+
}
|
|
124
|
+
# Read DTS file
|
|
125
|
+
# 1. https://devtalk.nvidia.com/default/topic/1071080/jetson-nano/best-way-to-check-which-tegra-board/
|
|
126
|
+
# 2. https://devtalk.nvidia.com/default/topic/1014424/jetson-tx2/identifying-tx1-and-tx2-at-runtime/
|
|
127
|
+
# 3. https://devtalk.nvidia.com/default/topic/996988/jetson-tk1/chip-uid/post/5100481/#5100481
|
|
128
|
+
if [ -f /proc/device-tree/nvidia,dtsfilename ]; then
|
|
129
|
+
# ..<something>/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0000-p3449-0000-b00.dts
|
|
130
|
+
# The last third is the codename of the board
|
|
131
|
+
JETSON_CODENAME=$(tr -d '\0' < /proc/device-tree/nvidia,dtsfilename)
|
|
132
|
+
JETSON_CODENAME=$(echo ${JETSON_CODENAME#*"/hardware/nvidia/platform/"} | tr '/' '\n' | head -2 | tail -1 )
|
|
133
|
+
# The basename extract the board type
|
|
134
|
+
JETSON_DTS="$(tr -d '\0' < /proc/device-tree/nvidia,dtsfilename | sed 's/.*\///')"
|
|
135
|
+
# List of all boards
|
|
136
|
+
eval $(list_hw_boards "$JETSON_DTS")
|
|
137
|
+
fi
|
|
138
|
+
|
|
139
|
+
# Export variables
|
|
140
|
+
export JETSON_MODEL
|
|
141
|
+
export JETSON_CHIP_ID
|
|
142
|
+
export JETSON_SOC
|
|
143
|
+
export JETSON_BOARDIDS
|
|
144
|
+
export JETSON_CODENAME
|
|
145
|
+
export JETSON_MODULE
|
|
146
|
+
export JETSON_CARRIER
|
|
147
|
+
|
|
148
|
+
# Write CUDA architecture
|
|
149
|
+
# https://developer.nvidia.com/cuda-gpus
|
|
150
|
+
# https://devtalk.nvidia.com/default/topic/988317/jetson-tx1/what-should-be-the-value-of-cuda_arch_bin/
|
|
151
|
+
case $JETSON_MODEL in
|
|
152
|
+
*Orin*) JETSON_CUDA_ARCH_BIN="8.7" ;;
|
|
153
|
+
*Xavier*) JETSON_CUDA_ARCH_BIN="7.2" ;;
|
|
154
|
+
*TX2*) JETSON_CUDA_ARCH_BIN="6.2" ;;
|
|
155
|
+
*TX1* | *Nano*) JETSON_CUDA_ARCH_BIN="5.3" ;;
|
|
156
|
+
*TK1*) JETSON_CUDA_ARCH_BIN="3.2" ;;
|
|
157
|
+
* ) JETSON_CUDA_ARCH_BIN="NONE" ;;
|
|
158
|
+
esac
|
|
159
|
+
# Export Jetson CUDA ARCHITECTURE
|
|
160
|
+
export JETSON_CUDA_ARCH_BIN
|
|
161
|
+
|
|
162
|
+
# Serial number
|
|
163
|
+
# https://devtalk.nvidia.com/default/topic/1055507/jetson-nano/nano-serial-number-/
|
|
164
|
+
JETSON_SERIAL_NUMBER=""
|
|
165
|
+
if [ -f /sys/firmware/devicetree/base/serial-number ]; then
|
|
166
|
+
JETSON_SERIAL_NUMBER=$(tr -d '\0' </sys/firmware/devicetree/base/serial-number)
|
|
167
|
+
fi
|
|
168
|
+
# Export NVIDIA Serial Number
|
|
169
|
+
export JETSON_SERIAL_NUMBER
|
|
170
|
+
|
|
171
|
+
# NVIDIA Jetson version
|
|
172
|
+
# reference https://devtalk.nvidia.com/default/topic/860092/jetson-tk1/how-do-i-know-what-version-of-l4t-my-jetson-tk1-is-running-/
|
|
173
|
+
# https://stackoverflow.com/questions/16817646/extract-version-number-from-a-string
|
|
174
|
+
# https://askubuntu.com/questions/319307/reliably-check-if-a-package-is-installed-or-not
|
|
175
|
+
# https://github.com/dusty-nv/jetson-inference/blob/7e81381a96c1ac5f57f1728afbfdec7f1bfeffc2/tools/install-pytorch.sh#L296
|
|
176
|
+
if [ -f /etc/nv_tegra_release ]; then
|
|
177
|
+
# L4T string
|
|
178
|
+
# First line on /etc/nv_tegra_release
|
|
179
|
+
# - "# R28 (release), REVISION: 2.1, GCID: 11272647, BOARD: t186ref, EABI: aarch64, DATE: Thu May 17 07:29:06 UTC 2018"
|
|
180
|
+
JETSON_L4T_STRING=$(head -n 1 /etc/nv_tegra_release)
|
|
181
|
+
# Load release and revision
|
|
182
|
+
JETSON_L4T_RELEASE=$(echo $JETSON_L4T_STRING | cut -f 2 -d ' ' | grep -Po '(?<=R)[^;]+')
|
|
183
|
+
JETSON_L4T_REVISION=$(echo $JETSON_L4T_STRING | cut -f 2 -d ',' | grep -Po '(?<=REVISION: )[^;]+')
|
|
184
|
+
elif dpkg --get-selections | grep -q "^nvidia-l4t-core[[:space:]]*install$"; then
|
|
185
|
+
# Read version
|
|
186
|
+
JETSON_L4T_STRING=$(dpkg-query --showformat='${Version}' --show nvidia-l4t-core)
|
|
187
|
+
# extract version
|
|
188
|
+
JETSON_L4T_ARRAY=$(echo $JETSON_L4T_STRING | cut -f 1 -d '-')
|
|
189
|
+
# Load release and revision
|
|
190
|
+
JETSON_L4T_RELEASE=$(echo $JETSON_L4T_ARRAY | cut -f 1 -d '.')
|
|
191
|
+
JETSON_L4T_REVISION=${JETSON_L4T_ARRAY#"$JETSON_L4T_RELEASE."}
|
|
192
|
+
else
|
|
193
|
+
# Load release and revision
|
|
194
|
+
JETSON_L4T_RELEASE="N"
|
|
195
|
+
JETSON_L4T_REVISION="N.N"
|
|
196
|
+
fi
|
|
197
|
+
# Write Jetson description
|
|
198
|
+
JETSON_L4T="$JETSON_L4T_RELEASE.$JETSON_L4T_REVISION"
|
|
199
|
+
# Export Release L4T
|
|
200
|
+
export JETSON_L4T_RELEASE
|
|
201
|
+
export JETSON_L4T_REVISION
|
|
202
|
+
export JETSON_L4T
|
|
203
|
+
|
|
204
|
+
JETSON_JETPACK=$(jetson_jetpack $JETSON_L4T)
|
|
205
|
+
# Export Jetson Jetpack installed
|
|
206
|
+
export JETSON_JETPACK
|
|
207
|
+
# EOF
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Copyright (c) 2024 Justin Davis (davisjustin302@gmail.com)
|
|
2
|
+
#
|
|
3
|
+
# MIT License
|
|
4
|
+
# ruff: noqa: S404, S603
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
import multiprocessing as mp
|
|
9
|
+
import subprocess
|
|
10
|
+
import time
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import TYPE_CHECKING
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from types import TracebackType
|
|
16
|
+
|
|
17
|
+
from typing_extensions import Self
|
|
18
|
+
|
|
19
|
+
_log = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Tegrastats:
|
|
23
|
+
"""Runs tegrastats in a seperate process and stores output in a file."""
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self: Self,
|
|
27
|
+
output: Path | str,
|
|
28
|
+
interval: int = 1000,
|
|
29
|
+
*,
|
|
30
|
+
readall: bool | None = None,
|
|
31
|
+
) -> None:
|
|
32
|
+
"""
|
|
33
|
+
Create an instance of tegrastats with outputs to a file.
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
output : Path | str
|
|
38
|
+
The path to the output file
|
|
39
|
+
interval : int, optional
|
|
40
|
+
The interval to run tegrastats in milliseconds, by default 1000
|
|
41
|
+
readall : bool, optional
|
|
42
|
+
Optionally, read all possible information through tegrastats.
|
|
43
|
+
Additional information varies by board.
|
|
44
|
+
Can consume additional CPU resources.
|
|
45
|
+
By default, will NOT readall
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
self._output = Path(output)
|
|
49
|
+
self._interval = interval
|
|
50
|
+
self._readall = readall
|
|
51
|
+
|
|
52
|
+
self._process = mp.Process(
|
|
53
|
+
target=self._run,
|
|
54
|
+
args=(self._output, self._interval),
|
|
55
|
+
daemon=True,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def __enter__(self: Self) -> Self:
|
|
59
|
+
self._process.start()
|
|
60
|
+
return self
|
|
61
|
+
|
|
62
|
+
def __exit__(
|
|
63
|
+
self: Self,
|
|
64
|
+
exc_type: type[BaseException] | None,
|
|
65
|
+
exc_value: BaseException | None,
|
|
66
|
+
traceback: TracebackType | None,
|
|
67
|
+
) -> None:
|
|
68
|
+
_log.debug("Stopping tegrastats")
|
|
69
|
+
self._process.terminate()
|
|
70
|
+
command = ["tegrastats", "--stop"]
|
|
71
|
+
subprocess.run(
|
|
72
|
+
command,
|
|
73
|
+
check=True,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def _run(
|
|
77
|
+
self: Self,
|
|
78
|
+
output: Path,
|
|
79
|
+
interval: int,
|
|
80
|
+
) -> None:
|
|
81
|
+
"""
|
|
82
|
+
Target function for process running tegrastats.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
output : Path
|
|
87
|
+
The path to the output file.
|
|
88
|
+
interval : int
|
|
89
|
+
The interval to update tegrastats info (ms).
|
|
90
|
+
|
|
91
|
+
Raises
|
|
92
|
+
------
|
|
93
|
+
RuntimeError
|
|
94
|
+
If the process created by Popen does not have stdout/stderr
|
|
95
|
+
CalledProcessError
|
|
96
|
+
If the process has any stderr output
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
# maintain the file in open state
|
|
100
|
+
with output.open("w+") as f:
|
|
101
|
+
_log.debug(f"Open file {output} for writing")
|
|
102
|
+
|
|
103
|
+
# create the command and run the Popen call
|
|
104
|
+
command = ["tegrastats", "--interval", str(interval)]
|
|
105
|
+
if self._readall:
|
|
106
|
+
command.append("--readall")
|
|
107
|
+
process = subprocess.Popen(
|
|
108
|
+
command,
|
|
109
|
+
stdout=subprocess.PIPE,
|
|
110
|
+
stderr=subprocess.PIPE,
|
|
111
|
+
text=True,
|
|
112
|
+
bufsize=1,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
_log.debug(f"Ran tegrastats with command: {command}")
|
|
116
|
+
|
|
117
|
+
# ensure stdout/stderr streams exist
|
|
118
|
+
if process.stdout is None or process.stderr is None:
|
|
119
|
+
err_msg = "Cannot access stdout or stderr streams in Tegrastat process."
|
|
120
|
+
raise RuntimeError(err_msg)
|
|
121
|
+
|
|
122
|
+
_log.debug("No errors from process found")
|
|
123
|
+
|
|
124
|
+
# read output while it exists
|
|
125
|
+
# this will be stopped by the __exit__ call
|
|
126
|
+
# which will call tegrastats --stop
|
|
127
|
+
# resulting in the lines to cease
|
|
128
|
+
while True:
|
|
129
|
+
line = process.stdout.readline()
|
|
130
|
+
if not line:
|
|
131
|
+
break
|
|
132
|
+
timestamp = time.time()
|
|
133
|
+
f.write(f"{timestamp:.6f}:: {line}")
|
|
134
|
+
f.flush()
|
|
135
|
+
|
|
136
|
+
_log.debug("Stopped reading from tegrastats process")
|
|
137
|
+
|
|
138
|
+
# check for any errors
|
|
139
|
+
stderr_output = process.stderr.read()
|
|
140
|
+
if stderr_output:
|
|
141
|
+
raise subprocess.CalledProcessError(
|
|
142
|
+
process.returncode,
|
|
143
|
+
process.args,
|
|
144
|
+
stderr=stderr_output,
|
|
145
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright (c) 2024 Justin Davis (davisjustin302@gmail.com)
|
|
2
|
+
#
|
|
3
|
+
# MIT License
|
|
4
|
+
"""
|
|
5
|
+
Tools for getting information about the Jetson device.
|
|
6
|
+
|
|
7
|
+
Classes
|
|
8
|
+
-------
|
|
9
|
+
JetsonInfo
|
|
10
|
+
Class to store information about the Jetson device.
|
|
11
|
+
|
|
12
|
+
Functions
|
|
13
|
+
---------
|
|
14
|
+
get_info
|
|
15
|
+
Get information about the Jetson device.
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from ._info import JetsonInfo, get_info
|
|
22
|
+
|
|
23
|
+
__all__ = ["JetsonInfo", "get_info"]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copyright (c) 2024 Justin Davis (davisjustin302@gmail.com)
|
|
2
|
+
#
|
|
3
|
+
# MIT License
|
|
4
|
+
"""Print information about the Jetson device."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from ._info import get_info
|
|
9
|
+
|
|
10
|
+
if __name__ == "__main__":
|
|
11
|
+
_ = get_info(verbose=True)
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Copyright (c) 2024 Justin Davis (davisjustin302@gmail.com)
|
|
2
|
+
#
|
|
3
|
+
# MIT License
|
|
4
|
+
# Adapted from: https://github.com/jetsonhacks/jetsonUtilities/blob/master/jetsonInfo.py
|
|
5
|
+
# ruff: noqa: S404, S603, T201
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import subprocess
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from enum import Enum
|
|
11
|
+
from functools import lru_cache
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class _Terminalcolors(Enum):
|
|
16
|
+
"""Terminal colors for printing."""
|
|
17
|
+
|
|
18
|
+
WARNING = "\033[93m"
|
|
19
|
+
FAIL = "\033[91m"
|
|
20
|
+
ENDC = "\033[0m"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class JetsonInfo:
|
|
25
|
+
"""Class to store information about the Jetson device."""
|
|
26
|
+
|
|
27
|
+
model: str
|
|
28
|
+
l4t: str
|
|
29
|
+
jetpack: str
|
|
30
|
+
ubuntu: str | None
|
|
31
|
+
kernel: str | None
|
|
32
|
+
cuda: str
|
|
33
|
+
cuda_arch: str
|
|
34
|
+
opencv: str
|
|
35
|
+
opencv_cuda: str
|
|
36
|
+
cudnn: str
|
|
37
|
+
tensorrt: str
|
|
38
|
+
visionworks: str
|
|
39
|
+
vpi: str
|
|
40
|
+
vulkan: str
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@lru_cache(maxsize=None)
|
|
44
|
+
def get_info(*, verbose: bool | None = None) -> JetsonInfo:
|
|
45
|
+
"""
|
|
46
|
+
Get information about the Jetson device.
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
verbose : bool, optional
|
|
51
|
+
If True, print additional information, by default None
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
dict[str, str]
|
|
56
|
+
The information about the Jetson device.
|
|
57
|
+
|
|
58
|
+
Raises
|
|
59
|
+
------
|
|
60
|
+
RuntimeError
|
|
61
|
+
If the subprocess stdout streams cannot be opened.
|
|
62
|
+
|
|
63
|
+
"""
|
|
64
|
+
environment_vars: dict[str, str] = {}
|
|
65
|
+
output: dict[str, str] = {}
|
|
66
|
+
|
|
67
|
+
path0 = Path(__file__).parent.parent / "_scripts" / "jetson_variables.sh"
|
|
68
|
+
path0 = path0.resolve()
|
|
69
|
+
command0 = ["bash", "-c", f"source {path0} && env"]
|
|
70
|
+
|
|
71
|
+
proc = subprocess.Popen(command0, stdout=subprocess.PIPE)
|
|
72
|
+
if proc.stdout is None:
|
|
73
|
+
err_msg = f"Cannot open subprocess: {command0}"
|
|
74
|
+
raise RuntimeError(err_msg)
|
|
75
|
+
for c0_line in proc.stdout:
|
|
76
|
+
(key, _, value) = c0_line.partition(b"=")
|
|
77
|
+
environment_vars[key.decode()] = value.decode()
|
|
78
|
+
|
|
79
|
+
proc.communicate()
|
|
80
|
+
|
|
81
|
+
# Jetson Model
|
|
82
|
+
output["model"] = environment_vars["JETSON_MODEL"].strip()
|
|
83
|
+
if verbose:
|
|
84
|
+
print("NVIDIA " + output["model"])
|
|
85
|
+
|
|
86
|
+
# L4T Version
|
|
87
|
+
output["l4t"] = environment_vars["JETSON_L4T"].strip()
|
|
88
|
+
output["jetpack"] = environment_vars["JETSON_JETPACK"].strip()
|
|
89
|
+
if verbose:
|
|
90
|
+
print(
|
|
91
|
+
" L4T " + output["l4t"] + " [ JetPack " + output["jetpack"] + " ]",
|
|
92
|
+
)
|
|
93
|
+
# Ubuntu version
|
|
94
|
+
output["ubuntu"] = "UNKNOWN"
|
|
95
|
+
ubuntu_version_path = Path("/etc/os-release")
|
|
96
|
+
if ubuntu_version_path.exists():
|
|
97
|
+
with ubuntu_version_path.open("r") as ubuntu_version_file:
|
|
98
|
+
ubuntu_version_file_text = ubuntu_version_file.read()
|
|
99
|
+
for uvft_line in ubuntu_version_file_text.splitlines():
|
|
100
|
+
if "PRETTY_NAME" in uvft_line:
|
|
101
|
+
# PRETTY_NAME="Ubuntu 16.04 LTS"
|
|
102
|
+
ubuntu_release = uvft_line.split('"')[1]
|
|
103
|
+
output["ubuntu"] = ubuntu_release
|
|
104
|
+
if verbose:
|
|
105
|
+
print(" " + ubuntu_release)
|
|
106
|
+
else:
|
|
107
|
+
if verbose:
|
|
108
|
+
print(
|
|
109
|
+
_Terminalcolors.FAIL.value
|
|
110
|
+
+ "Error: Unable to find Ubuntu Version"
|
|
111
|
+
+ _Terminalcolors.ENDC.value,
|
|
112
|
+
)
|
|
113
|
+
print("Reason: Unable to find file /etc/os-release")
|
|
114
|
+
|
|
115
|
+
# Kernel Release
|
|
116
|
+
output["kernel"] = "UNKNOWN"
|
|
117
|
+
kernel_release_path = Path("/proc/version")
|
|
118
|
+
if kernel_release_path.exists():
|
|
119
|
+
with kernel_release_path.open("r") as version_file:
|
|
120
|
+
version_file_text = version_file.read()
|
|
121
|
+
kernel_release_array = version_file_text.split(" ")
|
|
122
|
+
output["kernel"] = kernel_release_array[2]
|
|
123
|
+
if verbose:
|
|
124
|
+
print(" Kernel Version: " + kernel_release_array[2])
|
|
125
|
+
else:
|
|
126
|
+
if verbose:
|
|
127
|
+
print(
|
|
128
|
+
_Terminalcolors.FAIL.value
|
|
129
|
+
+ "Error: Unable to find Linux kernel version"
|
|
130
|
+
+ _Terminalcolors.ENDC.value,
|
|
131
|
+
)
|
|
132
|
+
print("Reason: Unable to find file /proc/version")
|
|
133
|
+
|
|
134
|
+
path1 = Path(__file__).parent.parent / "_scripts" / "jetson_libraries.sh"
|
|
135
|
+
path1 = path1.resolve()
|
|
136
|
+
command1 = ["bash", "-c", f"source {path1} && env"]
|
|
137
|
+
|
|
138
|
+
proc1 = subprocess.Popen(command1, stdout=subprocess.PIPE)
|
|
139
|
+
if proc1.stdout is None:
|
|
140
|
+
err_msg = f"Cannot open subprocess: {command1}"
|
|
141
|
+
raise RuntimeError(err_msg)
|
|
142
|
+
for c1_line in proc1.stdout:
|
|
143
|
+
(key, _, value) = c1_line.partition(b"=")
|
|
144
|
+
environment_vars[key.decode()] = value.decode()
|
|
145
|
+
|
|
146
|
+
output["cuda"] = environment_vars["JETSON_CUDA"].strip()
|
|
147
|
+
output["cuda_arch"] = environment_vars["JETSON_CUDA_ARCH_BIN"].strip()
|
|
148
|
+
output["opencv"] = environment_vars["JETSON_OPENCV"].strip()
|
|
149
|
+
output["opencv_cuda"] = environment_vars["JETSON_OPENCV_CUDA"].strip()
|
|
150
|
+
output["cudnn"] = environment_vars["JETSON_CUDNN"].strip()
|
|
151
|
+
output["tensorrt"] = environment_vars["JETSON_TENSORRT"].strip()
|
|
152
|
+
output["visionworks"] = environment_vars["JETSON_VISIONWORKS"].strip()
|
|
153
|
+
output["vpi"] = environment_vars["JETSON_VPI"].strip()
|
|
154
|
+
output["vulkan"] = environment_vars["JETSON_VULKAN_INFO"].strip()
|
|
155
|
+
|
|
156
|
+
if verbose:
|
|
157
|
+
print(f" CUDA: {output['cuda']}")
|
|
158
|
+
print(f" \tCUDA Arch: {output['cuda_arch']}")
|
|
159
|
+
print(f" OpenCV: {output['opencv']}")
|
|
160
|
+
print(f" \tOpenCV CUDA: {output['opencv_cuda']}")
|
|
161
|
+
print(f" cuDNN: {output['cudnn']}")
|
|
162
|
+
print(f" TensorRT: {output['tensorrt']}")
|
|
163
|
+
print(f" Vision Works: {output['visionworks']}")
|
|
164
|
+
print(f" VPI: {output['vpi']}")
|
|
165
|
+
print(f" Vulcan: {output['vulkan']}")
|
|
166
|
+
|
|
167
|
+
return JetsonInfo(
|
|
168
|
+
model=output["model"],
|
|
169
|
+
l4t=output["l4t"],
|
|
170
|
+
jetpack=output["jetpack"],
|
|
171
|
+
ubuntu=output["ubuntu"],
|
|
172
|
+
kernel=output["kernel"],
|
|
173
|
+
cuda=output["cuda"],
|
|
174
|
+
cuda_arch=output["cuda_arch"],
|
|
175
|
+
opencv=output["opencv"],
|
|
176
|
+
opencv_cuda=output["opencv_cuda"],
|
|
177
|
+
cudnn=output["cudnn"],
|
|
178
|
+
tensorrt=output["tensorrt"],
|
|
179
|
+
visionworks=output["visionworks"],
|
|
180
|
+
vpi=output["vpi"],
|
|
181
|
+
vulkan=output["vulkan"],
|
|
182
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: jetsontools
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Tools for working with NVIDIA Jetson devices.
|
|
5
|
+
Author-email: Justin Davis <davisjustin302@gmail.com>
|
|
6
|
+
Maintainer-email: Justin Davis <davisjustin302@gmail.com>
|
|
7
|
+
Project-URL: Homepage, https://github.com/justincdavis/jetsontools
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/justincdavis/jetsontools/issues
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Natural Language :: English
|
|
21
|
+
Classifier: Intended Audience :: Developers
|
|
22
|
+
Classifier: Intended Audience :: Education
|
|
23
|
+
Classifier: Intended Audience :: Science/Research
|
|
24
|
+
Classifier: Intended Audience :: Education
|
|
25
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: <=3.13,>=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: typing_extensions>=4.0.0
|
|
31
|
+
Provides-Extra: ci
|
|
32
|
+
Requires-Dist: pyupgrade>=3.10; extra == "ci"
|
|
33
|
+
Requires-Dist: ruff>=0.4.5; extra == "ci"
|
|
34
|
+
Requires-Dist: mypy>=1.10.0; extra == "ci"
|
|
35
|
+
Requires-Dist: types-setuptools>=57.0.0; extra == "ci"
|
|
36
|
+
Requires-Dist: types-tqdm>=4.66.0; extra == "ci"
|
|
37
|
+
Provides-Extra: test
|
|
38
|
+
Requires-Dist: pytest>=6.2.0; extra == "test"
|
|
39
|
+
Requires-Dist: hypothesis[numpy]>=6.98.0; extra == "test"
|
|
40
|
+
Requires-Dist: pybboxes>=0.1.6; extra == "test"
|
|
41
|
+
Provides-Extra: docs
|
|
42
|
+
Requires-Dist: sphinx>=6.1.0; extra == "docs"
|
|
43
|
+
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
44
|
+
Requires-Dist: myst_parser>=1.0.0; extra == "docs"
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: jetsontools[jit]; extra == "dev"
|
|
47
|
+
Requires-Dist: jetsontools[ci]; extra == "dev"
|
|
48
|
+
Requires-Dist: jetsontools[test]; extra == "dev"
|
|
49
|
+
Requires-Dist: jetsontools[docs]; extra == "dev"
|
|
50
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
51
|
+
Requires-Dist: wheel>=0.37.0; extra == "dev"
|
|
52
|
+
Requires-Dist: bumpver>=2023.1126; extra == "dev"
|
|
53
|
+
Requires-Dist: pyclean>=2.7.0; extra == "dev"
|
|
54
|
+
Requires-Dist: pyright>=1.1.348; extra == "dev"
|
|
55
|
+
Requires-Dist: seaborn>=0.13.0; extra == "dev"
|
|
56
|
+
|
|
57
|
+
# jetsontools
|
|
58
|
+
Tools for working with NVIDIA Jetson devices.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
src/jetsontools/__init__.py
|
|
6
|
+
src/jetsontools/_tegrastats.py
|
|
7
|
+
src/jetsontools/py.typed
|
|
8
|
+
src/jetsontools.egg-info/PKG-INFO
|
|
9
|
+
src/jetsontools.egg-info/SOURCES.txt
|
|
10
|
+
src/jetsontools.egg-info/dependency_links.txt
|
|
11
|
+
src/jetsontools.egg-info/requires.txt
|
|
12
|
+
src/jetsontools.egg-info/top_level.txt
|
|
13
|
+
src/jetsontools/_scripts/jetson_libraries.sh
|
|
14
|
+
src/jetsontools/_scripts/jetson_variables.sh
|
|
15
|
+
src/jetsontools/info/__init__.py
|
|
16
|
+
src/jetsontools/info/__main__.py
|
|
17
|
+
src/jetsontools/info/_info.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
typing_extensions>=4.0.0
|
|
2
|
+
|
|
3
|
+
[ci]
|
|
4
|
+
pyupgrade>=3.10
|
|
5
|
+
ruff>=0.4.5
|
|
6
|
+
mypy>=1.10.0
|
|
7
|
+
types-setuptools>=57.0.0
|
|
8
|
+
types-tqdm>=4.66.0
|
|
9
|
+
|
|
10
|
+
[dev]
|
|
11
|
+
jetsontools[jit]
|
|
12
|
+
jetsontools[ci]
|
|
13
|
+
jetsontools[test]
|
|
14
|
+
jetsontools[docs]
|
|
15
|
+
twine>=4.0.0
|
|
16
|
+
wheel>=0.37.0
|
|
17
|
+
bumpver>=2023.1126
|
|
18
|
+
pyclean>=2.7.0
|
|
19
|
+
pyright>=1.1.348
|
|
20
|
+
seaborn>=0.13.0
|
|
21
|
+
|
|
22
|
+
[docs]
|
|
23
|
+
sphinx>=6.1.0
|
|
24
|
+
sphinx-rtd-theme>=1.3.0
|
|
25
|
+
myst_parser>=1.0.0
|
|
26
|
+
|
|
27
|
+
[test]
|
|
28
|
+
pytest>=6.2.0
|
|
29
|
+
hypothesis[numpy]>=6.98.0
|
|
30
|
+
pybboxes>=0.1.6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
jetsontools
|