reprospect.tools.ncu.session module

class reprospect.tools.ncu.session.Command(*, executable: str | Path, output: Path, opts: tuple[str, ...] = (), metrics: tuple[Metric | MetricCorrelation | MetricDeviceAttribute, ...] | None = None, nvtx_includes: tuple[str, ...] | None = None, args: tuple[str | Path, ...] | None = None, env: Mapping[str, str] | None = None)View on GitHub

Bases: object

Run a ncu command line.

__init__(*, executable: str | Path, output: Path, opts: tuple[str, ...] = (), metrics: tuple[Metric | MetricCorrelation | MetricDeviceAttribute, ...] | None = None, nvtx_includes: tuple[str, ...] | None = None, args: tuple[str | Path, ...] | None = None, env: Mapping[str, str] | None = None) None

Method generated by attrs for class Command.

args: tuple[str | Path, ...] | None

Arguments to pass to the executable.

cmd: tuple[str | Path, ...]
env: Mapping[str, str] | None

Mapping used to update the environment before running, see run().

executable: str | Path

Executable to run.

log: Path

Log file.

metrics: tuple[Metric | MetricCorrelation | MetricDeviceAttribute, ...] | None

Metrics.

nvtx_includes: tuple[str, ...] | None

NVTX include. Refer to https://docs.nvidia.com/nsight-compute/2023.3/NsightComputeCli/index.html#nvtx-filtering.

opts: tuple[str, ...]

Options that do not involve paths.

output: Path

Report file.

run(*, cwd: Path | None = None, env: MutableMapping[str, str] | None = None) intView on GitHub
class reprospect.tools.ncu.session.Session(command: Command)View on GitHub

Bases: object

Nsight Compute session interface.

__init__(command: Command) None
command: Command
run(cwd: ~pathlib.Path | None = None, env: ~typing.MutableMapping | None = None, retries: int = 1, sleep: ~typing.Callable[[int, int], float] = <function Session.<lambda>>) NoneView on GitHub

Run ncu using command.

Parameters:
  • retriesncu might fail acquiring some resources because other instances are running. Retry a few times. See https://docs.nvidia.com/nsight-compute/ProfilingGuide/index.html#faq (Profiling failed because a driver resource was unavailable).

  • sleep – The time to sleep between successive retries. The callable is given the current retry index (descending) and the amount of allowed retries.

Warning

According to https://developer.nvidia.com/nvidia-development-tools-solutions-err_nvgpuctrperm-permission-issue-performance-counters#ElevPrivsTag, GPU performance counters are not available to all users by default.

Note

As of ncu 2025.1.1.0, a note tells us that specified NVTX include expressions match only start/end ranges.

References: