CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below m

import os
os.environ['CUDA_LAUNCH_BLOCKING'] = "1"

这样就可以准确指示哪一行出错了

基本是显存不够的原因
代码开头换一个gpu设备

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'

你可能感兴趣的:(pytorch,python)