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

GPU Memory Allocation Limits #67

Open
mwang87 opened this issue Jul 25, 2019 · 2 comments
Open

GPU Memory Allocation Limits #67

mwang87 opened this issue Jul 25, 2019 · 2 comments

Comments

@mwang87
Copy link

mwang87 commented Jul 25, 2019

There could be a command line option to set the max GPU memory allocation. By default tensorflow pre-allocates 100% of the GPU memory. If its not needed, then enabling the user to set the appropriate limit could help with GPU sharing. Example code for tensorflow is the following:

extra imports to set GPU options

import tensorflow as tf
from keras import backend as k

###################################

TensorFlow wizardry

config = tf.ConfigProto()

Don't pre-allocate memory; allocate as-needed

config.gpu_options.allow_growth = True

Only allow a total of half the GPU memory to be allocated

config.gpu_options.per_process_gpu_memory_fraction = 0.1

Create a session with the above options specified.

k.tensorflow_backend.set_session(tf.Session(config=config))
###################################

@mortonjt
Copy link
Collaborator

mortonjt commented Oct 1, 2019

@mwang87 would definitely be curious to hear more of your thoughts on this.

Right now, all of the data is being loaded on the GPU to avoid data transferring (see this line.

This isn't ideal for very large datasets. I have a DataLoader built in pytorch that can handle larger datasets. But given that we are supporting tensorflow in the first version - I wonder how easy this would be to fix here.

@mwang87
Copy link
Author

mwang87 commented Oct 1, 2019

Personally have not done straight TF, in Keras you can incrementally define batches to shoot over to GPU.

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

2 participants