Raise RuntimeError('DMA channel not idle')RuntimeError: DMA channel not idle

version : pynq-2.4 vivado 2018.3
here’s my code.I want to use an LSTM network for handwritten digit recognition. However, the error code seems to only recognize the first image, not the second image and beyond.

from pynq import Overlay, Xlnk
import pynq.lib.dma
overlay = Overlay(‘./mnist_lstm.bit’) # 加载Overlay
dma = overlay.axi_dma_0 # 定义DMA对象

import read_mnist as reader
test_images = reader.load_images(‘data/t10k-images.idx3-ubyte’) # 读取测试集图片
test_labels = reader.load_labels(‘data/t10k-labels.idx1-ubyte’) # 读取测试集标签

import random
import numpy as np
import matplotlib.pyplot as plt
IMG_NUM = 8
index = [0] * IMG_NUM #存储随机选择的图片的索引和图片数据
img = [0] * IMG_NUM
for i in range (IMG_NUM):
index[i] = random.randint(0, 10000)
img_dat = np.array(test_images[index[i]]).reshape(28, 28)
xlnk = Xlnk()
hw_time = [0] * IMG_NUM
in_buf = xlnk.cma_array(shape=(IMG_NUM,784))
out_buf = xlnk.cma_array(shape=(10000, 5), dtype = np.float32)
for i in range (IMG_NUM):
t0 = time.time()
in_buf[i]=test_images[index[i]]
dma.sendchannel.transfer(in_buf) # 调用DMA将待预测图片数据传输到IP核
dma.recvchannel.transfer(out_buf) # 调用DMA从IP核获取RNN的推导结果
#dma.sendchannel.wait() # 等待DMA发送完成
#dma.recvchannel.wait() # 等待DMA接收完成
t1 = time.time()
hw_time[i] = t1 - t0

out_list = np.array(out_buf[index[i]]).tolist()
max_indx = out_list.index(max(out_list))  # 推导结果向量的最大分量的下标即为预测结果
print('Result: %d,' % max_indx, 'time: {:1.6f}s'.format(hw_time[i]))

计算平均加速比

speed_up = [0.0] * IMG_NUM
for i in range (IMG_NUM):
speed_up[i] = sw_time[i] / hw_time[i]
print(‘Average speedup: {:.3f}’.format(sum(speed_up) / IMG_NUM))