提交 bb58f1a6 authored 作者: nouiz's avatar nouiz

Merge pull request #419 from goodfeli/gpu_mem_leak

fixed debugging and warning messages (grammar and semantics) for cudandarray
...@@ -47,7 +47,7 @@ void * device_malloc(size_t size) ...@@ -47,7 +47,7 @@ void * device_malloc(size_t size)
if (cudaSuccess != err) if (cudaSuccess != err)
{ {
#if COMPUTE_GPU_MEM_USED #if COMPUTE_GPU_MEM_USED
fprintf(stderr, "Error allocating %li bytes of device memory (%s). %d already allocated\n", (long)size, cudaGetErrorString(err),_allocated_size); fprintf(stderr, "Error allocating %li bytes of device memory (%s). new total bytes allocated: %d\n", (long)size, cudaGetErrorString(err),_allocated_size);
#else #else
fprintf(stderr, "Error allocating %li bytes of device memory (%s).\n", (long)size, cudaGetErrorString(err)); fprintf(stderr, "Error allocating %li bytes of device memory (%s).\n", (long)size, cudaGetErrorString(err));
#endif #endif
...@@ -65,7 +65,7 @@ void * device_malloc(size_t size) ...@@ -65,7 +65,7 @@ void * device_malloc(size_t size)
} }
_allocated_size += size; _allocated_size += size;
#endif #endif
//fprintf(stderr, "allocated %li bytes of device memory (%s). %d already allocated, ptr: %p\n", (long)size, cudaGetErrorString(err),_allocated_size,rval); //fprintf(stderr, "allocated %li bytes of device memory (%s). new total bytes allocated: %d. ptr: %p\n", (long)size, cudaGetErrorString(err),_allocated_size,rval);
if(ALLOC_MEMSET){ if(ALLOC_MEMSET){
//We init them to nan to make sure we catch more debug case. //We init them to nan to make sure we catch more debug case.
...@@ -76,6 +76,7 @@ void * device_malloc(size_t size) ...@@ -76,6 +76,7 @@ void * device_malloc(size_t size)
} }
int device_free(void *ptr) int device_free(void *ptr)
{ {
// if there is no gpu context, the call to cudaFree will fail; skip it entirely // if there is no gpu context, the call to cudaFree will fail; skip it entirely
if(!g_gpu_context_active) { if(!g_gpu_context_active) {
return 0; return 0;
...@@ -219,7 +220,7 @@ CudaNdarray_dealloc(CudaNdarray* self) ...@@ -219,7 +220,7 @@ CudaNdarray_dealloc(CudaNdarray* self)
{ {
if (0) std::cerr << "CudaNdarray dealloc " << self << " " << self->devdata << '\n'; if (0) std::cerr << "CudaNdarray dealloc " << self << " " << self->devdata << '\n';
if(self->ob_refcnt>1) if(self->ob_refcnt>1)
printf("WARNING:CudaNdarray_dealloc called when their is still active reference to it.\n"); printf("WARNING:CudaNdarray_dealloc called when there is still active reference to it.\n");
CudaNdarray_uninit(self); CudaNdarray_uninit(self);
self->ob_type->tp_free((PyObject*)self); self->ob_type->tp_free((PyObject*)self);
--_outstanding_mallocs[1]; --_outstanding_mallocs[1];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论