Created
February 23, 2021 09:03
-
-
Save AIAnytime/c8ebad5a94664f83c91189d00c7a4a5c to your computer and use it in GitHub Desktop.
How to disable GPU with TensorFlow?
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
try: | |
# Disable all GPUS | |
tf.config.set_visible_devices([], 'GPU') | |
visible_devices = tf.config.get_visible_devices() | |
for device in visible_devices: | |
assert device.device_type != 'GPU' | |
except: | |
# Invalid device or cannot modify virtual devices once initialized. | |
pass | |
#2nd method | |
import os | |
os.environ["CUDA_VISIBLE_DEVICES"] = "-1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment