Skip to content

Commit

Permalink
better wrapper script, backport of 39ddf33
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Mar 9, 2024
1 parent 4199ab7 commit 2fb0e13
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ def add_service_exe(script, icon, base_name):
if nvfbc_ENABLED:
add_console_exe("xpra/codecs/nvidia/nvfbc/capture.py", "nvidia.ico", "NvFBC_capture")
if nvfbc_ENABLED or nvenc_ENABLED or nvdec_ENABLED or nvjpeg_encoder_ENABLED or nvjpeg_decoder_ENABLED:
add_console_exe("xpra/codecs/nvidia/cuda_context.py", "cuda.ico", "CUDA_info")
add_console_exe("xpra/codecs/nvidia/info.py", "cuda.ico", "CUDA_info")

if ("install_exe" in sys.argv) or ("install" in sys.argv):
#FIXME: how do we figure out what target directory to use?
Expand Down
54 changes: 54 additions & 0 deletions xpra/codecs/nvidia/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
# This file is part of Xpra.
# Copyright (C) 2024 Antoine Martin <antoine@xpra.org>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import sys
from importlib import import_module


def main(argv) -> int:
# pylint: disable=import-outside-toplevel
from xpra.util import print_nested_dict, numpy_import_lock
from xpra.platform import program_context
with program_context("CUDA-Info", "CUDA Info"):
from xpra.log import Logger, enable_color
enable_color()
log = Logger("cuda")
if "-v" in argv or "--verbose" in argv:
log.enable_debug()
with numpy_import_lock:
for component in (
"xpra.codecs",
"xpra.codecs.nvidia",
"pycuda",
"pycuda.driver",
"xpra.codecs.nvidia.cuda.context",
):
try:
module = import_module(component)
except ImportError as e:
log.error(f"Error: the `{component}` component failed to load")
log.estr(e)
if component == "pycuda.driver":
log.error(" this usually happens if the CUDA library is not installed or not found")
return 1
else:
log.debug(f"loaded {component}={module}")
from xpra.codecs.nvidia import cuda_context
pycuda_info = cuda_context.get_pycuda_info()
log.info("pycuda_info")
print_nested_dict(pycuda_info, print_fn=log.info)
log.info("cuda_info")
print_nested_dict(cuda_context.get_cuda_info(), print_fn=log.info)
log.info("preferences:")
print_nested_dict(cuda_context.get_prefs(), print_fn=log.info)
log.info("device automatically selected:")
log.info(" %s", cuda_context.device_info(cuda_context.select_device()[1]))
return 0


if __name__ == "__main__":
v = main(sys.argv)
sys.exit(v)

0 comments on commit 2fb0e13

Please sign in to comment.