Skip to content

Commit

Permalink
Merge pull request BVLC#179 from drnikolaev/caffe-0.15-multigpu-ws-fix
Browse files Browse the repository at this point in the history
Hot fix preventing dead lock during shutdown
  • Loading branch information
drnikolaev authored Jun 25, 2016
2 parents dce8bbf + c068392 commit a7c9144
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/caffe/util/gpu_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void GPUMemory::Manager::init(const vector<int>& gpus, Mode m, bool debug) {
// Just in case someone installed 'no cleanup' arena before
delete cub_allocator_;
cub_allocator_ = new cub::CachingDeviceAllocator(BIN_GROWTH, MIN_BIN,
MAX_BIN, MAX_CACHED_BYTES, false, debug_);
MAX_BIN, MAX_CACHED_BYTES, true, debug_);
} catch (...) {
}
CHECK_NOTNULL(cub_allocator_);
Expand Down Expand Up @@ -117,7 +117,14 @@ void GPUMemory::Manager::deallocate(void* ptr, int device,
}
switch (mode_) {
case CUB_ALLOCATOR:
CUDA_CHECK(cub_allocator_->DeviceFree(device, ptr));
{
int current_device;
cudaError_t status = cudaGetDevice(&current_device);
// Preventing dead lock while Caffe shutting down.
if (status != cudaErrorCudartUnloading) {
CUDA_CHECK(cub_allocator_->DeviceFree(device, ptr));
}
}
break;
default:
CUDA_CHECK(cudaFree(ptr));
Expand Down

0 comments on commit a7c9144

Please sign in to comment.