File: ncu-ui

package info (click to toggle)
nvidia-cuda-toolkit 11.8.0-5~deb12u1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm
  • size: 18,338,396 kB
  • sloc: ansic: 172,472; cpp: 57,058; javascript: 21,597; python: 12,656; xml: 12,438; makefile: 2,949; sh: 2,056; perl: 352
file content (71 lines) | stat: -rwxr-xr-x 2,984 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
# 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 "."
    IFS=. read -r  year major_version minor_version  <<< "$1"

    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

    LIST_NSIGHT_COMPUTE_TOOL_DIRS=$(ls "/opt/nvidia/nsight-compute")

    while read -r nsight_compute_dir; do
        setLatestNsightComputeToolDir "$nsight_compute_dir" "/opt/nvidia/nsight-compute/$nsight_compute_dir"
    done <<< "$LIST_NSIGHT_COMPUTE_TOOL_DIRS"
fi

# If installed with .run file, nsight-compute tools will be under nsight-compute-<version> folder. e.g nsight-compute-2019.4.0
NSIGHT_COMPUTE_TOOL_DIRS=$(find "$CUDA_TOOLKIT_BIN_DIR"/.. -maxdepth 1 -name "nsight-compute-*")

while read -r nsight_compute_tool_dir_path; do
    # 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 <<< "$NSIGHT_COMPUTE_TOOL_DIRS"

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

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

exec "$NSIGHT_COMPUTE_UI" "$@"