MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / get_default_sess_config

Function get_default_sess_config

tensorpack/tfutils/common.py:22–60  ·  view source on GitHub ↗

Return a tf.ConfigProto to use as default session config. You can modify the returned config to fit your needs. Args: mem_fraction(float): see the `per_process_gpu_memory_fraction` option in TensorFlow's GPUOptions protobuf: https://github.com/tensorflow

(mem_fraction=0.99)

Source from the content-addressed store, hash-verified

20
21
22def get_default_sess_config(mem_fraction=0.99):
23 """
24 Return a tf.ConfigProto to use as default session config.
25 You can modify the returned config to fit your needs.
26
27 Args:
28 mem_fraction(float): see the `per_process_gpu_memory_fraction` option
29 in TensorFlow's GPUOptions protobuf:
30 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/config.proto
31
32 Returns:
33 tf.ConfigProto: the config to use.
34 """
35 conf = tfv1.ConfigProto()
36
37 conf.allow_soft_placement = True
38 # conf.log_device_placement = True
39
40 conf.intra_op_parallelism_threads = 1
41 conf.inter_op_parallelism_threads = 0
42 # TF benchmark use cpu_count() - gpu_thread_count(), e.g. 80 - 8 * 2
43 # Didn't see much difference.
44
45 conf.gpu_options.per_process_gpu_memory_fraction = mem_fraction
46
47 # This hurt performance of large data pipeline:
48 # https://github.com/tensorflow/benchmarks/commit/1528c46499cdcff669b5d7c006b7b971884ad0e6
49 # conf.gpu_options.force_gpu_compatible = True
50
51 conf.gpu_options.allow_growth = True
52
53 # from tensorflow.core.protobuf import rewriter_config_pb2 as rwc
54 # conf.graph_options.rewrite_options.memory_optimization = \
55 # rwc.RewriterConfig.HEURISTICS
56
57 # May hurt performance?
58 # conf.graph_options.optimizer_options.global_jit_level = tf.OptimizerOptions.ON_1
59 # conf.graph_options.place_pruned_graph = True
60 return conf
61
62
63@graph_memoized

Callers 7

checkpoint-prof.pyFile · 0.90
imagenet_utils.pyFile · 0.90
imagenet_utils.pyFile · 0.90
imagenet_utils.pyFile · 0.90
imagenet_utils.pyFile · 0.90
__init__Method · 0.85
trainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected