Skip to content

Instantly share code, notes, and snippets.

@fo40225
Last active March 23, 2020 12:04
Show Gist options
  • Save fo40225/429c97410becb322384cd9c3b5b00722 to your computer and use it in GitHub Desktop.
Save fo40225/429c97410becb322384cd9c3b5b00722 to your computer and use it in GitHub Desktop.
twgc windows keras tensorflow misc
# 國網專用
import os
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
import os
import multiprocessing
import psutil
IO_THREADS=multiprocessing.cpu_count()
CPU_THREADS=psutil.cpu_count(logical=False)
if os.name is 'nt':
from multiprocessing.dummy import Pool
CPU_THREADS=1
else:
from multiprocessing import Pool
from keras import backend as K
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
K.set_session(session)
# keras FP16
#K.set_floatx('float16')
#K.set_epsilon(2**-10)
# restore default
os.environ['TF_FP16_MATMUL_USE_FP32_COMPUTE']='1'
os.environ['TF_FP16_CONV_USE_FP32_COMPUTE']='1'
os.environ['TF_FP16_RNN_USE_FP32_COMPUTE']='1'
os.environ["TF_ADJUST_HUE_FUSED"]="0"
os.environ["TF_ADJUST_SATURATION_FUSED"]="0"
os.environ["TF_AUTOTUNE_THRESHOLD"]="1"
os.environ["TF_ENABLE_WINOGRAD_NONFUSED"]="0"
# ngc
os.environ["TF_ENABLE_TENSOR_OP_MATH_FP32"] = "0"
os.environ["TF_ENABLE_CUBLAS_TENSOR_OP_MATH_FP32"] = "0"
os.environ["TF_ENABLE_CUDNN_TENSOR_OP_MATH_FP32"] = "0"
os.environ["TF_ENABLE_CUDNN_RNN_TENSOR_OP_MATH_FP32"] = "0"
os.environ["TF_ENABLE_AUTO_MIXED_PRECISION"]="0"
os.environ["TF_ENABLE_AUTO_MIXED_PRECISION_GRAPH_REWRITE"]="0"
os.environ["TF_ENABLE_AUTO_MIXED_PRECISION_LOSS_SCALING"]="0"
os.environ["TF_XLA_FLAGS"]=""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment