-
Notifications
You must be signed in to change notification settings - Fork 532
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
Fixes for timeouts in tests #5598
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4da5a94
FIX context creation at import time
dantegd 884fd9c
FIX style fixes
dantegd edc0b62
FIX Update function name and description based on PR review
dantegd 2bcbf74
FIX style fixes
dantegd 603a838
FIX cd fix and temporarly skip flaky test
dantegd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unrelated fix?
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.
yeah, it just seemed way to small of a change to warrant a full PR with CI run