Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
6444e6b8
Commit
6444e6b8
authored
Apr 08, 2025
by
Tushar Sharma
Committed by
GitHub
Apr 08, 2025
Browse files
feat: Add dynamo env CLI option to provide information about user environment (#533)
parent
0eacef76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
0 deletions
+176
-0
deploy/dynamo/sdk/src/dynamo/sdk/cli/cli.py
deploy/dynamo/sdk/src/dynamo/sdk/cli/cli.py
+2
-0
deploy/dynamo/sdk/src/dynamo/sdk/cli/env.py
deploy/dynamo/sdk/src/dynamo/sdk/cli/env.py
+174
-0
No files found.
deploy/dynamo/sdk/src/dynamo/sdk/cli/cli.py
View file @
6444e6b8
...
@@ -31,6 +31,7 @@ def create_bentoml_cli() -> click.Command:
...
@@ -31,6 +31,7 @@ def create_bentoml_cli() -> click.Command:
from
bentoml_cli.utils
import
get_entry_points
from
bentoml_cli.utils
import
get_entry_points
from
dynamo.sdk.cli.deployment
import
deployment_command
from
dynamo.sdk.cli.deployment
import
deployment_command
from
dynamo.sdk.cli.env
import
env_command
# from dynamo.sdk.cli.deploy import deploy_command
# from dynamo.sdk.cli.deploy import deploy_command
from
dynamo.sdk.cli.run
import
run_command
from
dynamo.sdk.cli.run
import
run_command
...
@@ -64,6 +65,7 @@ def create_bentoml_cli() -> click.Command:
...
@@ -64,6 +65,7 @@ def create_bentoml_cli() -> click.Command:
# bentoml_cli.add_command(deploy_command)
# bentoml_cli.add_command(deploy_command)
# bentoml_cli.add_command(containerize_command)
# bentoml_cli.add_command(containerize_command)
bentoml_cli
.
add_command
(
deployment_command
)
bentoml_cli
.
add_command
(
deployment_command
)
bentoml_cli
.
add_command
(
env_command
)
# Load commands from extensions
# Load commands from extensions
for
ep
in
get_entry_points
(
"bentoml.commands"
):
for
ep
in
get_entry_points
(
"bentoml.commands"
):
...
...
deploy/dynamo/sdk/src/dynamo/sdk/cli/env.py
0 → 100644
View file @
6444e6b8
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# #
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
annotations
import
platform
import
subprocess
import
sys
import
click
import
distro
import
pkg_resources
def
get_os_version
()
->
str
:
"""Get OS version."""
# TODO: Revisit once we need to support Windows based systems
return
f
"
{
distro
.
name
()
}
{
distro
.
version
()
}
"
def
execute_subprocess_output
(
command
:
str
)
->
str
:
"""Execute a subprocess command and return the output."""
try
:
out
=
subprocess
.
check_output
(
command
,
shell
=
True
,
stderr
=
subprocess
.
DEVNULL
)
if
not
out
.
strip
():
return
"N/A"
return
out
.
decode
(
"utf-8"
).
strip
()
except
subprocess
.
CalledProcessError
:
return
"N/A"
def
get_glibc_version
()
->
str
:
"""Get GLIBC version."""
return
execute_subprocess_output
(
"ldd --version | head -n 1 | awk '{print $NF}'"
)
def
get_gcc_version
()
->
str
:
"""Get GCC version."""
return
execute_subprocess_output
(
"gcc --version | head -n 1 | awk '{print $NF}'"
)
def
get_cmake_version
()
->
str
:
"""Get Cmake version."""
return
execute_subprocess_output
(
"cmake --version | head -n 1 | awk '{print $NF}'"
)
def
get_rust_version
()
->
str
:
"""Get Rust version."""
return
execute_subprocess_output
(
"rustc --version | head -n 1 | awk '{print $(NF-2)}'"
)
def
get_docker_version
()
->
str
:
"""Get Docker version."""
return
execute_subprocess_output
(
"docker --version | awk '{print $3}' | tr -d ','"
)
def
get_cpu_architecture
()
->
str
:
"""Get CPU architecture."""
return
execute_subprocess_output
(
"lscpu"
)
def
query_nvidia_smi
(
param
:
str
)
->
str
:
"""Get GPU information from nvidia-smi if available"""
return
execute_subprocess_output
(
f
"nvidia-smi --query-gpu=
{
param
}
--format=csv,noheader"
)
def
get_gpu_topo
()
->
str
:
"""Get GPU topology if available"""
return
execute_subprocess_output
(
"nvidia-smi topo -m"
)
def
get_cuda_version
()
->
str
:
"""Get CUDA version if available."""
return
execute_subprocess_output
(
r
"nvcc --version | grep -Po 'release \K\d+\.\d+'"
)
def
get_python_platform
():
return
platform
.
platform
()
def
get_installed_packages
()
->
list
[
tuple
[
str
,
str
]]:
"""Get list of installed Python packages and their versions."""
return
[(
pkg
.
key
,
pkg
.
version
)
for
pkg
in
pkg_resources
.
working_set
]
def
get_python_packages
()
->
str
:
"""Get list of specified Python packages and their versions."""
installed_packages
=
get_installed_packages
()
out
=
[]
search_python_packages
=
[
"ai-dynamo"
,
"ai-dynamo-runtime"
,
"ai-dynamo-vllm"
,
"genai-perf"
,
"nixl"
,
"numpy"
,
"nvidia-cublas-cu12"
,
"nvidia-cuda-cupti-cu12"
,
"nvidia-cuda-nvrtc-cu12"
,
"nvidia-cuda-runtime-cu12"
,
"nvidia-cudnn-cu12"
,
"nvidia-cufft-cu12"
,
"nvidia-curand-cu12"
,
"nvidia-cusolver-cu12"
,
"nvidia-cusparse-cu12"
,
"nvidia-ml-py"
,
"nvidia-nccl-cu12"
,
"nvidia-nvjitlink-cu12"
,
"nvidia-nvtx-cu12"
,
"pyzmq"
,
"tensorrt_llm"
,
"torch"
,
"torchaudio"
,
"transformers"
,
"tritonclient"
,
]
for
pkg_name
in
search_python_packages
:
version
=
next
(
(
version
for
name
,
version
in
installed_packages
if
name
==
pkg_name
),
None
)
if
version
:
out
.
append
(
f
"
{
pkg_name
}
:
{
version
}
"
)
else
:
out
.
append
(
f
"
{
pkg_name
}
: Not installed"
)
return
"
\n
"
.
join
(
out
)
def
build_env_command
()
->
click
.
Command
:
@
click
.
command
(
name
=
"env"
)
def
env
()
->
None
:
"""Display information about the current environment."""
click
.
echo
(
"System Information:"
)
click
.
echo
(
f
"OS:
{
get_os_version
()
}
"
)
click
.
echo
(
f
"Glibc Version:
{
get_glibc_version
()
}
"
)
click
.
echo
(
f
"GCC Version:
{
get_gcc_version
()
}
"
)
click
.
echo
(
f
"Cmake Version:
{
get_cmake_version
()
}
"
)
click
.
echo
(
f
"Rust Version:
{
get_rust_version
()
}
"
)
click
.
echo
(
f
"Docker Version:
{
get_docker_version
()
}
"
)
click
.
echo
(
"
\n
CPU Information:"
)
click
.
echo
(
f
"
{
get_cpu_architecture
()
}
"
)
click
.
echo
(
"
\n
GPU Information:"
)
click
.
echo
(
f
"Models and configurations:
{
query_nvidia_smi
(
'gpu_name'
)
}
"
)
click
.
echo
(
f
"Driver Version:
{
query_nvidia_smi
(
'driver_version'
)
}
"
)
click
.
echo
(
f
"CUDA Runtime Version:
{
get_cuda_version
()
}
"
)
click
.
echo
(
f
"Topology:
{
get_gpu_topo
()
}
"
)
# Get Python version
py_version
=
sys
.
version
.
split
()[
0
]
click
.
echo
(
f
"
\n
Python Version:
{
py_version
}
"
)
click
.
echo
(
f
"Python Platform:
{
get_python_platform
()
}
"
)
click
.
echo
(
"
\n
Python Packages:"
)
click
.
echo
(
f
"
{
get_python_packages
()
}
"
)
return
env
env_command
=
build_env_command
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment