Megvii-BaseDetection / Megvii-BaseDetection/YOLOX

CPU evaluation

Open
#1,464 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

I am trying to evaluate the models provided in the repo on the COCO dataset using the tools/eval.py and switched model.load to device='cpu'

But there are some functions in "coco_evaluator.py" that use cuda, is there any way that I can evaluate the model on a CPU only machine?

This is the error that I am getting

2022-08-04 23:05:34 | ERROR | yolox.core.launch:98 - An error has been caught in function 'launch', process 'MainProcess' (50200), thread 'MainThread' (4461495808):
Traceback (most recent call last):

File "tools/eval.py", line 214, in
launch(
└ <function launch at 0x7f789b6f1550>

File "/Users/srisiddarthchakaravarthy/Desktop/SID/GSOC_22/Work/Models/YOLOX/YOLOX_main/tools/yolox/core/launch.py", line 98, in launch
main_func(*args)
│ └ (╒═══════════════════╤══════════════════════════════════════════════════════════════════════════════════════════════╕
│ │ keys ...
└ <function main at 0x7f789c54d5e0>

File "tools/eval.py", line 195, in main
*_, summary = evaluator.evaluate(
│ └ <function COCOEvaluator.evaluate at 0x7f789d1e9670>
└ <yolox.evaluators.coco_evaluator.COCOEvaluator object at 0x7f789d218fa0>

File "/Users/srisiddarthchakaravarthy/Desktop/SID/GSOC_22/Work/Models/YOLOX/YOLOX_main/tools/yolox/evaluators/coco_evaluator.py", line 162, in evaluate
imgs = imgs.type(tensor_type)
│ │ └ <class 'torch.cuda.HalfTensor'>
│ └ <method 'type' of 'torch._C._TensorBase' objects>
└ tensor([[[[ 77., 64., 57., ..., 14., 12., 15.],
[ 68., 73., 52., ..., 13., 10., 9.],
[ 68., ...

RuntimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason. The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols. You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tools/eval.py and yolox/evaluators/coco_evaluator.py, especially the evaluate path around line 162 where imgs is converted to torch.cuda.HalfTensor. Compare that path with the model.load device='cpu' setting and trace the evaluator's device selection. Done means COCO evaluation completes on a CPU-only machine without initializing CUDA.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.