jiecaoyu / XNOR-Net-PyTorch

PyTorch Implementation of XNOR-Net
472 stars 119 forks source link

Run with PyTorch 11.3 #129

Closed gobenavides closed 1 year ago

gobenavides commented 1 year ago

I am getting an error when trying to run MNIST/main.py

Traceback (most recent call last):

  File "C:\Users\saft_\miniconda3\envs\XNOR\lib\site-packages\spyder_kernels\py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "c:\users\saft_\machinelearning\xnor-net-pytorch\mnist\maincopy.py", line 189, in <module>
    train(epoch)

  File "c:\users\saft_\machinelearning\xnor-net-pytorch\mnist\maincopy.py", line 39, in train
    output = model(data)

  File "C:\Users\saft_\miniconda3\envs\XNOR\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)

  File "C:\Users\saft_\MachineLearning\XNOR-Net-PyTorch\MNIST\models\LeNet_5.py", line 93, in forward
    x = self.bin_conv2(x)

  File "C:\Users\saft_\miniconda3\envs\XNOR\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)

  File "C:\Users\saft_\MachineLearning\XNOR-Net-PyTorch\MNIST\models\LeNet_5.py", line 53, in forward
    x = BinActive()(x)

  File "C:\Users\saft_\miniconda3\envs\XNOR\lib\site-packages\torch\autograd\function.py", line 330, in __call__
    raise RuntimeError(

RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)

Does anyone know how to solve this issue? I have Python 3.9 with PyTorch 11.3 and CUDA 11.7

gobenavides commented 1 year ago

I fixed this issue in my fork https://github.com/gobenavides/XNOR-Net-PyTorch, commit ad09a15e2bffbd18ba8042d36d99bcdfa3fd4542