Skip to content

Commit

Permalink
fix(select): fix CUDA device selection tool nvisel
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Jan 9, 2025
1 parent 8bef345 commit aa9148d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

-
- Fix CUDA device selection tool `nvisel` by [@XuehaiPan](https://github.com/XuehaiPan).

### Removed

Expand Down
4 changes: 1 addition & 3 deletions nvitop/api/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,18 +458,16 @@ class GpuProcess: # pylint: disable=too-many-instance-attributes,too-many-publi
_ident: tuple
_hash: int | None

# pylint: disable-next=too-many-arguments
# pylint: disable-next=too-many-arguments,unused-argument
def __new__(
cls,
pid: int | None,
device: Device,
*,
# pylint: disable=unused-argument
gpu_memory: int | NaType | None = None,
gpu_instance_id: int | NaType | None = None,
compute_instance_id: int | NaType | None = None,
type: str | NaType | None = None, # pylint: disable=redefined-builtin
# pylint: enable=unused-argument
) -> Self:
"""Return the cached instance of :class:`GpuProcess`."""
if pid is None:
Expand Down
16 changes: 14 additions & 2 deletions nvitop/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def select_devices( # pylint: disable=too-many-arguments
) -> list[Device]: ...


# pylint: disable-next=too-many-branches,too-many-statements,too-many-locals,unused-argument,too-many-arguments
# pylint: disable-next=too-many-branches,too-many-statements,too-many-locals,too-many-arguments
def select_devices(
devices: Iterable[Device] | None = None,
*,
Expand Down Expand Up @@ -562,7 +562,19 @@ def main() -> int:
)
return 3

identifiers = select_devices(devices, **vars(args))
identifiers = select_devices( # type: ignore[call-overload]
devices,
format=args.format,
min_count=args.min_count,
max_count=args.max_count,
min_free_memory=args.min_free_memory,
min_total_memory=args.min_total_memory,
max_gpu_utilization=args.max_gpu_utilization,
max_memory_utilization=args.max_memory_utilization,
tolerance=args.tolerance,
free_accounts=args.free_accounts,
sort=args.sort,
)
identifiers = list(map(str, identifiers))
result = args.sep.join(identifiers)

Expand Down

0 comments on commit aa9148d

Please sign in to comment.