Tag Archives: RuntimeError

[Solved] RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place

yolov5 Error: RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place

Solution:
In model/yolo.py file

        for mi, s in zip(m.m, m.stride):  # from
            b = mi.bias.view(m.na, -1)  # conv.bias(255) to (3,85)
            b[:, 4] += math.log(8/(640/s) ** 2)  # obj (8 objects per 640 image)
            b[:, 5:] += math.log(0.6/(m.nc - 0.99)) if cf is None else torch.log(cf/cf.sum())  # cls
            mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)

Add with torch.no_grad(): as follows

        for mi, s in zip(m.m, m.stride):  # from
            b = mi.bias.view(m.na, -1)  # conv.bias(255) to (3,85)
            with torch.no_grad():
                b[:, 4] += math.log(8/(640/s) ** 2)  # obj (8 objects per 640 image)
                b[:, 5:] += math.log(0.6/(m.nc - 0.99)) if cf is None else torch.log(cf/cf.sum())  # cls
            mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)

——> The root cause is to add:

with torch.no_grad():

[Solved] Python Error: asyncio RuntimeError: This event loop is already running

In case of an error, the following diagram is given:

Solution:

# download nest_asyncio
pip3 install nest_asyncio

Add the following two lines at the beginning of the asynchronous collaboration code, or in the code:

import nest_asyncio

nest_asyncio.apply()

After consulting the data, it is found that using the Jupiter notebook environment, it is connected to the IPython kernel, and the IPython kernel itself runs on the event loop, while asyncio does not allow nesting of its event loop, so the error message as shown in the above figure will appear.

nest_asyncio exists as a patch for asynchronous operations.

RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /opt/conda/conda-bld/

problem

RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /opt/conda/conda-bld/

solve

This problem is likely to be your CUDA number is wrong
for example, the variables you set use GPUs 2 and 3, but in fact you only have two GPUs 0 and 1, which will lead to this error.

Using postman Test Django Interface error: RuntimeError:You called this URL via POST,but the URL doesn‘t end in a slash

1. Access interface

Using the postman provider

2. Error reporting:

RuntimeError:You called this URL via POST,but the URL doesn’t end in a slash and you have APPEND_ SLASH set. Django can’t redirect to the slash URL while maintaining POST data.

3. Solution:

In fact, two methods have been suggested in the error report

Method 1: add a at the end of the URL/

http:10.192.171.128:8000/ops/rbac/group/distribute

Method 2: set append in settings_ SLASH=False

RuntimeError: ONNX export failed: Couldn‘t export operator aten::upsample_bilinear2d

pth –> Onnx error

RuntimeError: ONNX export failed: Couldn't export operator aten::upsample_bilinear2d

Solution:

   torch.onnx.export(model, input, onnx_path, verbose=True, input_names=input_names, output_names=output_names)
#add:opset_version=11
   torch.onnx.export(model, input, onnx_path, verbose=True, input_names=input_names, output_names=output_names, opset_version=11)

linux ubuntu pip search Fault: <Fault -32500: “RuntimeError: PyPI‘s XMLRPC API is currently disab

Pip search does not work properly. The following error is reported
Complete error report:

$ pip search absl-py --proxy http://10.xxx.xxx.xxx:8080 --trusted-host=pypi.python.org
/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py:860: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/search.py", line 45, in run
    pypi_hits = self.search(query, options)
  File "/usr/lib/python2.7/dist-packages/pip/commands/search.py", line 62, in search
    hits = pypi.search({'name': query, 'summary': query}, 'or')
  File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 778, in request
    return self.parse_response(response.raw)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1493, in parse_response
    return u.close()
  File "/usr/lib/python2.7/xmlrpclib.py", line 800, in close
    raise Fault(**self._stack[0])
Fault: <Fault -32500: "RuntimeError: PyPI's XMLRPC API is currently disabled due to unmanageable load and will be deprecated in the near future. See https://status.python.org/ for more information.">

Because the website is temporarily turned off this feature, see: https://status.python.org/