-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move test utils to
dask_cuda.utils_test
module
- Loading branch information
Showing
2 changed files
with
24 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import distributed | ||
from distributed import Worker | ||
|
||
|
||
class MockWorker(Worker): | ||
"""Mock Worker class preventing NVML from getting used by SystemMonitor. | ||
By preventing the Worker from initializing NVML in the SystemMonitor, we can | ||
mock test multiple devices in `CUDA_VISIBLE_DEVICES` behavior with single-GPU | ||
machines. | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
distributed.diagnostics.nvml.device_get_count = MockWorker.device_get_count | ||
self._device_get_count = distributed.diagnostics.nvml.device_get_count | ||
super().__init__(*args, **kwargs) | ||
|
||
def __del__(self): | ||
distributed.diagnostics.nvml.device_get_count = self._device_get_count | ||
|
||
@staticmethod | ||
def device_get_count(): | ||
return 0 |