RuntimeError: CUDA error: out of memory CUDA运行模式问题

【RuntimeError: CUDA error: out of memory.

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

For debugging consider passing CUDA_LAUNCH_BLOCKING=1.】CUDA运行模式问题

引入CUDA_LAUNCH_BLOCKING=1

‘’‘程序文件内容开头加入’‘’
import os

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

用cpu运行

把.to('cuda')变成.to('cpu')就能获得正常的track

你可能感兴趣的:(深度学习)