Skip to content

Use valid GPU for allocating CUDA host memory - #4185

Closed
gibiansky wants to merge 1 commit into
tensorflow:masterfrom
gibiansky:gibiansky-fix-cuda-alloc-executor-choice
Closed

gibiansky wants to merge 1 commit into
tensorflow:masterfrom
gibiansky:gibiansky-fix-cuda-alloc-executor-choice

Conversation

@gibiansky

Copy link
Copy Markdown
Contributor

This PR fixes (again!) issue #1888.

Before this commit, when allocating CUDA host memory, device 0 would
always be used to allocate the memory (because the memory is allocated
on the host with DMA enabled in the same way for all devices; it does
not matter which stream executor allocates the host memory). This
works, but if device 0 is not a valid device in this session (e.g. it
is turned off using GPUOptions.visible_device_list), doing so would
allocate a context on GPU 0, even when it was not being used. This
change fixes this, so that a visible device is found by looking at
which GPU allocators exist, and then using that device to allocate host
memory.

@vrv

Before this commit, when allocating CUDA host memory, device 0 would
always be used to allocate the memory (because the memory is allocated
on the host with DMA enabled in the same way for all devices; it does
not matter which stream executor allocates the host memory). This
works, but if device 0 is not a valid device in this session (e.g. it
is turned off using GPUOptions.visible_device_list), doing so would
allocate a context on GPU 0, even when it was not being used. This
change fixes this, so that a visible device is found by looking at
which GPU allocators exist, and then using that device to allocate host
memory.
numa_node = 0;
mutex_lock lock(mu_);

// CUDAHost alloc the same across all gpus, so just get the executor for the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe start this with "Any valid stream executor works for allocating CUDA host memory, so just ..."

@vrv

vrv commented Sep 2, 2016

Copy link
Copy Markdown

This is pretty much what I was thinking, so thanks! I wonder what happened to the CLA bot though, we need that to go through...

@vrv

vrv commented Sep 2, 2016

Copy link
Copy Markdown

@googlebot where are you

@vrv

vrv commented Sep 2, 2016

Copy link
Copy Markdown

I guess if this is being done as part of your work from Baidu, we'd need Baidu to sign the corp CLA. Perhaps I should just implement this fix myself instead, unless you want to push that through ;)

@gibiansky

Copy link
Copy Markdown
Contributor Author

Probably best to just have you re-implement it, then, especially given how small it is; this is not being done for Baidu (hence non corp CLA) and I do not think I can get a corp CLA there for this work at this point, but given how small this change is, may as well play it safe.

@vrv

vrv commented Sep 2, 2016

Copy link
Copy Markdown

ah, the commit had a baidu.com email address, so I wasn't sure. Okay, sorry about that, legal stuff makes me sad too. I'll send in a fix soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants