问题:
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
网上搜索有说设置的label 数量和网络最后一层输出的数量不一致,但是我检查过了,我的不是这个问题。后来发现是pycharm中环境变量设置了用0卡,而代码中是os.environ["CUDA_VISIBLE_DEVICES"] = "1",导致显卡选择不一致
解决方法:
1.打开Run/Debug Configurations,在Environment variables右边点击…处
2.修改
os.environ["CUDA_VISIBLE_DEVICES"] = "0" #(原来是"1"报错,修改成"0"和环境变量一样)