Skip to content

Commit 8a4ca9a

Browse files
CUDA: add device number to error messages (#3112)
1 parent f31b6f4 commit 8a4ca9a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ggml-cuda.cu

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ static_assert(sizeof(half) == sizeof(ggml_fp16_t), "wrong fp16 size");
144144
do { \
145145
cudaError_t err_ = (err); \
146146
if (err_ != cudaSuccess) { \
147-
fprintf(stderr, "CUDA error %d at %s:%d: %s\n", err_, __FILE__, __LINE__, \
147+
int id; \
148+
cudaGetDevice(&id); \
149+
fprintf(stderr, "\nCUDA error %d at %s:%d: %s\n", err_, __FILE__, __LINE__, \
148150
cudaGetErrorString(err_)); \
151+
fprintf(stderr, "current device: %d\n", id); \
149152
exit(1); \
150153
} \
151154
} while (0)
@@ -155,8 +158,11 @@ static_assert(sizeof(half) == sizeof(ggml_fp16_t), "wrong fp16 size");
155158
do { \
156159
cublasStatus_t err_ = (err); \
157160
if (err_ != CUBLAS_STATUS_SUCCESS) { \
161+
int id; \
162+
cudaGetDevice(&id); \
158163
fprintf(stderr, "\ncuBLAS error %d at %s:%d: %s\n", \
159164
err_, __FILE__, __LINE__, cublasGetStatusString(err_)); \
165+
fprintf(stderr, "current device: %d\n", id); \
160166
exit(1); \
161167
} \
162168
} while (0)
@@ -165,7 +171,10 @@ static_assert(sizeof(half) == sizeof(ggml_fp16_t), "wrong fp16 size");
165171
do { \
166172
cublasStatus_t err_ = (err); \
167173
if (err_ != CUBLAS_STATUS_SUCCESS) { \
174+
int id; \
175+
cudaGetDevice(&id); \
168176
fprintf(stderr, "\ncuBLAS error %d at %s:%d\n", err_, __FILE__, __LINE__); \
177+
fprintf(stderr, "current device: %d\n", id); \
169178
exit(1); \
170179
} \
171180
} while (0)

0 commit comments

Comments
 (0)