-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Timeouts in CI were happening due to CUDA context creation happening in some dask estimator docstrings, this PR fixes that by avoiding that context creation. Also fixes a typo in the coordinate descent solver that caused the intercept to be calculated wrong in some cases Authors: - Dante Gama Dessavre (https://github.com/dantegd) Approvers: - Simon Adorf (https://github.com/csadorf) URL: #5598
- Loading branch information
Showing
4 changed files
with
124 additions
and
3 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
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,109 @@ | ||
# Copyright (c) 2023, NVIDIA CORPORATION. | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
from shutil import which | ||
|
||
import pytest | ||
|
||
GDB_COMMANDS = """ | ||
set confirm off | ||
set breakpoint pending on | ||
break cuInit | ||
run | ||
exit | ||
""" | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def cuda_gdb(request): | ||
gdb = which("cuda-gdb") | ||
if gdb is None: | ||
request.applymarker( | ||
pytest.mark.xfail(reason="No cuda-gdb found, can't detect cuInit"), | ||
) | ||
return gdb | ||
else: | ||
output = subprocess.run( | ||
[gdb, "--version"], capture_output=True, text=True | ||
) | ||
if output.returncode != 0: | ||
request.applymarker( | ||
pytest.mark.xfail( | ||
reason=( | ||
"cuda-gdb not working on this platform, " | ||
f"can't detect cuInit: {output.stderr}" | ||
) | ||
), | ||
) | ||
return gdb | ||
|
||
|
||
def test_cuml_import_no_cuinit(cuda_gdb): | ||
# When RAPIDS_NO_INITIALIZE is set, importing cuml should _not_ | ||
# create a CUDA context (i.e. cuInit should not be called). | ||
# Intercepting the call to cuInit programmatically is tricky since | ||
# the way it is resolved from dynamic libraries by | ||
# cuda-python/numba/cupy is multitudinous (see discussion at | ||
# https://github.com/rapidsai/cuml/pull/12361 which does this, but | ||
# needs provide hooks that override dlsym, cuGetProcAddress, and | ||
# cuInit. | ||
# Instead, we just run under GDB and see if we hit a breakpoint | ||
env = os.environ.copy() | ||
env["RAPIDS_NO_INITIALIZE"] = "1" | ||
output = subprocess.run( | ||
[ | ||
cuda_gdb, | ||
"-x", | ||
"-", | ||
"--args", | ||
sys.executable, | ||
"-c", | ||
"import cuml", | ||
], | ||
input=GDB_COMMANDS, | ||
env=env, | ||
capture_output=True, | ||
text=True, | ||
) | ||
|
||
cuInit_called = output.stdout.find("in cuInit ()") | ||
print("Command output:\n") | ||
print("*** STDOUT ***") | ||
print(output.stdout) | ||
print("*** STDERR ***") | ||
print(output.stderr) | ||
assert output.returncode == 0 | ||
assert cuInit_called < 0 | ||
|
||
|
||
def test_cuml_create_estimator_cuinit(cuda_gdb): | ||
# This tests that our gdb scripting correctly identifies cuInit | ||
# when it definitely should have been called. | ||
env = os.environ.copy() | ||
env["RAPIDS_NO_INITIALIZE"] = "1" | ||
output = subprocess.run( | ||
[ | ||
cuda_gdb, | ||
"-x", | ||
"-", | ||
"--args", | ||
sys.executable, | ||
"-c", | ||
"import cupy as cp; a = cp.ones(10)", | ||
], | ||
input=GDB_COMMANDS, | ||
env=env, | ||
capture_output=True, | ||
text=True, | ||
) | ||
|
||
cuInit_called = output.stdout.find("in cuInit ()") | ||
print("Command output:\n") | ||
print("*** STDOUT ***") | ||
print(output.stdout) | ||
print("*** STDERR ***") | ||
print(output.stderr) | ||
assert output.returncode == 0 | ||
assert cuInit_called >= 0 |