Skip to content

Add file and line to CUDA_CHECK and CUDNN_CHECK#8836

Merged
soumith merged 4 commits intopytorch:masterfrom
bstriner:cpp_exceptions
Jun 25, 2018
Merged

Add file and line to CUDA_CHECK and CUDNN_CHECK#8836
soumith merged 4 commits intopytorch:masterfrom
bstriner:cpp_exceptions

Conversation

@bstriner
Copy link
Contributor

Add file and line to messages from CUDA_CHECK and CUDNN_CHECK. Renamed original functions to cudaCheck and cudnnCheck and made macros with the original names. Should make debugging slightly friendlier.

Also ran clang-format on the file.

Cheers

@bstriner
Copy link
Contributor Author

Worth noting that CUDA_CHECK is now a macro not a function, so potentially redefines CUDA_CHECK from caffe2 if you include both headers at the same time.

Could potentially rename something like AT_CUDA_CHECK and AT_CUDNN_CHECK.

@soumith
Copy link
Collaborator

soumith commented Jun 25, 2018

Could potentially rename something like AT_CUDA_CHECK and AT_CUDNN_CHECK.

Yes please :)

@ssnl
Copy link
Collaborator

ssnl commented Jun 25, 2018

It might be better to just change those functions to use AT_ERROR.

Is this custom cudnn_exception necessary, @ezyang ?

@ezyang
Copy link
Contributor

ezyang commented Jun 25, 2018

No, I don't think it is.

@bstriner
Copy link
Contributor Author

Ok. If that's the case, I'll rewrite both of those checks as just defines that utilize AT_ERROR and rename with AT_ prefixes. Will try to test that out tomorrow.

I like that AT_ERROR includes the function name in the error report as well. That is missing, for example, in TORCH_CUDA_CHECK. https://github.com/pytorch/pytorch/blob/master/torch/csrc/cuda/cuda_check.h

@bstriner
Copy link
Contributor Author

@ssnl Great idea! AT_ERROR prints way better error messages than Exceptions.h was printing. Has function name, line, c stack and everything.

@soumith soumith merged commit e251fb5 into pytorch:master Jun 25, 2018
@soumith
Copy link
Collaborator

soumith commented Jun 25, 2018

looks great, thanks Ben!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants