File: nsys_constants.py

package info (click to toggle)
nvidia-cuda-toolkit 12.4.1-3
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 18,505,836 kB
  • sloc: ansic: 203,477; cpp: 64,769; python: 34,699; javascript: 22,006; xml: 13,410; makefile: 3,085; sh: 2,343; perl: 352
file content (72 lines) | stat: -rw-r--r-- 2,679 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
#
# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from NVIDIA CORPORATION or
# its affiliates is strictly prohibited.

import os
import platform
import subprocess


def get_arm_target_dir():
    # TODO(DTSP-15164): Correct platform detection for containers on Jetson.
    tegra_check = subprocess.run(
        "find /proc/device-tree/ -maxdepth 1 -name 'tegra*'",
        shell=True,
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )
    desktop_check = subprocess.run(
        "lsmod | grep 'nvidia'",
        shell=True,
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )

    if tegra_check.returncode == 0:
        return "target-linux-tegra-armv8"
    elif desktop_check.returncode == 0:
        return "target-linux-sbsa-armv8"
    return None


NSYS_TARGET_DIR = None
if platform.system() == "Windows":
    NSYS_EXE_NAME = "nsys.exe"
    NSYS_HOST_DIR = "host-windows-x64"
    NSYS_TARGET_DIR = "target-windows-x64"
    NSYS_SQLITE_LIB = "sqlite3.dll"
elif platform.system() == "Linux":
    NSYS_EXE_NAME = "nsys"
    NSYS_SQLITE_LIB = "libsqlite3.so.0"
    if platform.machine() == "x86_64":
        NSYS_HOST_DIR = "host-linux-x64"
        NSYS_TARGET_DIR = "target-linux-x64"
    elif platform.machine() == "aarch64":
        NSYS_HOST_DIR = "host-linux-armv8"
        NSYS_TARGET_DIR = get_arm_target_dir()

if NSYS_TARGET_DIR is None:
    raise RuntimeError("Current platform is not supported.")

NSYS_RULE_DIR = "rules"
NSYS_REPORT_DIR = "reports"
NSYS_PYTHON_DIR = "python"

NSYS_PYTHON_LIB_DIR = os.path.join(NSYS_PYTHON_DIR, "lib")
NSYS_PYTHON_PKG_DIR = os.path.join(NSYS_PYTHON_DIR, "packages")

NSYS_RECIPE_PATH = os.path.abspath(os.path.dirname(__file__))
NSYS_RECIPE_INSTALL_PATH = os.path.join(NSYS_RECIPE_PATH, "install.py")
NSYS_RECIPE_REQ_PATH = os.path.join(NSYS_RECIPE_PATH, "requirements")
NSYS_RECIPE_THIRDPARTY_PATH = os.path.join(NSYS_RECIPE_PATH, "third_party")
NSYS_RECIPE_RECIPES_PATH = os.path.join(NSYS_RECIPE_PATH, "recipes")

NSYS_RECIPE_REQ_COMMON_PATH = os.path.join(NSYS_RECIPE_REQ_PATH, "common.txt")
NSYS_RECIPE_REQ_DASK_PATH = os.path.join(NSYS_RECIPE_REQ_PATH, "dask.txt")
NSYS_RECIPE_REQ_JUPYTER_PATH = os.path.join(NSYS_RECIPE_REQ_PATH, "jupyter.txt")