Skip to content

Add configuration to enable/disable NVML diagnostics #4893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions distributed/diagnostics/nvml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

import dask

try:
import pynvml
except ImportError:
Expand All @@ -12,6 +14,11 @@

def init_once():
global nvmlInitialized, nvmlLibraryNotFound, nvmlOwnerPID

if dask.config.get("distributed.diagnostics.nvml") is False:
nvmlInitialized = False
return

if pynvml is None or (nvmlInitialized is True and nvmlOwnerPID == os.getpid()):
return

Expand Down
19 changes: 19 additions & 0 deletions distributed/diagnostics/tests/test_nvml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

pynvml = pytest.importorskip("pynvml")

import dask

from distributed.diagnostics import nvml
from distributed.utils_test import gen_cluster

Expand All @@ -19,6 +21,23 @@ def test_one_time():
assert len(output["name"]) > 0


def test_enable_disable_nvml():
try:
pynvml.nvmlShutdown()
except pynvml.NVMLError_Uninitialized:
pass
else:
nvml.nvmlInitialized = False

with dask.config.set({"distributed.diagnostics.nvml": False}):
nvml.init_once()
assert nvml.nvmlInitialized is False

with dask.config.set({"distributed.diagnostics.nvml": True}):
nvml.init_once()
assert nvml.nvmlInitialized is True


def test_1_visible_devices():
if nvml.device_get_count() < 1:
pytest.skip("No GPUs available")
Expand Down
11 changes: 11 additions & 0 deletions distributed/distributed-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,17 @@ properties:
Alternatively, the key can be appended to the cert file
above, and this field left blank

diagnostics:
type: object
properties:
nvml:
type: boolean
description: |
If ``True``, enables GPU diagnostics with NVML. Generally leaving it enabled is
not a problem and will be automatically disabled if no GPUs are found in the
system, but in certain cases it may be desirable to completely disable NVML
diagnostics.

dashboard:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions distributed/distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ distributed:
key: null
cert: null

diagnostics:
nvml: True
Comment on lines +198 to +199
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is GPU specific, we might want to put this option in it's own section like rmm and ucx

rmm:
pool-size: null
ucx:
cuda_copy: False # enable cuda-copy
tcp: False # enable tcp
nvlink: False # enable cuda_ipc
infiniband: False # enable Infiniband
rdmacm: False # enable RDMACM
net-devices: null # define what interface to use for UCX comm
reuse-endpoints: null # enable endpoint reuse

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind moving it there if you prefer, but it seems like the general feel about those is that they have been a mistake to be outside of the distributed schema. For example #4904 is attempting to move ucx into distributed to comply with the general config schema.


###################
# Bokeh dashboard #
Expand Down