Open fengchuibeixiang opened 10 months ago
Sometimes I encountered the same problem. Empirically, replacing NaN values in cost matrix with a large number alleviates this but cannot completely solve it.
# Reference: https://github.com/SHI-Labs/OneFormer/blob/main/oneformer/modeling/matcher.py
def linear_sum_assignment_with_nan(cost_matrix):
cost_matrix = np.asarray(cost_matrix)
nan = np.isnan(cost_matrix).any()
nan_all = np.isnan(cost_matrix).all()
empty = cost_matrix.size == 0
if not empty:
if nan_all:
print('Matrix contains all NaN values!')
elif nan:
print('Matrix contains NaN values!')
if nan_all:
cost_matrix = np.empty(shape=(0, 0))
elif nan:
cost_matrix[np.isnan(cost_matrix)] = 100
return linear_sum_assignment(cost_matrix)
添加以上Nan处理后,loss还是遇到Nan问题。这个应该怎么处理?
我添加该函数后也并没有解决这个问题。 我有个疑问,有没有可能是我只用了单卡训练的原因,之前用实验室的双卡机器可以正常训练。
我添加该函数后也并没有解决这个问题。 我有个疑问,有没有可能是我只用了单卡训练的原因,之前用实验室的双卡机器可以正常训练。
我一直用的四卡偶尔也会有该问题,有时候微调一些参数甚至随机种子就没有这个问题,比较玄学,训练确实存在不稳定性
添加以上Nan处理后,loss还是遇到Nan问题。这个应该怎么处理?
请问有解决这个问题吗 难道其他朋友都没遇到嘛。。 我每次跑都会遇到这个问题,在考虑把这种nan的数据筛掉
我换了一张卡,nan就全都没掉了
我换了一张卡,nan就全都没掉了 是不是显卡比较老,不支持混合精度训练,把config里面的混合精度AMP设置为False试试,我是因为这个原因
我换了一张卡,nan就全都没掉了 是不是显卡比较老,不支持混合精度训练,把config里面的混合精度AMP设置为False试试,我是因为这个原因
我把config里面的混合精度AMP设置为False,依然报这个错误(哭了)