Xingyu-Lin / mbpo_pytorch

A pytorch reprelication of the model-based reinforcement learning algorithm MBPO
148 stars 38 forks source link

Very slow runtime caused by `torch.autograd.set_detect_anomaly(True)` #8

Open mickelliu opened 2 years ago

mickelliu commented 2 years ago

I found this line that causes the extreme slowdown in runtime (thousands times slower). https://github.com/Xingyu-Lin/mbpo_pytorch/blob/fe3c78c474d188c16a026051b92f8a2e84fa9387/sac/sac.py#L11

Set to False returns to normal running speed, just a heads-up.

wxgkuaile commented 1 year ago

Will it not affect the final result if you do this? Set False.

mickelliu commented 1 year ago

Will it not affect the final result if you do this? Set False.

As for whether setting it to False will affect the final result, it typically should not, assuming there are no errors in your code. The anomaly detection is primarily a debugging tool. If your code runs correctly without producing nan or inf values during the backward pass (which would indicate an error), you should be able to safely disable anomaly detection without any impact on your results.