How to use pb file to surpport GPU

Since my cuda version was 10.1, i can’t use deepspeech-gpu, so i want create a class that can parse pb file to the model, and accept single audio file and transform it to text, so do you have some examples to learn? thx
below are my codes

from **future** import absolute_import, division, print_function
import io
import os
import sys
import tensorflow.compat.v1 as tfv1
from util.config import Config, initialize_globals
from util.flags import create_flags, FLAGS

LOG_LEVEL_INDEX = sys.argv.index('--log_level') + 1 if '--log_level' in sys.argv else 0
DESIRED_LOG_LEVEL = sys.argv[LOG_LEVEL_INDEX] if 0 < LOG_LEVEL_INDEX < len(sys.argv) else '3'
os.environ['TF_CPP_MIN_LOG_LEVEL'] = DESIRED_LOG_LEVEL

tfv1.logging.set_verbosity({
'0': tfv1.logging.DEBUG,
'1': tfv1.logging.INFO,
'2': tfv1.logging.WARN,
'3': tfv1.logging.ERROR
}.get(DESIRED_LOG_LEVEL))

from util.helpers import check_ctcdecoder_version
from DeepSpeech import create_model, create_overlapping_windows
from util.feeding import *
from util.sample_collections import samples_from_file
os.environ["CUDA_VISIBLE_DEVICES"] = '0'

check_ctcdecoder_version()

def wav_2_feas(wav_files): # wav -> mfcc feature
    features, features_len = audiofile_to_features(wav_files, train_phase=False)
    shape = tf.shape(features)
    features = tf.reshape(features, [-1, shape[0], shape[1]])
    return features, features_len

class DS_detector(object):
    def __init__ (self, model_path):
    self._graph = tf.Graph()
    with self._graph.as_default():
    self._graph, self._sess = self.init_model(model_path)


def get_logits(self, wav_files):
    feas, feas_len = wav_2_feas(wav_files)  
    no_dropout = [None] * 6
    self.logits, _ = create_model(batch_x=feas,
                                  batch_size=1,
                                  seq_length=feas_len,
                                  dropout=no_dropout)
    print(np.shape(self.logits))
    return self._sess.run(self.logits)

def init_model(self, model_path):
    config = tf.ConfigProto()
    config.gpu_options.per_process_gpu_memory_fraction = 0.8
    compute_graph = tf.Graph()
    compute_graph.as_default()
    sess = tf.Session(config=config)
    with tf.gfile.GFile(model_path, 'rb') as fid:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(fid.read())
        tf.import_graph_def(graph_def, name='')
    return (compute_graph, sess)


def test():
    create_flags()
    initialize_globals()
    wav_files = './ch_datas/clips/common_voice_zh-CN_18524189.wav'
    model_path = '/Data/checkpoints/output_graph.pb'
    ds_detector = DS_detector(model_path)
    logits = ds_detector.get_logits(wav_files)
    print(logits)

if __name__ ==' __main__ ':
    test()

and now i have an error says:

Traceback (most recent call last):
File "/Data/DeepSpeech/ds_use_pb.py", line 114, in
test()
File "/Data/DeepSpeech/ds_use_pb.py", line 110, in test
logits = ds_detector.get_logits(wav_files)
File "/Data/DeepSpeech/ds_use_pb.py", line 72, in get_logits
dropout=no_dropout)
File "/Data/DeepSpeech/DeepSpeech.py", line 206, in create_model
output, output_state = rnn_impl(layer_3, seq_length, previous_state, reuse)
File "/Data/DeepSpeech/DeepSpeech.py", line 103, in rnn_impl_lstmblockfusedcell
initial_state=previous_state)
File "/home/lingck/.conda/envs/deepspeech/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 537, in **call**
outputs = super(Layer, self). **call** (inputs, *args, **kwargs)
File "/home/lingck/.conda/envs/deepspeech/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 634, in **call**
outputs = call_fn(inputs, *args, **kwargs)
File "/home/lingck/.conda/envs/deepspeech/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py", line 149, in wrapper
raise e.ag_error_metadata.to_exception(type(e))
ValueError: in converted code:
relative to /home/lingck/.conda/envs/deepspeech/lib/python3.6/site-packages/tensorflow:
contrib/rnn/python/ops/lstm_ops.py:554 call
[1, 0])
python/ops/array_ops.py:1739 transpose
ret = transpose_fn(a, perm, name=name)
python/ops/gen_array_ops.py:11046 transpose
"Transpose", x=x, perm=perm, name=name)
python/framework/op_def_library.py:788 _apply_op_helper
op_def=op_def)
python/util/deprecation.py:507 new_func
return func(*args, **kwargs)
python/framework/ops.py:3616 create_op
op_def=op_def)
python/framework/ops.py:2027 **init**
control_input_ops)
python/framework/ops.py:1867 _create_c_op
raise ValueError(str(e))
ValueError: Dimension must be 1 but is 2 for 'cudnn_lstm/rnn/multi_rnn_cell/cell_0/cudnn_compatible_lstm_cell/transpose' (op: 'Transpose') with input shapes: [?], [2].

can you help me?

You need to re-implement the logic from native_client/deepspeech.cc. That’s not a good idea.

Either use a local 10.0 install (download tar, extract, set LD_LIBRARY_PATH) or just rebuild deepspeech-gpu against CUDA 10.1.