1 min read

PyTorch DataLoader 速度极慢的可能解决方案

Table of Contents

table of content

问题

使用Pytorch的DataLoader时,速度极慢,GPU完全吃不满,CPU占用率也不高。设置num_workers以及尝试拆分文件之后加载(原数据~50G)均无效。

实测的可用解决方案

  1. os.environ["KMP_AFFINITY"] = "disabled"export KMP_AFFINITY=disabled

  2. conda install 'llvm-openmp<16'

ref

https://github.com/pytorch/pytorch/issues/99625 https://github.com/pytorch/pytorch/issues/101850 https://github.com/pytorch/pytorch/issues/102494