# Internal debugger error occurred while attempting to launch cublas batched dgemm

**URL:** <https://forums.developer.nvidia.com/t/internal-debugger-error-occurred-while-attempting-to-launch-cublas-batched-dgemm/59055>\
**Category:** GPU-Accelerated Libraries\
**Created:** [March 12, 2018, 4:42pm UTC](https://forums.developer.nvidia.com/t/internal-debugger-error-occurred-while-attempting-to-launch-cublas-batched-dgemm/59055 "2018-03-12T16:42:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yangxl](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@yangxl](https://forums.developer.nvidia.com/u/yangxl)\
**Post date:** [March 12, 2018, 4:42pm UTC](https://forums.developer.nvidia.com/t/internal-debugger-error-occurred-while-attempting-to-launch-cublas-batched-dgemm/59055/1 "2018-03-12T16:42:28Z")

</div>

I have following application of Cublas batched matrix multiplication function cublasDgemmBatched. The code stopped for “unknown reason”.I would like to know that reason. I’m using VS2017 and CUDA V9.1 with GeForce 940MX.

#include “cuda\_runtime.h”  
#include “device\_launch\_parameters.h”  
#include"cublas\_v2.h"

#include \<stdio.h\>  
#include \<stdlib.h\>

int kernel(double \*A, int N, int batchCt) //N is the dimension of matrix  
{  
cublasHandle\_t handle;  
cublasCreate(&handle);  
double alpha = 1.0;  
double beta = 1.0;  
double _d\_A = NULL; //device copy of matrix data  
double pa = NULL; //array of pointers to matrix data  
double pb = NULL;  
double pc = NULL;  
double d\_pa = NULL; //device copy of pa  
double **d\_pb = NULL;  
double d\_pc = NULL;  
cudaMalloc((void)&d\_A, 3 \* batchCt \* N \* N \* sizeof(double)); //allocate device memory for d\_A  
cudaMemcpy(d\_A, A, 3 \* batchCt \* N \* N \* sizeof(double), cudaMemcpyHostToDevice); //memory copy  
pa = (double**)malloc(3 \* batchCt \* sizeof(double)); //allocate host memory for pa  
pb = pa + batchCt;  
pc = pa + 2 \* batchCt;  
for (int k = 0; k \< batchCt; k++) //compute the pointers to matrix data on device  
{  
pa[k] = d\_A + k \* N \* N;  
pb[k] = pa[k] + batchCt \* N \* N ;  
pc[k] = pa[k] + 2 \* batchCt \* N \* N;  
}  
cudaMalloc((void)&d\_pa, 3 \* batchCt \* sizeof(double)); //allocate device memory for d\_pa  
cudaMemcpy(d\_pa, pa, 3 \* batchCt \* sizeof(double), cudaMemcpyHostToDevice); //memory copy  
d\_pb = d\_pa + batchCt;  
d\_pc = d\_pa + 2 \* batchCt;  
cublasDgemmBatched(handle, CUBLAS\_OP\_N, CUBLAS\_OP\_N, N, N, N, &alpha, (const double)d\_pa, N, (const double_)d\_pb, N, &beta, d\_pc, N, batchCt);  
cudaMemcpy(A, d\_A, 3 \* batchCt \* N \* N \* sizeof(double), cudaMemcpyDeviceToHost);  
cublasDestroy(handle);  
cudaFree(d\_A);  
cudaFree(d\_pa);  
free¶;  
return 0;  
}

int main()  
{  
int batchCt = 3;  
int N = 3;  
double _A = (double_)malloc(3 \* batchCt \* N \* N \* sizeof(double));  
for (int k = 0; k \< 3 \* batchCt \* N \* N; k++)  
A[k] = k \* k / 2 + 1.0; //arbitrary numbers  
int result = kernel(A, N, batchCt);  
free(A);  
return result;  
}

The debugging output is “Internal debugger error occurred while attempting to launch maxwell\_dgemm\_64x64\_nn in CUcontext 0x1efc447bb00, CUmodule 0x1efe2482130: code patching failed for unknown reason. All breakpoints for function maxwell\_dgemm\_64x64\_nn have been removed.”

Note: I removed the API error checking functions since they didn’t give me any error information.

---

<div class="post-metadata">

**Author:** ![njuffa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@njuffa](https://forums.developer.nvidia.com/u/njuffa)\
**Post date:** [March 12, 2018, 5:55pm UTC](https://forums.developer.nvidia.com/t/internal-debugger-error-occurred-while-attempting-to-launch-cublas-batched-dgemm/59055/2 "2018-03-12T17:55:41Z")

</div>

> [@](#):
>
> Internal debugger error […] code patching failed for unknown reason

The debugger is telling us that it detected a bug inside the debugger. Given that this happens with CUDA 9.1, you would want to file a bug report with NVIDIA (the bug-reporting form is linked from the registered developer website) so the engineering team responsible for the debugger can find the root cause of the failure.
