Skip to content
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

Include cublas error details when getting cublas handle fails #3695

Merged
merged 7 commits into from
Jun 13, 2023
8 changes: 6 additions & 2 deletions csrc/includes/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ class TrainingContext {
{
curandCreateGenerator(&_gen, CURAND_RNG_PSEUDO_DEFAULT);
curandSetPseudoRandomGeneratorSeed(_gen, 123);
if (cublasCreate(&_cublasHandle) != CUBLAS_STATUS_SUCCESS) {
auto message = std::string("Fail to create cublas handle.");
cublasStatus_t stat = cublasCreate(&_cublasHandle);
if (stat != CUBLAS_STATUS_SUCCESS) {
// It would be nice to use cublasGetStatusName and
// cublasGetStatusString, but they were only added in CUDA 11.4.2.
auto message = std::string("Failed to create cublas handle: cublasStatus_t was ") +
std::to_string(stat);
std::cerr << message << std::endl;
throw std::runtime_error(message);
}
Expand Down
9 changes: 7 additions & 2 deletions csrc/transformer/inference/includes/inference_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ class InferenceContext {
{
_workSpaceSize = 0;
_workspace = 0;
if (cublasCreate(&_cublasHandle) != CUBLAS_STATUS_SUCCESS) {
auto message = std::string("Fail to create cublas handle.");

cublasStatus_t stat = cublasCreate(&_cublasHandle);
if (stat != CUBLAS_STATUS_SUCCESS) {
// It would be nice to use cublasGetStatusName and
// cublasGetStatusString, but they were only added in CUDA 11.4.2.
auto message = std::string("Failed to create cublas handle: cublasStatus_t was ") +
std::to_string(stat);
std::cerr << message << std::endl;
throw std::runtime_error(message);
}
Expand Down