summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Gäßler <johannesg@5d6.de>2023-09-11 13:00:24 +0200
committerGitHub <noreply@github.com>2023-09-11 13:00:24 +0200
commit8a4ca9af569853023ce87f047eb5165df13f2ff1 (patch)
tree7cd0c1d44a6b282324affa821ebb277772976a2e
parentf31b6f4e2d6def3c0bd7c75f75c0c1e8698e0589 (diff)
CUDA: add device number to error messages (#3112)
-rw-r--r--ggml-cuda.cu11
1 files changed, 10 insertions, 1 deletions
diff --git a/ggml-cuda.cu b/ggml-cuda.cu
index 00e9bbea..50344ae8 100644
--- a/ggml-cuda.cu
+++ b/ggml-cuda.cu
@@ -144,8 +144,11 @@ static_assert(sizeof(half) == sizeof(ggml_fp16_t), "wrong fp16 size");
do { \
cudaError_t err_ = (err); \
if (err_ != cudaSuccess) { \
- fprintf(stderr, "CUDA error %d at %s:%d: %s\n", err_, __FILE__, __LINE__, \
+ int id; \
+ cudaGetDevice(&id); \
+ fprintf(stderr, "\nCUDA error %d at %s:%d: %s\n", err_, __FILE__, __LINE__, \
cudaGetErrorString(err_)); \
+ fprintf(stderr, "current device: %d\n", id); \
exit(1); \
} \
} while (0)
@@ -155,8 +158,11 @@ static_assert(sizeof(half) == sizeof(ggml_fp16_t), "wrong fp16 size");
do { \
cublasStatus_t err_ = (err); \
if (err_ != CUBLAS_STATUS_SUCCESS) { \
+ int id; \
+ cudaGetDevice(&id); \
fprintf(stderr, "\ncuBLAS error %d at %s:%d: %s\n", \
err_, __FILE__, __LINE__, cublasGetStatusString(err_)); \
+ fprintf(stderr, "current device: %d\n", id); \
exit(1); \
} \
} while (0)
@@ -165,7 +171,10 @@ static_assert(sizeof(half) == sizeof(ggml_fp16_t), "wrong fp16 size");
do { \
cublasStatus_t err_ = (err); \
if (err_ != CUBLAS_STATUS_SUCCESS) { \
+ int id; \
+ cudaGetDevice(&id); \
fprintf(stderr, "\ncuBLAS error %d at %s:%d\n", err_, __FILE__, __LINE__); \
+ fprintf(stderr, "current device: %d\n", id); \
exit(1); \
} \
} while (0)