question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

windows10 mmdet inference gives error on mmcv-full v1.4.2 (py3.9, cu113, mmdet@master)

See original GitHub issue

steps to reproduce:

  • setup env:
conda create -n mmlab python=3.9 -y 
conda activate mmlab 

conda install pytorch=1.10.0 torchvision=0.11.1 cudatoolkit=11.3 -c pytorch -y
pip install mmcv-full==1.4.2 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html

pip install git+https://github.com/open-mmlab/mmdetection.git@master
  • confirm cuda and pytorch installation:
# Check Pytorch installation
import torch, torchvision
print(torch.__version__, torch.cuda.is_available())

# Check MMDetection installation
import mmdet
print(mmdet.__version__)

# Check mmcv installation
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
print(get_compiling_cuda_version())
print(get_compiler_version())
1.10.0 True
2.19.1
11.3
MSVC 192930137
  • confirm mmcv installation:
python -c "from mmcv.ops import RoIPool"

no error

  • clone mmdet repo for config files:
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
  • download mmdet weight:
import urllib.request
from pathlib import Path

def download_from_url(from_url: str, to_path: str):
    Path(to_path).parent.mkdir(parents=True, exist_ok=True)
    urllib.request.urlretrieve(
        from_url,
        to_path,
    )

from_url='https://download.openmmlab.com/mmdetection/v2.0/yolox/yolox_tiny_8x8_300e_coco/yolox_tiny_8x8_300e_coco_20211124_171234-b4047906.pth'
to_path='weight.pth'
download_from_url(from_url, to_path)
  • attempt to perform inference:
from mmdet.apis import inference_detector, init_detector

# Choose to use a config and initialize the detector
config = 'configs/yolox/yolox_tiny_8x8_300e_coco.py'
# Setup a checkpoint file to load
checkpoint = 'weight.pth'
# initialize the detector
model = init_detector(config, checkpoint, device='cuda:0')
# Use the detector to do inference
img = 'demo/demo.jpg'
result = inference_detector(model, img)

error:

load checkpoint from local path: weight.pth
C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\torch\functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ..\aten\src\ATen\native\TensorShape.cpp:2157.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmdet\models\dense_heads\yolox_head.py:284: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at  ..\torch\csrc\utils\tensor_new.cpp:201.)
  flatten_bboxes[..., :4] /= flatten_bboxes.new_tensor(
Traceback (most recent call last):
  File "C:\Users\xxx\dev\mmdetection\tools\perform_inference.py", line 11, in <module>
    result = inference_detector(model, img)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmdet\apis\inference.py", line 147, in inference_detector
    results = model(return_loss=False, rescale=True, **data)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmcv\runner\fp16_utils.py", line 98, in new_func
    return old_func(*args, **kwargs)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmdet\models\detectors\base.py", line 174, in forward
    return self.forward_test(img, img_metas, **kwargs)
  File "C:\Users\FxxxA\Miniconda3\envs\xxx\lib\site-packages\mmdet\models\detectors\base.py", line 147, in forward_test
    return self.simple_test(imgs[0], img_metas[0], **kwargs)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmdet\models\detectors\single_stage.py", line 102, in simple_test
    results_list = self.bbox_head.simple_test(
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmdet\models\dense_heads\base_dense_head.py", line 360, in simple_test
    return self.simple_test_bboxes(feats, img_metas, rescale=rescale)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmdet\models\dense_heads\dense_test_mixins.py", line 37, in simple_test_bboxes
    results_list = self.get_bboxes(
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmdet\models\dense_heads\yolox_head.py", line 294, in get_bboxes
    self._bboxes_nms(cls_scores, bboxes, score_factor, cfg))
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmdet\models\dense_heads\yolox_head.py", line 321, in _bboxes_nms
    dets, keep = batched_nms(bboxes, scores, labels, cfg.nms)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmcv\ops\nms.py", line 307, in batched_nms
    dets, keep = nms_op(boxes_for_nms, scores, **nms_cfg_)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmcv\utils\misc.py", line 340, in new_func
    output = old_func(*args, **kwargs)
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmcv\ops\nms.py", line 171, in nms
    inds = NMSop.apply(boxes, scores, iou_threshold, offset,
  File "C:\Users\xxx\Miniconda3\envs\xxx\lib\site-packages\mmcv\ops\nms.py", line 26, in forward
    inds = ext_module.nms(
RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
zhouzaidacommented, Dec 29, 2021

Yet, thank you very much for your feedback! We checked our logs and found we missed the compute capability 8_6. We will re-compile and upload the new packages in the next few days.

1reaction
fcakyoncommented, Dec 29, 2021

I found similar errors on mmcv+windows+compute capability 8_6 gpus: MMCV(1.4.1) + Windows + RTX3070: https://github.com/open-mmlab/mmtracking/issues/378 MMCV(1.4.0) + Windows + RTX3080: https://github.com/open-mmlab/mmcv/issues/1559 MMCV(1.4.0) + Windows + RTX3080: https://github.com/open-mmlab/mmaction2/issues/1308

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prerequisites — MMDetection 2.26.0 documentation
Case a: If you develop and run mmdet directly, install it from source: git clone https://github.com/open-mmlab/mmdetection.git cd mmdetection pip install -v -e ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found