Open SP-FA opened 10 months ago
Hi, this error is because pytorch 2.0 will set set_to_none=True by default, while it is not desired in our code. You should add set_to_none=False or replace the optimizer.zero_grad() to the following to keep compatibility for different pytorch versions.
# For backward compatibility
# PyTorch 1.7 introduced zero_grad(set_to_none=False)
# PyTorch 2.0 changed set_to_none=True
if "set_to_none" in inspect.signature(optimizer.zero_grad).parameters:
optimizer.zero_grad(set_to_none=False)
else:
optimizer.zero_grad()
I'm getting the following error when I run
python dreamplace/placer.py test/ispd2005/adaptec1.json
on thecircuit_trainin
branch:But it can running successfully on the
master
branch.I add the parameter
set_to_none=False
atNonLinearPlace.py
L277 and then it can finish without issues. I want to know if this is the correct method of correction. Is it?My environment is: Ubuntu 22.0.4 Python 3.9.18 PyTorch 2.0.1