ycq091044 / SafeDrug

IJCAI2021: Code for SafeDrug, MIMIC data processing, Medical code mapping
67 stars 16 forks source link

issue for DMNC #6

Closed liuhaifeng0212 closed 2 years ago

liuhaifeng0212 commented 2 years ago

Dear author, the DMNC source code has reported the following error, do you have any solutions?

Traceback (most recent call last): File "SafeDrug/src/DMNC.py", line 187, in main() File "SafeDrug/src/DMNC.py", line 154, in main loss.backward(retain_graph=True) File "D:\liuhaifeng\anaconda\envs\bibi\lib\site-packages\torch\tensor.py", line 185, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph) File "D:\liuhaifeng\anaconda\envs\bibi\lib\site-packages\torch\autograd__init__.py", line 127, in backward allow_unreachable=True) # allow_unreachable flag RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [128, 136]], which is output 0 of TBackward, is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

ycq091044 commented 2 years ago

Good question. I clone the repository and try to install it in a new environment. Then, I also get the same issue and am not sure how to fix it. Maybe the dnc package is updated. Please refer to the original DMNC repo: https://github.com/thaihungle/DMNC