This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Do not touch GPU 0 during ReleaseAll #14550
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,11 +53,14 @@ class GPUPooledStorageManager final : public StorageManager { | |
public: | ||
/*! | ||
* \brief Default constructor. | ||
* | ||
* \param initial_context context used by this Storage Manager | ||
*/ | ||
GPUPooledStorageManager() { | ||
explicit GPUPooledStorageManager(Context initial_context) { | ||
reserve_ = dmlc::GetEnv("MXNET_GPU_MEM_POOL_RESERVE", 5); | ||
page_size_ = dmlc::GetEnv("MXNET_GPU_MEM_POOL_PAGE_SIZE", 4096); | ||
large_alloc_round_size_ = dmlc::GetEnv("MXNET_GPU_MEM_LARGE_ALLOC_ROUND_SIZE", 2 * 1024 * 1024); | ||
initial_context_ = initial_context; | ||
if (large_alloc_round_size_ <= 0) { | ||
LOG(FATAL) << "MXNET_GPU_MEM_LARGE_ALLOC_ROUND_SIZE cannot be set to a value <= 0, found: " | ||
<< large_alloc_round_size_; | ||
|
@@ -123,6 +126,8 @@ class GPUPooledStorageManager final : public StorageManager { | |
int reserve_; | ||
// number of devices | ||
const size_t NDEV = 32; | ||
// context used by this Storage Manager | ||
Context initial_context_; | ||
// memory pool | ||
std::unordered_map<size_t, std::vector<void*>> memory_pool_; | ||
DISALLOW_COPY_AND_ASSIGN(GPUPooledStorageManager); | ||
|
@@ -177,6 +182,7 @@ void GPUPooledStorageManager::ReleaseAll() { | |
Storage::Handle handle; | ||
handle.dptr = j; | ||
handle.size = i.first; | ||
handle.ctx = initial_context_; | ||
DirectFreeNoLock(handle); | ||
} | ||
} | ||
|
@@ -201,11 +207,14 @@ class GPUPooledRoundedStorageManager final : public StorageManager { | |
public: | ||
/*! | ||
* \brief Default constructor. | ||
* | ||
* \param initial_context context used by this Storage Manager | ||
*/ | ||
GPUPooledRoundedStorageManager() { | ||
explicit GPUPooledRoundedStorageManager(Context initial_context) { | ||
reserve_ = dmlc::GetEnv("MXNET_GPU_MEM_POOL_RESERVE", 5); | ||
page_size_ = dmlc::GetEnv("MXNET_GPU_MEM_POOL_PAGE_SIZE", 4096); | ||
cut_off_ = dmlc::GetEnv("MXNET_GPU_MEM_POOL_ROUND_LINEAR_CUTOFF", 24); | ||
initial_context_ = initial_context; | ||
if (page_size_ < 32) { | ||
LOG(FATAL) << "MXNET_GPU_MEM_POOL_PAGE_SIZE cannot be set to a value smaller than 32. " \ | ||
<< "Got: " << page_size_ << "."; | ||
|
@@ -290,6 +299,8 @@ class GPUPooledRoundedStorageManager final : public StorageManager { | |
size_t cut_off_; | ||
// percentage of reserved memory | ||
int reserve_; | ||
// context used by this Storage Manager | ||
Context initial_context_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
// memory pool | ||
std::vector<std::vector<void*>> memory_pool_; | ||
DISALLOW_COPY_AND_ASSIGN(GPUPooledRoundedStorageManager); | ||
|
@@ -345,6 +356,7 @@ void GPUPooledRoundedStorageManager::ReleaseAll() { | |
Storage::Handle handle; | ||
handle.size = size; | ||
handle.dptr = j; | ||
handle.ctx = initial_context_; | ||
DirectFreeNoLock(handle); | ||
} | ||
memory_pool_[i].clear(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more comment: make it const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.