Could not run '_caffe2::DistributeFpnProposals' with arguments from the 'CUDATensorId' backend. '
See original GitHub issue- what changes you made (
git diff
) or what code you wrote i write a export_model.py
from detectron2.export.api import add_export_config, export_caffe2_model, Caffe2Model
from detectron2.config import get_cfg
from detectron2.modeling import build_model
from detectron2.engine.defaults import DefaultPredictor
from detectron2.data.detection_utils import read_image
import detectron2.data.transforms as T
import torch
import cv2
import os
def prepareConfig(testThreshold=0.8):
# cfg
config_file = 'configs/PascalVOC-Detection/faster_rcnn_R_50_FPN.yaml'
cfg = get_cfg()
cfg.merge_from_file(config_file)
# Set score_threshold for builtin models
cfg.MODEL.RETINANET.SCORE_THRESH_TEST = testThreshold
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = testThreshold
cfg.MODEL.PANOPTIC_FPN.COMBINE.INSTANCES_CONFIDENCE_THRESH = testThreshold
cfg.MODEL.WEIGHTS = os.path.join('output/R50_FPN', 'model_final.pth')
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 20
return cfg
cfg = prepareConfig()
cfg = add_export_config(cfg)
model = build_model(cfg)
img = read_image('1008.bmp', format='BGR')
height, width = img.shape[:2]
transform_gen = T.ResizeShortestEdge(
[cfg.INPUT.MIN_SIZE_TEST, cfg.INPUT.MIN_SIZE_TEST], cfg.INPUT.MAX_SIZE_TEST
)
image = transform_gen.get_transform(img).apply_image(img)
image = torch.as_tensor(image.astype("float32").transpose(2, 0, 1))
inputs = {'image':image, 'height':height, 'width':width}
c2_model = export_caffe2_model(cfg, model, [inputs])
c2_model.save_protobuf('./c2res')
- what exact command you run:
python demo/export_model.py
- what you observed (including the full logs):
net_drawer will not run correctly. Please install the correct dependencies.
D:\Anaconda3\lib\site-packages\pycocotools\coco.py:49: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
The backend was *originally* set to 'Qt5Agg' by the following code:
File "demo/export_model.py", line 1, in <module>
from detectron2.export.api import add_export_config, export_caffe2_model, Caffe2Model
File "d:\algorithmlibrary\detectron2-master\detectron2\export\__init__.py", line 3, in <module>
from .api import *
File "d:\algorithmlibrary\detectron2-master\detectron2\export\api.py", line 10, in <module>
from .caffe2_inference import ProtobufDetectionModel
File "d:\algorithmlibrary\detectron2-master\detectron2\export\caffe2_inference.py", line 11, in <module>
from detectron2.export.caffe2_modeling import convert_batched_inputs_to_c2_format
File "d:\algorithmlibrary\detectron2-master\detectron2\export\caffe2_modeling.py", line 9, in <module>
from detectron2.modeling import meta_arch
File "d:\algorithmlibrary\detectron2-master\detectron2\modeling\__init__.py", line 17, in <module>
from .meta_arch import (
File "d:\algorithmlibrary\detectron2-master\detectron2\modeling\meta_arch\__init__.py", line 9, in <module>
from .rcnn import GeneralizedRCNN, ProposalNetwork
File "d:\algorithmlibrary\detectron2-master\detectron2\modeling\meta_arch\rcnn.py", line 10, in <module>
from detectron2.utils.visualizer import Visualizer
File "d:\algorithmlibrary\detectron2-master\detectron2\utils\visualizer.py", line 13, in <module>
from matplotlib.backends.backend_agg import FigureCanvasAgg
File "D:\Anaconda3\lib\site-packages\matplotlib\backends\__init__.py", line 16, in <module>
line for line in traceback.format_stack()
import matplotlib; matplotlib.use('Agg')
Config 'configs/PascalVOC-Detection/faster_rcnn_R_50_FPN.yaml' has no VERSION. Assuming it to be compatible with latest v2.
d:\algorithmlibrary\detectron2-master\detectron2\export\c10.py:24: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert tensor.dim() == 2 and tensor.size(-1) in [4, 5], tensor.size()
Traceback (most recent call last):
File "demo/export_model.py", line 39, in <module>
c2_model = export_caffe2_model(cfg, predictor.model, [inputs])
File "d:\algorithmlibrary\detectron2-master\detectron2\export\api.py", line 54, in export_caffe2_model
predict_net, init_net = export_caffe2_detection_model(c2_compatible_model, c2_format_input)
File "d:\algorithmlibrary\detectron2-master\detectron2\export\caffe2_export.py", line 80, in export_caffe2_detection_model
predict_net, init_net = _export_via_onnx(model, (tensor_inputs,))
File "d:\algorithmlibrary\detectron2-master\detectron2\export\caffe2_export.py", line 39, in _export_via_onnx
f,
File "D:\Anaconda3\lib\site-packages\torch\onnx\__init__.py", line 156, in export
custom_opsets)
File "D:\Anaconda3\lib\site-packages\torch\onnx\utils.py", line 67, in export
custom_opsets=custom_opsets)
File "D:\Anaconda3\lib\site-packages\torch\onnx\utils.py", line 466, in _export
fixed_batch_size=fixed_batch_size)
File "D:\Anaconda3\lib\site-packages\torch\onnx\utils.py", line 319, in _model_to_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
File "D:\Anaconda3\lib\site-packages\torch\onnx\utils.py", line 276, in _trace_and_get_graph_from_model
torch.jit._get_trace_graph(model, args, _force_outplace=False, _return_inputs_states=True)
File "D:\Anaconda3\lib\site-packages\torch\jit\__init__.py", line 282, in _get_trace_graph
outs = ONNXTracedModule(f, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 539, in __call__
result = self.forward(*input, **kwargs)
File "D:\Anaconda3\lib\site-packages\torch\jit\__init__.py", line 365, in forward
self._force_outplace,
File "D:\Anaconda3\lib\site-packages\torch\jit\__init__.py", line 352, in wrapper
outs.append(self.inner(*trace_inputs))
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 537, in __call__
result = self._slow_forward(*input, **kwargs)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 523, in _slow_forward
result = self.forward(*input, **kwargs)
File "D:\Anaconda3\lib\contextlib.py", line 52, in inner
return func(*args, **kwds)
File "d:\algorithmlibrary\detectron2-master\detectron2\export\caffe2_modeling.py", line 122, in forward
results = self._wrapped_model.inference(inputs, do_postprocess=False)
File "d:\algorithmlibrary\detectron2-master\detectron2\modeling\meta_arch\rcnn.py", line 171, in inference
results, _ = self.roi_heads(images, features, proposals, None)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 537, in __call__
result = self._slow_forward(*input, **kwargs)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 523, in _slow_forward
result = self.forward(*input, **kwargs)
File "d:\algorithmlibrary\detectron2-master\detectron2\modeling\roi_heads\roi_heads.py", line 572, in forward
pred_instances = self._forward_box(features_list, proposals)
File "d:\algorithmlibrary\detectron2-master\detectron2\modeling\roi_heads\roi_heads.py", line 619, in _forward_box
box_features = self.box_pooler(features, [x.proposal_boxes for x in proposals])
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 537, in __call__
result = self._slow_forward(*input, **kwargs)
File "D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 523, in _slow_forward
result = self.forward(*input, **kwargs)
File "d:\algorithmlibrary\detectron2-master\detectron2\export\c10.py", line 298, in forward
legacy_plus_one=False,
RuntimeError: Could not run '_caffe2::DistributeFpnProposals' with arguments from the 'CUDATensorId' backend. '_caffe2::DistributeFpnProposals' is only available for these backends: [CPUTensorId]. (dispatch_ at C:\w\1\s\windows\pytorch\aten\src\ATen/core/dispatch/Dispatcher.h:222)
(no backtrace available)
Environment:
sys.platform win32 Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] Numpy 1.14.3 Detectron2 Compiler MSVC 191125548 Detectron2 CUDA Compiler 10.1 DETECTRON2_ENV_MODULE <not set> PyTorch 1.4.0.dev20200107 PyTorch Debug Build False torchvision 0.5.0.dev20200107 CUDA available True GPU 0 GeForce RTX 2080 Ti CUDA_HOME C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1 NVCC Not Available Pillow 6.0.0 cv2 4.1.1
PyTorch built with:
- MSVC 191125547
- Intel® Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel® 64 architecture applications
- OpenMP 200203
- CUDA Runtime 10.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_37,code=compute_37
- CuDNN 7.6.3
- Magma 2.5.1
- Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /w /EHa /MP /bigobj -openmp, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF,
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (1 by maintainers)
Top Results From Across the Web
FAQ / Troubleshooting Help - Caffe2
To install Caffe2 with GPU support, first install all the needed Nvidia libraries (CUDA and CuDNN) and then follow the installation instructions. What...
Read more >Comprehensive Guide: Installing Caffe2 with GPU Support by ...
1. Verify that NVIDIA graphics driver has been properly installed. You can refer to this article for NVIDIA graphics driver installation and ...
Read more >How to Write a Winning Business Proposal [Updated 2021]
The client does not want to interpret how your offerings will benefit value –- that is the writer's task. Generic proposals do not...
Read more >15 ways you should never trust people working on proposals
But the solution is counter-intuitive. To fix the trust issues related to uncertainty, you should build a proposal process that does not trust...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Our CPU inference is fast enough and much cheaper than GPUs.
Have you found a solution? I’m having the same problem