File: ncu-ui

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 (84 lines) | stat: -rwxr-xr-x 3,616 bytes parent folder | download | duplicates (4)
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
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
# Considering this script will be in cuda toolkit bin directory.
CUDA_TOOLKIT_BIN_DIR="$(dirname "$(readlink -f -- "$0")")"

setLatestNsightComputeToolDir()
{
    # Split version information <year>.<major_version>.<minor version> by "."
    year=$(echo "$1" | cut -d'.' -f1)
    major_version=$(echo "$1" | cut -d'.' -f2)
    minor_version=$(echo "$1" | cut -d'.' -f3)

    version_value=$(( year * 10000 + major_version * 100 + minor_version ))

    if [ "$version_value" -ge "$latest_version" ]; then
        latest_version=$version_value
        LATEST_NSIGHT_COMPUTE_TOOL_DIR=$2
    fi
}

# Pick latest Nsight Compute version if user has more than one nsight-compute-<year>.<major_version>.<minor version> or nsight-compute/<version> folder.
latest_version=0
# If installed with .deb or .rpm pkg, nsight-compute tools will be under nsight-compute/<tool_version folder> folder. e.g nsight-compute/2019.4.0
if [ -d "/opt/nvidia/nsight-compute" ]; then
    for nsight_compute_dir in /opt/nvidia/nsight-compute/*; do
        if [ ! -e "$nsight_compute_dir" ]; then
            # Glob didn't match anything. Let's skip this single iteration.
            continue
        fi
        setLatestNsightComputeToolDir "$(basename "$nsight_compute_dir")" "$nsight_compute_dir"
    done
fi

# If installed with .run file, nsight-compute tools will be under nsight-compute-<version> folder. e.g nsight-compute-2019.4.0
for nsight_compute_tool_dir_path in "$CUDA_TOOLKIT_BIN_DIR"/../nsight-compute-*; do
    if [ ! -e "$nsight_compute_tool_dir_path" ]; then
        # Glob didn't match anything. Let's skip this single iteration.
        continue
    fi
    # Split nsight compute tool dir path by "/" to get nsight compute folder name.
    nsight_compute_tool_dir_name=${nsight_compute_tool_dir_path##*/}
    # Split nsight compute tool dir name nsight-compute-<year>.<major_version>.<minor version> by "-" to get version information.
    nsight_compute_tool_version=${nsight_compute_tool_dir_name##*-}

    setLatestNsightComputeToolDir "$nsight_compute_tool_version" "$nsight_compute_tool_dir_path"
done

if [ -z "$LATEST_NSIGHT_COMPUTE_TOOL_DIR" ]; then
    echo "ERROR : nsight-compute directory is not found under $CUDA_TOOLKIT_BIN_DIR/../ or /opt/nvidia. Nsight Compute is not installed on your system." 1>&2
    exit 1
fi

# find all available hosts
NSIGHT_COMPUTE_HOSTS=$(find "$LATEST_NSIGHT_COMPUTE_TOOL_DIR/host" -maxdepth 1 -name "linux-*")
NSIGHT_COMPUTE_NUM_HOSTS=$(echo "$NSIGHT_COMPUTE_HOSTS" | wc -l)

# if there is only one, use that, otherwise make the selection dynamically
if [ "$NSIGHT_COMPUTE_NUM_HOSTS" = 1 ]; then
    NSIGHT_COMPUTE_UI="$NSIGHT_COMPUTE_HOSTS/ncu-ui"
else
    LINUX_DESKTOP_NSIGHT_COMPUTE_UI="$LATEST_NSIGHT_COMPUTE_TOOL_DIR/host/linux-desktop-glibc_2_11_3-x64/ncu-ui"
    LINUX_ARMSERVER_NSIGHT_COMPUTE_UI="$LATEST_NSIGHT_COMPUTE_TOOL_DIR/host/linux-desktop-t210-a64/ncu-ui"
    LINUX_L4T_NSIGHT_COMPUTE_UI="$LATEST_NSIGHT_COMPUTE_TOOL_DIR/host/linux-v4l_l4t-t210-a64/ncu-ui"

    ARCH=$(uname -m)

    if [ "$ARCH" = "x86_64" ]; then
        NSIGHT_COMPUTE_UI="$LINUX_DESKTOP_NSIGHT_COMPUTE_UI"
    elif [ "$ARCH" = "aarch64" ]; then
        case "$(uname -r)" in
            *tegra*) NSIGHT_COMPUTE_UI="$LINUX_L4T_NSIGHT_COMPUTE_UI" ;;
            *) NSIGHT_COMPUTE_UI="$LINUX_ARMSERVER_NSIGHT_COMPUTE_UI" ;;
        esac
    else
        echo "ERROR : Unsupported Architecture: $ARCH" 1>&2
        exit 1
    fi

    if [ ! -x "$NSIGHT_COMPUTE_UI" ]; then
        echo "ERROR : $NSIGHT_COMPUTE_UI not found." 1>&2
        exit 1
    fi
fi

exec "$NSIGHT_COMPUTE_UI" "$@"