RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead

Hi every one,
I have a Machine learning program, which I was working on it until 2 weeks ago. I ran it on google colab (GPU). after 2 weeks vacation I came back to it and ran without any change.
I got the error: RuntimeError: Can’t call numpy() on Variable that requires grad. Use var.detach().numpy() instead.
I changed the runtime to Local there is no change.
when I download the .jpynb on my PC and run it, there is no error. it seems that there have been some changes on google colab during these 2 weeks.
can you help me to solve this problem?

exact error text:

RuntimeError Traceback (most recent call last)
in ()
29 no_mive_criteria = 0.01,
30 SNR_Lin = SNRs_List_Linear[i],
—> 31 SNR_dB = SNRs_List_dB[i])
32
33 model_save_name = ‘Modelof{}QAMforSNR{}’.format(order,EbN0s_List_dB[i])

8 frames
/usr/local/lib/python3.6/dist-packages/torch/tensor.py in array(self, dtype)
490 def array(self, dtype=None):
491 if dtype is None:
–> 492 return self.numpy()
493 else:
494 return self.numpy().astype(dtype, copy=False)

RuntimeError: Can’t call numpy() on Variable that requires grad. Use var.detach().numpy() instead.

Could you check, if the line of code, which is raising this error, uses any numpy() calls?
If so, replace it with tensor.detach().numpy() as suggested in the error message.

This error was added a while ago to make sure the user is aware, that Autograd won’t be able to track the numpy operations.

In whole my code there is no call for numpy()

is there any way to ignore this error?

You could use a try block to get the exception, but it wouldn’t ignore the error and the operation won’t be successful.

What do you think about successful running on PC and getting this error on google colab

The versions might be different. You could check them via print(torch.__version__).

yes mine is 1.4 and in google colab is 1.5.0+cu101