Commit 0a1060a6 authored by Fenglei's avatar Fenglei Committed by Robert Kimball

fix convolution bug by retain primary context for device (#894)

* fix convolution bug by retain primary context for device
* add release to destructor
parent 3d590dea
...@@ -31,6 +31,11 @@ runtime::gpu::CudaContextManager::CudaContextManager() ...@@ -31,6 +31,11 @@ runtime::gpu::CudaContextManager::CudaContextManager()
{ {
CUDA_SAFE_CALL(cuInit(0)); CUDA_SAFE_CALL(cuInit(0));
CUDA_SAFE_CALL(cuDeviceGet(&m_device, 0)); CUDA_SAFE_CALL(cuDeviceGet(&m_device, 0));
CUDA_SAFE_CALL(cuCtxCreate(&m_context, 0, m_device)); CUDA_SAFE_CALL(cuDevicePrimaryCtxRetain(&m_context, m_device));
m_context_ptr = std::make_shared<CUcontext>(m_context); m_context_ptr = std::make_shared<CUcontext>(m_context);
} }
runtime::gpu::CudaContextManager::~CudaContextManager()
{
CUDA_SAFE_CALL(cuDevicePrimaryCtxRelease(m_device));
}
...@@ -39,7 +39,7 @@ namespace ngraph ...@@ -39,7 +39,7 @@ namespace ngraph
std::shared_ptr<CUcontext> get_context() { return m_context_ptr; } std::shared_ptr<CUcontext> get_context() { return m_context_ptr; }
protected: protected:
CudaContextManager(); CudaContextManager();
~CudaContextManager() {} ~CudaContextManager();
CUdevice m_device; CUdevice m_device;
CUcontext m_context; CUcontext m_context;
std::shared_ptr<CUcontext> m_context_ptr; std::shared_ptr<CUcontext> m_context_ptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment