21 import tensorflow
as tf
23 visible_device_list =
'0'
24 per_process_gpu_memory_fraction = 0.9
25 intra_op_parallelism_threads = 2
26 inter_op_parallelism_threads = 5
28 gpu_options = tf.compat.v1.GPUOptions(
29 per_process_gpu_memory_fraction = per_process_gpu_memory_fraction,
30 visible_device_list = visible_device_list,
33 config = tf.compat.v1.ConfigProto(
34 allow_soft_placement =
True,
35 log_device_placement =
False,
36 intra_op_parallelism_threads = intra_op_parallelism_threads,
37 inter_op_parallelism_threads = inter_op_parallelism_threads,
38 gpu_options = gpu_options)
40 s = config.SerializeToString()
43 print(
'a serialized protobuf string for TF_SetConfig, note the byte order is in normal order.')
44 b =
''.join(
format(b,
'02x')
for b
in s)