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
CUDA: Don't make a runtime call on import #6147
Conversation
Calling `runtime.get_version()` on import initializes the CUDA driver, even though it creates no context. This is an issue for libraries that import Numba then set `CUDA_VISIBLE_DEVICES`, because the call at import time already initialized the driver and fixed the set of visible devices. This is an issue for, but not limited to, the Dask Local CUDA Cluster. This commit fixes this by deferring the call to `runtime.get_version()` until the list of supported CCs is actually needed.
FYI: This breaks more than just Dask, but Python multiprocessing in general as even spawning a process via multiprocessing will have it run imports from the parent process unless they're put under the |
For some extra info - prior to the commit in this PR:
With this PR / commit:
|
Test added - the test requires multiple GPUs. For me on a single-GPU system (one RTX 8000), I get:
With an 8-GPU system (V100s):
and with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @gmarkall !
Buildfarm ID: |
Testsuite is failing on the farm universally with:
|
This commit fixes the error: ``` [2020-08-20 06:00:35,606] INFO - FAIL: test_visible_devices_set_after_import (numba.cuda.tests.cudadrv.test_runtime.TestRuntime) [2020-08-20 06:00:35,606] INFO - ---------------------------------------------------------------------- [2020-08-20 06:00:35,606] INFO - Traceback (most recent call last): [2020-08-20 06:00:35,606] INFO - File "<path>\testenv_b522e3de-5976-43cf-ae68-63c7d7c1f2a3\lib\site-packages\numba\cuda\tests\cudadrv\test_runtime.py", line 51, in test_visible_devices_set_after_import [2020-08-20 06:00:35,606] INFO - p.start() [2020-08-20 06:00:35,606] INFO - File "<path>\envs\testenv_b522e3de-5976-43cf-ae68-63c7d7c1f2a3\lib\multiprocessing\process.py", line 118, in start [2020-08-20 06:00:35,606] INFO - assert not _current_process._config.get('daemon'), \ [2020-08-20 06:00:35,606] INFO - AssertionError: daemonic processes are not allowed to have children ``` by putting `test_visible_devices_set_after_import` in its own test class with a `SerialMixin`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!
Buildfarm ID: |
PR numba#6147 broke the test_cuda_submodules test because the test_nvvm_driver test could no longer be imported - the change from SUPPORTED_CC to get_supported_ccs in nvvm.py was not reflected in the CUDA simulator. This commit fixes the issue by changing SUPPORTED_CC to get_supported_ccs in the simulator.
CUDA: Don't make a runtime call on import
Calling
runtime.get_version()
on import initializes the CUDA driver, even though it creates no context. This is an issue for libraries that import Numba then setCUDA_VISIBLE_DEVICES
, because the call at import time already initialized the driver and fixed the set of visible devices. This is an issue for, but not limited to, the Dask Local CUDA Cluster.This PR fixes this by deferring the call to
runtime.get_version()
until the list of supported CCs is actually needed.cc @kkraus14 @pentschev @quasiben
Fixes #6149.