jbwang1997 / OBBDetection

OBBDetection is an oriented object detection library, which is based on MMdetection.
Apache License 2.0
525 stars 112 forks source link

RuntimeError #12

Closed hust-lidelong closed 2 years ago

hust-lidelong commented 2 years ago

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug When I try to run [Faster R-CNN OBB], it occurs a problem. RuntimeError: radix_sort: failed on 1st step: cudaErrorInvalidDevice: invalid device ordinal. But when I run [RetinaNet OBB], there is no problem.

Reproduction

  1. What command or script did you run?
    CUDA_VISIBLE_DEVICES=0 python tools/train.py configs/obb/faster_rcnn_obb/faster_rcnn_obb_r50_fpn_1x_dota10.py
  2. Did you make any modifications on the code or config? Did you understand what you have modified?
  3. What dataset did you use? DOTA1.0

Environment

  1. Please run python mmdet/utils/collect_env.py to collect necessary environment infomation and paste it here. sys.platform: linux Python: 3.8.10 | packaged by conda-forge | (default, May 11 2021, 07:01:05) [GCC 9.3.0] CUDA available: True CUDA_HOME: /usr/local/cuda-11.1 NVCC: Build cuda_11.1.TC455_06.29190527_0 GPU 0,1: NVIDIA GeForce RTX 2080 Ti GCC: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 PyTorch: 1.8.0 PyTorch compiling details: PyTorch built with:
    • GCC 7.3
    • C++ Version: 201402
    • Intel(R) oneAPI Math Kernel Library Version 2021.3-Product Build 20210617 for Intel(R) 64 architecture applications
    • Intel(R) MKL-DNN v1.7.0 (Git Hash 7aed236906b1f7a05c0917e5257a1af05e9ff683)
    • OpenMP 201511 (a.k.a. OpenMP 4.5)
    • NNPACK is enabled
    • CPU capability usage: AVX2
    • CUDA Runtime 11.1
    • NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
    • CuDNN 8.0.5
    • Magma 2.5.2
    • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.1, CUDNN_VERSION=8.0.5, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.8.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON,

TorchVision: 0.9.0 OpenCV: 4.5.3 MMCV: 0.6.2 MMDetection: 2.2.0+89243c8 MMDetection Compiler: GCC 9.3 MMDetection CUDA Compiler: 11.1

  1. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback If applicable, paste the error trackback here.

2021-08-27 21:26:53,932 - mmdet - INFO - workflow: [('train', 1)], max: 12 epochs
Traceback (most recent call last):
  File "tools/train.py", line 153, in <module>
    main()
  File "tools/train.py", line 142, in main
    train_detector(
  File "/home/lidelong/data/code/OBBDetection/mmdet/apis/train.py", line 129, in train_detector
    runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
  File "/home/lidelong/miniconda3/envs/OBBDetection/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 122, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/home/lidelong/miniconda3/envs/OBBDetection/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 31, in train
    outputs = self.model.train_step(data_batch, self.optimizer,
  File "/home/lidelong/miniconda3/envs/OBBDetection/lib/python3.8/site-packages/mmcv/parallel/data_parallel.py", line 31, in train_step
    return self.module.train_step(*inputs[0], **kwargs[0])
  File "/home/lidelong/data/code/OBBDetection/mmdet/models/detectors/base.py", line 237, in train_step
    losses = self(**data)
  File "/home/lidelong/miniconda3/envs/OBBDetection/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/lidelong/data/code/OBBDetection/mmdet/core/fp16/decorators.py", line 51, in new_func
    return old_func(*args, **kwargs)
  File "/home/lidelong/data/code/OBBDetection/mmdet/models/detectors/base.py", line 172, in forward
    return self.forward_train(img, img_metas, **kwargs)
  File "/home/lidelong/data/code/OBBDetection/mmdet/models/detectors/obb/obb_two_stage.py", line 167, in forward_train
    rpn_losses, proposal_list = self.rpn_head.forward_train(
  File "/home/lidelong/data/code/OBBDetection/mmdet/models/dense_heads/base_dense_head.py", line 54, in forward_train
    losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore)
  File "/home/lidelong/data/code/OBBDetection/mmdet/models/dense_heads/rpn_head.py", line 69, in loss
    losses = super(RPNHead, self).loss(
  File "/home/lidelong/data/code/OBBDetection/mmdet/core/fp16/decorators.py", line 131, in new_func
    return old_func(*args, **kwargs)
  File "/home/lidelong/data/code/OBBDetection/mmdet/models/dense_heads/anchor_head.py", line 459, in loss
    cls_reg_targets = self.get_targets(
  File "/home/lidelong/data/code/OBBDetection/mmdet/models/dense_heads/anchor_head.py", line 342, in get_targets
    results = multi_apply(
  File "/home/lidelong/data/code/OBBDetection/mmdet/core/utils/misc.py", line 54, in multi_apply
    return tuple(map(list, zip(*map_results)))
  File "/home/lidelong/data/code/OBBDetection/mmdet/models/dense_heads/anchor_head.py", line 229, in _get_targets_single
    sampling_result = self.sampler.sample(assign_result, anchors,
  File "/home/lidelong/data/code/OBBDetection/mmdet/core/bbox/samplers/base_sampler.py", line 95, in sample
    neg_inds = self.neg_sampler._sample_neg(
  File "/home/lidelong/data/code/OBBDetection/mmdet/core/bbox/samplers/random_sampler.py", line 75, in _sample_neg
    return self.random_choice(neg_inds, num_expected)
  File "/home/lidelong/data/code/OBBDetection/mmdet/core/bbox/samplers/random_sampler.py", line 51, in random_choice
    perm = torch.randperm(gallery.numel(), device=gallery.device)[:num]
RuntimeError: radix_sort: failed on 1st step: cudaErrorInvalidDevice: invalid device ordinal

Bug fix If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

jbwang1997 commented 2 years ago

It seems a bug of pytorch-1.8.0+CUDA11.1 issues#54245.

I recommend trying different visions of PyTorch.

liufeinuaa commented 2 years ago

i have some bug

liufeinuaa commented 2 years ago

you can try using the newest pytorch version pytorch 1.9.0 + cuda 11.1, it seem worked right in my PC (GPU is 3080ti)

xwhkkk commented 1 year ago

you can try using the newest pytorch version pytorch 1.9.0 + cuda 11.1, it seem worked right in my PC (GPU is 3080ti)

hello, I encountered the same bug, and I have tried the PyTorch 1.9.0+cuda 11.1, but it has the following error. Could you give me some suggestions? import_errror