Created
June 21, 2022 08:01
-
-
Save innat/b38ca9af2b3df7edb56fd196e89ac348 to your computer and use it in GitHub Desktop.
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
# RESTRICT TENSORFLOW TO 2GB OF GPU RAM | |
# SO THAT WE HAVE 14GB RAM free | |
LIMIT = 2.0 | |
gpus = tf.config.experimental.list_physical_devices('GPU') | |
if gpus: | |
try: | |
tf.config.experimental.set_virtual_device_configuration( | |
gpus[0], | |
[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=1024*LIMIT)]) | |
logical_gpus = tf.config.experimental.list_logical_devices('GPU') | |
#print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs") | |
except RuntimeError as e: | |
print(e) | |
print('We will restrict TensorFlow to max %iGB GPU RAM'%LIMIT) | |
print('RAM Free %iGB GPU RAM'%(16-LIMIT)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment