-
Notifications
You must be signed in to change notification settings - Fork 919
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
Improve the capture of fatal cuda error #10884
Merged
rapids-bot
merged 12 commits into
rapidsai:branch-22.08
from
sperlingxx:catch_cuda_fatal_error
Jun 7, 2022
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
823b145
update
sperlingxx 404ce92
revert style
sperlingxx ef6e881
udpate
sperlingxx 3dcb354
udpate
sperlingxx e0d026f
udpate
sperlingxx b610762
udpate
sperlingxx 7e66695
update
sperlingxx b91e248
update
sperlingxx ac595a2
update
sperlingxx 61058af
remove lines
sperlingxx 3af3cc8
Merge remote-tracking branch 'origin/branch-22.06' into catch_cuda_fa…
sperlingxx 182c15d
Merge remote-tracking branch 'origin/branch-22.08' into catch_cuda_fa…
sperlingxx 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
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,67 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ai.rapids.cudf; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class CudaFatalTest { | ||
|
||
@Test | ||
public void testCudaFatalException() { | ||
try (ColumnVector cv = ColumnVector.fromInts(1, 2, 3, 4, 5)) { | ||
|
||
try (ColumnView badCv = ColumnView.fromDeviceBuffer(new BadDeviceBuffer(), 0, DType.INT8, 256); | ||
ColumnView ret = badCv.sub(badCv); | ||
HostColumnVector hcv = ret.copyToHost()) { | ||
} catch (CudaException ignored) { | ||
} | ||
|
||
// CUDA API invoked by libcudf failed because of previous unrecoverable fatal error | ||
assertThrows(CudaFatalException.class, () -> { | ||
try (ColumnVector cv2 = cv.asLongs()) { | ||
} catch (CudaFatalException ex) { | ||
assertEquals(CudaException.CudaError.cudaErrorIllegalAddress, ex.cudaError); | ||
throw ex; | ||
} | ||
}); | ||
} | ||
|
||
// CUDA API invoked by RMM failed because of previous unrecoverable fatal error | ||
assertThrows(CudaFatalException.class, () -> { | ||
try (ColumnVector cv = ColumnVector.fromBoxedInts(1, 2, 3, 4, 5)) { | ||
} catch (CudaFatalException ex) { | ||
assertEquals(CudaException.CudaError.cudaErrorIllegalAddress, ex.cudaError); | ||
throw ex; | ||
} | ||
}); | ||
} | ||
|
||
private static class BadDeviceBuffer extends BaseDeviceMemoryBuffer { | ||
public BadDeviceBuffer() { | ||
super(256L, 256L, (MemoryBufferCleaner) null); | ||
} | ||
|
||
@Override | ||
public MemoryBuffer slice(long offset, long len) { | ||
return null; | ||
} | ||
} | ||
|
||
} |
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
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.
Does this end up doing a full device synchronize as normal
cudaFree
calls do? If it does, ideally we would want to find a CUDA call that can detect the error with minimal (ideally zero) synchronization with the device.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.
Hi @jlowe, according to the CUDA doc, "If devPtr is 0, no operation is performed. cudaFree() returns cudaErrorValue in case of failure."
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.
If we're guaranteed this doesn't do anything slow like a synchronize it seems OK to me, but I'll defer to @jrhemstad's judgement on whether this is the best approach with the limited tools we have to detect this.
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.
lol, well that's just straight up a lie given that 99% of the world uses
cudaFree(0)
to force context initialization 🙃.tbh, I've had my confidence shaken in the whole "sticky" error thing as a result of exploring this because of this PR.
The right long term solution is that we'll need to file an RFE to get a deterministic, programmatic way to query when the context is borked.
In the meantime,
cudaFree(0)
seems about the least bad option available.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.
Shall we just let the PR in, as a sort of workaround?