mmdeploy icon indicating copy to clipboard operation
mmdeploy copied to clipboard

Device "cuda" not found,failed to create classifier

Open 6sz opened this issue 11 months ago • 1 comments

Checklist

  • [X] I have searched related issues but cannot get the expected help.
  • [X] 2. I have read the FAQ documentation but cannot get the expected help.
  • [X] 3. The bug has not been fixed in the latest version.

Describe the bug

The model is resnet and has been converted to tensorrt format (end2end. engine). Using the inference API of Model Converter, it can execute normally and return inference results.

` META INFORMATION img_shape: (224, 224) scale_factor: (1.1428571428571428, 1.1428571428571428) img_path: /home/lsz/Documents/code/mmdeploy/demo/art.png ori_shape: (224, 224) num_classes: 4

DATA FIELDS pred_label: tensor([0], device='cuda:0') pred_score: tensor([9.9993e-01, 4.7808e-05, 1.6962e-05, 4.2211e-06], device='cuda:0')

) at 0x7ff7f6b4c370>]

`

When using the SDK, it improves the device "cuda" not found

` [error] [common.cpp:67] Device "cuda" not found Traceback (most recent call last): File "inference_V2.py", line 34, in main() File "inference_V2.py", line 27, in main classifier = Classifier(model_path=args.model_path, device_name=args.device_name, device_id=0) RuntimeError: failed to create classifier

`

Reproduction

python ./demo/python/image_classification.py
cuda
./work_dir/resnet18_cp1020_coslr_cuda
./demo/art.png

or wget https://github.com/open-mmlab/mmdeploy/releases/download/v1.3.1/mmdeploy-1.3.1-linux-x86_64-cuda11.8.tar.gz tar xf mmdeploy-1.3.1-linux-x86_64-cuda11.8

cd mmdeploy-1.3.1-linux-x86_64-cuda11.8

run python demo

python example/python/image_classification.py cuda ../mmdeploy/work_dir/resnet18_cp1020_coslr_cuda ../mmdeploy/demo/demo.jpg

Environment

03/08 10:19:25 - mmengine - INFO - **********Environmental information**********
03/08 10:19:26 - mmengine - INFO - sys.platform: linux
03/08 10:19:26 - mmengine - INFO - Python: 3.8.16 | packaged by conda-forge | (default, Feb  1 2023, 16:01:55) [GCC 11.3.0]
03/08 10:19:26 - mmengine - INFO - CUDA available: True
03/08 10:19:26 - mmengine - INFO - numpy_random_seed: 2147483648
03/08 10:19:26 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 4090
03/08 10:19:26 - mmengine - INFO - CUDA_HOME: /usr/local/cuda-11.7
03/08 10:19:26 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.7, V11.7.64
03/08 10:19:26 - mmengine - INFO - GCC: gcc (Ubuntu 7.5.0-6ubuntu2) 7.5.0
03/08 10:19:26 - mmengine - INFO - PyTorch: 1.13.1

03/08 10:19:26 - mmengine - INFO - TorchVision: 0.14.1
03/08 10:19:26 - mmengine - INFO - OpenCV: 4.7.0
03/08 10:19:26 - mmengine - INFO - MMEngine: 0.7.3
03/08 10:19:26 - mmengine - INFO - MMCV: 2.0.1
03/08 10:19:26 - mmengine - INFO - MMCV Compiler: GCC 9.3
03/08 10:19:26 - mmengine - INFO - MMCV CUDA Compiler: 11.7
03/08 10:19:26 - mmengine - INFO - MMDeploy: 1.3.1+bc75c9d
03/08 10:19:26 - mmengine - INFO - 

03/08 10:19:26 - mmengine - INFO - **********Backend information**********
03/08 10:19:26 - mmengine - INFO - tensorrt:    8.5.1.7
03/08 10:19:26 - mmengine - INFO - tensorrt custom ops: NotAvailable
03/08 10:19:26 - mmengine - INFO - ONNXRuntime: 1.8.1
03/08 10:19:26 - mmengine - INFO - ONNXRuntime-gpu:     1.8.1
03/08 10:19:26 - mmengine - INFO - ONNXRuntime custom ops:      NotAvailable
03/08 10:19:26 - mmengine - INFO - pplnn:       None
03/08 10:19:26 - mmengine - INFO - ncnn:        None
03/08 10:19:26 - mmengine - INFO - snpe:        None
03/08 10:19:26 - mmengine - INFO - openvino:    None
03/08 10:19:26 - mmengine - INFO - torchscript: 1.13.1
03/08 10:19:26 - mmengine - INFO - torchscript custom ops:      NotAvailable
03/08 10:19:26 - mmengine - INFO - rknn-toolkit:        None
03/08 10:19:26 - mmengine - INFO - rknn-toolkit2:       None
03/08 10:19:26 - mmengine - INFO - ascend:      None
03/08 10:19:26 - mmengine - INFO - coreml:      None
03/08 10:19:26 - mmengine - INFO - tvm: None
03/08 10:19:26 - mmengine - INFO - vacc:        None
03/08 10:19:26 - mmengine - INFO - 

03/08 10:19:26 - mmengine - INFO - **********Codebase information**********
03/08 10:19:26 - mmengine - INFO - mmdet:       3.3.0
03/08 10:19:26 - mmengine - INFO - mmseg:       None
03/08 10:19:26 - mmengine - INFO - mmpretrain:  1.0.0rc7
03/08 10:19:26 - mmengine - INFO - mmocr:       None
03/08 10:19:26 - mmengine - INFO - mmagic:      None
03/08 10:19:26 - mmengine - INFO - mmdet3d:     None
03/08 10:19:26 - mmengine - INFO - mmpose:      None
03/08 10:19:26 - mmengine - INFO - mmrotate:    None
03/08 10:19:26 - mmengine - INFO - mmaction:    None
03/08 10:19:26 - mmengine - INFO - mmrazor:     None
03/08 10:19:26 - mmengine - INFO - mmyolo:      None

Error traceback

loading libmmdeploy_ort_net.so ...
[2024-03-08 10:20:23.783] [mmdeploy] [info] [model.cpp:35] [DirectoryModel] Load model: "./work_dir/resnet18_cp1020_coslr_cuda"
[2024-03-08 10:20:23.783] [mmdeploy] [error] [common.cpp:67] Device "cuda" not found
Traceback (most recent call last):
  File "inference_V2.py", line 34, in <module>
    main()
  File "inference_V2.py", line 27, in main
    classifier = Classifier(model_path=args.model_path, device_name=args.device_name, device_id=0)
RuntimeError: failed to create classifier

6sz avatar Mar 08 '24 02:03 6sz

Same issue

NicDionne avatar Aug 05 '24 15:08 NicDionne