1cabdff1aSopenharmony_ci# Copyright (c) 2021 2cabdff1aSopenharmony_ci# 3cabdff1aSopenharmony_ci# This file is part of FFmpeg. 4cabdff1aSopenharmony_ci# 5cabdff1aSopenharmony_ci# FFmpeg is free software; you can redistribute it and/or 6cabdff1aSopenharmony_ci# modify it under the terms of the GNU Lesser General Public 7cabdff1aSopenharmony_ci# License as published by the Free Software Foundation; either 8cabdff1aSopenharmony_ci# version 2.1 of the License, or (at your option) any later version. 9cabdff1aSopenharmony_ci# 10cabdff1aSopenharmony_ci# FFmpeg is distributed in the hope that it will be useful, 11cabdff1aSopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 12cabdff1aSopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13cabdff1aSopenharmony_ci# Lesser General Public License for more details. 14cabdff1aSopenharmony_ci# 15cabdff1aSopenharmony_ci# You should have received a copy of the GNU Lesser General Public 16cabdff1aSopenharmony_ci# License along with FFmpeg; if not, write to the Free Software 17cabdff1aSopenharmony_ci# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18cabdff1aSopenharmony_ci# ============================================================================== 19cabdff1aSopenharmony_ci 20cabdff1aSopenharmony_ci# verified with Python 3.6.8 on CentOS 7.2 21cabdff1aSopenharmony_ciimport tensorflow as tf 22cabdff1aSopenharmony_ci 23cabdff1aSopenharmony_civisible_device_list = '0' # use , separator for more GPUs like '0, 1' 24cabdff1aSopenharmony_ciper_process_gpu_memory_fraction = 0.9 # avoid out of memory 25cabdff1aSopenharmony_ciintra_op_parallelism_threads = 2 # default in tensorflow 26cabdff1aSopenharmony_ciinter_op_parallelism_threads = 5 # default in tensorflow 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_cigpu_options = tf.compat.v1.GPUOptions( 29cabdff1aSopenharmony_ci per_process_gpu_memory_fraction = per_process_gpu_memory_fraction, 30cabdff1aSopenharmony_ci visible_device_list = visible_device_list, 31cabdff1aSopenharmony_ci allow_growth = True) 32cabdff1aSopenharmony_ci 33cabdff1aSopenharmony_ciconfig = tf.compat.v1.ConfigProto( 34cabdff1aSopenharmony_ci allow_soft_placement = True, 35cabdff1aSopenharmony_ci log_device_placement = False, 36cabdff1aSopenharmony_ci intra_op_parallelism_threads = intra_op_parallelism_threads, 37cabdff1aSopenharmony_ci inter_op_parallelism_threads = inter_op_parallelism_threads, 38cabdff1aSopenharmony_ci gpu_options = gpu_options) 39cabdff1aSopenharmony_ci 40cabdff1aSopenharmony_cis = config.SerializeToString() 41cabdff1aSopenharmony_ci# print(list(map(hex, s))) # print by json if need 42cabdff1aSopenharmony_ci 43cabdff1aSopenharmony_ciprint('a serialized protobuf string for TF_SetConfig, note the byte order is in normal order.') 44cabdff1aSopenharmony_cib = ''.join(format(b,'02x') for b in s) 45cabdff1aSopenharmony_ciprint('0x%s' % b) # print by hex format 46