import os
import sys

# Try to mute and then load Tensorflow and Keras
# Muting seems to not work lately on Linux in any way
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
from tensorflow.python.client import device_lib
sys.stdin = stdin
sys.stderr = stderr

# Get list of all devices
devices = device_lib.list_local_devices()

# Print GPUs only
print('\n\n\nList of found GPUs:')
for device in devices:
    if device.device_type == 'GPU':
        print(device.physical_device_desc)
# result:
# List of found GPUs:
# device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0
a37a1fa7df1160a86fb85432659901cf01079b92
<mask token>

<mask token>
tf.logging.set_verbosity(tf.logging.ERROR)
<mask token>
print("""


List of found GPUs:""")
for device in devices:
    if device.device_type == 'GPU':
        print(device.physical_device_desc)

<mask token>
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
<mask token>
tf.logging.set_verbosity(tf.logging.ERROR)
<mask token>
sys.stdin = stdin
sys.stderr = stderr
devices = device_lib.list_local_devices()
print("""


List of found GPUs:""")
for device in devices:
    if device.device_type == 'GPU':
        print(device.physical_device_desc)

import os
import sys
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
from tensorflow.python.client import device_lib
sys.stdin = stdin
sys.stderr = stderr
devices = device_lib.list_local_devices()
print("""


List of found GPUs:""")
for device in devices:
    if device.device_type == 'GPU':
        print(device.physical_device_desc)

import os
import sys

# Try to mute and then load Tensorflow and Keras
# Muting seems to not work lately on Linux in any way
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
from tensorflow.python.client import device_lib
sys.stdin = stdin
sys.stderr = stderr

# Get list of all devices
devices = device_lib.list_local_devices()

# Print GPUs only
print('\n\n\nList of found GPUs:')
for device in devices:
    if device.device_type == 'GPU':
        print(device.physical_device_desc)
# result:
# List of found GPUs:
# device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0