Skip to content

Instantly share code, notes, and snippets.

@thiagopbueno
Last active November 27, 2019 15:54
Show Gist options
  • Save thiagopbueno/bccdc6f35b73970fcbb8fb5e609325e4 to your computer and use it in GitHub Desktop.
Save thiagopbueno/bccdc6f35b73970fcbb8fb5e609325e4 to your computer and use it in GitHub Desktop.
TensorFlow snippets

GPUs

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '-1' # ignore GPUs

CPUs

Multiprocessing

import psutil
import os
os.environ['OMP_NUM_THREADS'] = str(psutil.cpu_count(logical=False))

import tensorflow as tf
config = tf.ConfigProto(
  inter_op_parallelism_threads=1,
  intra_op_parallelism_threads=1,
)

with tf.Session(config=config) as sess:
  pass

Logging

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment