import tensorflow as tf import multiprocessing as mp core_num = mp.cpu_count() config = tf.ConfigProto( inter_op_parallelism_threads=core_num, intra_op_parallelism_threads=core_num ) a = tf.Variable(123) b = tf.Variable([4,5,6]) ss= tf.Session(config=config) ss.run(tf.initialize_all_variables()) print(ss.run(a)) print(ss.run(b))