# Runtime API

**URL:** <https://forums.developer.nvidia.com/t/runtime-api/9596>\
**Category:** CUDA Programming and Performance\
**Created:** [May 20, 2009, 1:03pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596 "2009-05-20T13:03:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sailesh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sailesh](https://forums.developer.nvidia.com/u/sailesh)\
**Post date:** [May 20, 2009, 1:03pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/1 "2009-05-20T13:03:14Z")

</div>

Hi Friends…  
My name is sailesh  
I am new to cuda…  
I need some help…

When I compile my code it is fine and generating .out file, when I am executing it  
it is showing

cudaSafeCall() Runtime API error…

I dont know why I am getting this kind of message…

Please help me guys…

Sailesh

---

<div class="post-metadata">

**Author:** ![YDD](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@YDD](https://forums.developer.nvidia.com/u/YDD)\
**Post date:** [May 20, 2009, 2:03pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/2 "2009-05-20T14:03:15Z")

</div>

I assume you mean CUDA\_SAFE\_CALL from cutil.h? tmurray will be along shortly with a baseball bat…

Anyway, that means that something failed. Can you get any of the SDK examples to run (both in release and debug modes)? Do you get any more error messages?

---

<div class="post-metadata">

**Author:** ![sailesh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sailesh](https://forums.developer.nvidia.com/u/sailesh)\
**Post date:** [May 20, 2009, 4:27pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/3 "2009-05-20T16:27:53Z")

</div>

> [@](#):
>
> I assume you mean CUDA\_SAFE\_CALL from cutil.h? tmurray will be along shortly with a baseball bat…
> 
> Anyway, that means that something failed. Can you get any of the SDK examples to run (both in release and debug modes)? Do you get any more error messages?

Thanks for responding…

I can run all SDK examples, no error message there…

I get this error only when I run my code.

I am giving part of my code below, where it is failing

size\_var = 4_N_sizeof(float);

cutilSafeCall(cudaMalloc((void\*\*)&gpu\_x\_k\_mat,size\_var));

cutilSafeCall(cudaMemcpy(gpu\_x\_k\_mat,x\_k\_mat,size\_var,cudaMe

mcpyHostToDevice));

size\_var = bins_bins_bins\*sizeof(float);

cutilSafeCall(cudaMalloc((void\*\*)&gpu\_model\_mat,size\_var));

cutilSafeCall(cudaMemcpy(gpu\_model\_mat,model\_mat,size\_var,cu

daMemcpyHostToDevice));

size\_var = 2\*sizeof(float);

cutilSafeCall(cudaMalloc((void\*\*)&gpu\_scale\_for\_kernel,size\_var));

cutilSafeCall(cudaMemcpy(gpu\_scale\_for\_kernel,scale\_for\_kern

el,size\_var,cudaMemcpyHostToDevice));

size\_var = N\*sizeof(float);

cutilSafeCall(cudaMalloc((void\*\*)&gpu\_w\_k,size\_var));

size\_var = sizeof(int);

cutilSafeCall(cudaMalloc((void\*\*)&gpu\_bin,size\_var));

cutilSafeCall(cudaMemcpy(gpu\_bin,bin,size\_var,cudaMemcpyHost

ToDevice));

size\_var = sizeof(int);

cutilSafeCall(cudaMalloc((void\*\*)&gpu\_Na,size\_var));

cutilSafeCall(cudaMemcpy(gpu\_Na,Na,size\_var,cudaMemcpyHostTo

Device));

pftrack\_kernel\<\<\<1, N\>\>\>(gpu\_x\_k\_mat,gpu\_image\_matR,gpu\_image\_matG,gpu\_image\_matB

,gpu\_model\_mat,gpu\_scale\_for\_kernel,bin,Na,gpu\_w\_k);

size\_var = N\*sizeof(float);

[u][b]cutilSafeCall(cudaMemcpy(w\_k,gpu\_w\_k,size\_var,cudaMemcpyDevi

ceToHost));[/b][/u]

I get error only on the last line…(bold one)

What could be the reason…?

---

<div class="post-metadata">

**Author:** ![tmurray](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@tmurray](https://forums.developer.nvidia.com/u/tmurray)\
**Post date:** [May 20, 2009, 5:21pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/4 "2009-05-20T17:21:44Z")

</div>

Your kernel probably has a segfault in it, and cudaThreadSynchronize would return unspecified launch failure if you were calling it. Since you’re not, cudaMemcpy is doing that instead.

Now, get rid of cutil and check your errors yourself with cudaGetLastError() and cudaGetErrorString().

---

<div class="post-metadata">

**Author:** ![sailesh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sailesh](https://forums.developer.nvidia.com/u/sailesh)\
**Post date:** [May 20, 2009, 6:13pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/5 "2009-05-20T18:13:16Z")

</div>

> [@](#):
>
> Your kernel probably has a segfault in it, and cudaThreadSynchronize would return unspecified launch failure if you were calling it. Since you’re not, cudaMemcpy is doing that instead.
> 
> Now, get rid of cutil and check your errors yourself with cudaGetLastError() and cudaGetErrorString().

I am gettint “unspecified launch failure” error…

Now I removed cutilSafeCall and used CUDA\_SAFE\_CALL

now I am getting the array that I have copied back from GPU as “NaN”

Does it mean SEG fault…?

---

<div class="post-metadata">

**Author:** ![sailesh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sailesh](https://forums.developer.nvidia.com/u/sailesh)\
**Post date:** [May 20, 2009, 6:13pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/6 "2009-05-20T18:13:28Z")

</div>

[quote name=‘tmurray’ post=‘543437’ date=‘May 20 2009, 10:51 PM’]

Your kernel probably has a segfault in it, and cudaThreadSynchronize would return unspecified launch failure if you were calling it. Since you’re not, cudaMemcpy is doing that instead.

Thanks for your reply…

Again waiting for reply… :D

---

<div class="post-metadata">

**Author:** ![YDD](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@YDD](https://forums.developer.nvidia.com/u/YDD)\
**Post date:** [May 20, 2009, 7:38pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/7 "2009-05-20T19:38:38Z")

</div>

As I said in another thread, recompile in device emulation mode (emu=1 dbg=1, if you’re using common.mk), and run through valgrind.

---

<div class="post-metadata">

**Author:** ![sailesh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sailesh](https://forums.developer.nvidia.com/u/sailesh)\
**Post date:** [May 21, 2009, 12:06pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/8 "2009-05-21T12:06:07Z")

</div>

> [@](#):
>
> As I said in another thread, recompile in device emulation mode (emu=1 dbg=1, if you’re using common.mk), and run through valgrind.

Here I have this kernel invocation in a for loop

When compiled it in deviceemu mode it runs correctly up to 84 iterations. but exactly after 84 th iteration again I am getting “NaN” error.

and when I compile in GPU mode I am not at all able perform one iteration also.

cant we put the kernel invocation in a for loop…?

does it gives errors related to memory…?

---

<div class="post-metadata">

**Author:** ![YDD](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@YDD](https://forums.developer.nvidia.com/u/YDD)\
**Post date:** [May 21, 2009, 1:54pm UTC](https://forums.developer.nvidia.com/t/runtime-api/9596/9 "2009-05-21T13:54:41Z")

</div>

What did valgrind say? Running kernels in loops shouldn’t be a problem.
