Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory used across all GPUs #180

Closed
mys007 opened this issue Jun 15, 2015 · 6 comments
Closed

Memory used across all GPUs #180

mys007 opened this issue Jun 15, 2015 · 6 comments

Comments

@mys007
Copy link
Contributor

mys007 commented Jun 15, 2015

The current implementation allocates hundreds of MB of GPU memory on each GPU present in the system (at least 102MB per device as reported by nvidia-smi), just upon simple require 'cutorch'. This doesn't change with subsequent calls like cutorch.setDevice(). Is there any technical reason for this behavior?

@soumith
Copy link
Member

soumith commented Jun 15, 2015

we only allocate a tiny amount of scratch space. All combined to be less than 2MB afaik.
NVIDIA's driver allocates a minimum amount of memory per process using the GPU, for p2p scratch buffers etc. (possibly).

@soumith soumith closed this as completed Jun 15, 2015
@mys007
Copy link
Contributor Author

mys007 commented Jun 15, 2015

Hmm, but the end effect is the same, there is 100MB GPU memory less for each process. It should be possible to start cutorch selectively just on a chosen subsets of GPUs.

@soumith
Copy link
Member

soumith commented Jun 15, 2015

CUDA_VISIBLE_DEVICES=0,2 th [yourscript.lua]

where you are telling it to use device 0 and device 2.
The devices are 0-indexed.

@mys007
Copy link
Contributor Author

mys007 commented Jun 15, 2015

Great, thanks!

@eriche2016
Copy link

eriche2016 commented May 12, 2016

so if you use CUDA_VISIBLE_DEVICES=0 th [yourscript.lua], it means that you can only have 1 gpu to use and others are transparent to you, so there is no sense to use cutorch.setDevice(id) which can be used to switch the default gpu, right? if so, can you offer some guidlines about when to use CUDA_VISIBLE_DEVICES and when to use cutorch.setDevice(id)?

@fmassa
Copy link
Contributor

fmassa commented May 12, 2016

@eriche2016 it makes sense to use it in the context of multi-GPUs. For example, with CUDA_VISIBLE_DEVICES=0,2 you select the GPUs you want to use (here 0 and 2), and with cutorch.setDevice you select between each visible device your tensor will be created. This is how it's done in DataParallelTable.
Now if you only want to use 1 GPU, then there are no benefits in using cutorch.setDevice instead of CUDA_VISIBLE_DEVICES.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants