trunk,cudamatrix : added reset of cuda error state by cudaGetLastError(), when allocator runs out of gpu memory before releasing

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@3197 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
This commit is contained in:
Karel Vesely 2013-11-21 22:53:34 +00:00
Родитель c3a5fa2187
Коммит b1602fd846
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -588,6 +588,7 @@ void* CuAllocator::MallocInternal(size_t row_bytes,
if (ret != 0) {
KALDI_WARN << "Allocation of memory block of " << size << " bytes "
<< "failed, releasing cached memory and retrying.";
cudaGetLastError(); // reset the error state
ReleaseAllCachedMemory();
ret = cudaMalloc(&ans, size);
if (ret != 0)
@ -603,6 +604,7 @@ void* CuAllocator::MallocInternal(size_t row_bytes,
KALDI_WARN << "Allocation of " << num_rows << " rows, each of size "
<< row_bytes << " bytes failed, releasing cached "
<< "memory and retrying.";
cudaGetLastError(); // reset the error state
ReleaseAllCachedMemory();
ret = cudaMallocPitch(&ans, &pitch, row_bytes, num_rows);
if (ret != 0) {