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)
| 20 | |
| 21 | |
| 22 | def 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 |
no outgoing calls
no test coverage detected