师兄小课堂笔记系列:
GPU 显存占用高但是计算利用率低,基本上是因为读写效率低,TensorFlow是很难或很麻烦去监视读写时间的。
解决办法:将数据一次性读到内存中,在按照batch_file的idx来做计算处理。
监视其他代码运行时间的方法:
from time import time, perf_counter, sleep
def function1():
sleep(2)
def main():
start =time()
funtion1()
end=time()
print(end-start)
if __name__=='__main__':
main()
网友评论