cudaFree not working properly

Hi all,
i’m not sure if this is the right section of the forum for this discussion, but since yesterday i’m experiencing a weird behavior from cudaFree.

Here is my code:
cudaError_t error;

size_t mem_tot_0 = 0;
size_t mem_free_0 = 0;
cudaMemGetInfo (&mem_free_0, & mem_tot_0);
printf(“mem free %zu; mem tot %zu \n”, mem_free_0, mem_tot_0);

int kur = res/8;
dim3 dimGrid( kur, kur, kur);
dim3 dimBlock( 8, 8, 8);
kernel_vox_2<<<dimGrid, dimBlock>>>(depth, dev_dist, dev_tsdf, res, dev_seen_u, dev_seen_v);
getLastCudaError(“Kernel 2 Launch Failed”);

cudaMemcpy( tsdf, dev_tsdf, resresres*sizeof(float), cudaMemcpyDeviceToHost);

error = cudaFree(dev_seen_u);
if (error != cudaSuccess)
{
printf(“failed to free array %d \n”, LINE-3);
}
error = cudaFree(dev_seen_v);
if (error != cudaSuccess)
{
printf(“failed to free array %d \n”, LINE-3);
}
error = cudaFree(dev_dist);
if (error != cudaSuccess)
{
printf(“failed to free array %d \n”, LINE-3);
}
error = cudaFree(dev_tsdf);
if (error != cudaSuccess)
{
printf(“failed to free array %d \n”, LINE-3);
}

cudaMemGetInfo (&mem_free_0, & mem_tot_0);
printf(“mem free %zu; mem tot %zu \n”, mem_free_0, mem_tot_0);

cudaDeviceReset();

and here are the error messages:

mem free 1912651776; mem tot 2146762752
failed to free array 145
failed to free array 150
failed to free array 156
failed to free array 162
mem free 0; mem tot 0

thanks

Bruno

Hi,

You should check the error code returned by cudaMemGetInfo. It surely reports the previous error.

Julien