open-mmlab / mmtracking

OpenMMLab Video Perception Toolbox. It supports Video Object Detection (VID), Multiple Object Tracking (MOT), Single Object Tracking (SOT), Video Instance Segmentation (VIS) with a unified framework.
https://mmtracking.readthedocs.io/en/latest/
Apache License 2.0
3.51k stars 587 forks source link

NameError: name 'get_device' is not defined #788

Open ouyanglinke opened 1 year ago

ouyanglinke commented 1 year 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 I was trying to run the training section using the example code of MOT17 (just follow all the steps shows in the homepage), but it always got this NameError.

Reproduction

  1. What command or script did you run?
srun -p bigdata_s2 --quotatype=auto --gres=gpu:1 python tools/train.py configs/det/faster-rcnn_r50_fpn_4e_mot17-half.py
  1. Did you make any modifications on the code or config? Did you understand what you have modified? No.

  2. What dataset did you use and what task did you run? MOT17, multiple-object tracking.

Environment

  1. Please run python mmtrack/utils/collect_env.py to collect necessary environment information and paste it here.
    
    sys.platform: linux
    Python: 3.8.13 (default, Mar 28 2022, 11:38:47) [GCC 7.5.0]
    CUDA available: False
    GCC: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
    PyTorch: 1.7.1
    PyTorch compiling details: PyTorch built with:
    - GCC 7.3
    - C++ Version: 201402
    - Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
    - Intel(R) MKL-DNN v1.6.0 (Git Hash 5ef631a030a6f73131c77892041042805a06064f)
    - OpenMP 201511 (a.k.a. OpenMP 4.5)
    - NNPACK is enabled
    - CPU capability usage: AVX2
    - Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -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, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=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.8.2 OpenCV: 4.6.0 MMCV: 1.6.1 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 11.0 MMTracking: 0.14.0+b1679f9


3. 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.

```none
Traceback (most recent call last):
  File "tools/train.py", line 215, in <module>
    main()
  File "tools/train.py", line 167, in main
    cfg.device = get_device()           # adding from mmdet
NameError: name 'get_device' is not defined
srun: error: SH-IDC1-10-140-24-123: task 0: Exited with exit code 1

Bug fix I found an issue in mmdet repo: https://github.com/open-mmlab/mmtracking/issues/540, so I added three lines in mmtracking/tools/train.py, which works for me:

 # line 15
from mmdet.utils import get_device   

# line 162
meta['config'] = cfg.pretty_text            

 # line 168
cfg.device = get_device()                    
dyhBUPT commented 1 year ago

Thanks for your report! We'll appreciate it if you can raise a PR to fix the bug~

ouyanglinke commented 1 year ago

The PR has been raised: https://github.com/open-mmlab/mmtracking/pull/793

dyhBUPT commented 1 year ago

The PR has been raised: #793

Thanks for your contributions, we'll check it.