-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not implemented on the CPU #54
Comments
I had the same issue. Could you please shred some light? |
There is a In the meanwhile, you can patch DETReg/models/ops/modules/ms_deform_attn.py Line 112 in 32f39af
from ..functions import MSDeformAttnFunction, ms_deform_attn_core_pytorch if value.is_cuda:
output = MSDeformAttn.MSDeformAttnFunction.apply(value, input_spatial_shapes, input_level_start_index, sampling_locations, attention_weights, self.im2col_step)
else:
output = ms_deform_attn_core_pytorch(value, input_spatial_shapes, sampling_locations, attention_weights) From my earlier checks, it's correct, but please test it as well |
it because the author's google colab code wrong. you need change the input variable to cuda format for model run, it means you need change
to
I can't remember whether there is the same error in other positions, if there is, use the same method to deal with |
Thanks! This make the "Not implemented on the CPU" error disappear. But I had another error when I tried to run author's colab code and would appreciate your help. RuntimeError Traceback (most recent call last) File ~/prog/anaconda3/envs/physics/lib/python3.10/site-packages/torch/nn/modules/module.py:1110, in Module._call_impl(self, *input, **kwargs) File ~/prog/DETReg/models/deformable_detr.py:138, in DeformableDETR.forward(self, samples) File ~/prog/DETReg/models/deformable_detr.py:141, in DeformableDETR.forward_samples(self, samples) File ~/prog/anaconda3/envs/physics/lib/python3.10/site-packages/torch/nn/modules/module.py:1110, in Module._call_impl(self, *input, **kwargs) File ~/prog/DETReg/models/backbone.py:134, in Joiner.forward(self, tensor_list) File ~/prog/anaconda3/envs/physics/lib/python3.10/site-packages/torch/nn/modules/module.py:1110, in Module._call_impl(self, *input, **kwargs) File ~/prog/DETReg/models/backbone.py:88, in BackboneBase.forward(self, tensor_list) File ~/prog/anaconda3/envs/physics/lib/python3.10/site-packages/torch/nn/modules/module.py:1110, in Module._call_impl(self, *input, **kwargs) File ~/prog/anaconda3/envs/physics/lib/python3.10/site-packages/torchvision/models/_utils.py:63, in IntermediateLayerGetter.forward(self, x) File ~/prog/anaconda3/envs/physics/lib/python3.10/site-packages/torch/nn/modules/module.py:1110, in Module._call_impl(self, *input, **kwargs) File ~/prog/anaconda3/envs/physics/lib/python3.10/site-packages/torch/nn/modules/conv.py:447, in Conv2d.forward(self, input) File ~/prog/anaconda3/envs/physics/lib/python3.10/site-packages/torch/nn/modules/conv.py:443, in Conv2d._conv_forward(self, input, weight, bias) RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same |
I can't remember if I meet this error. as a matter of experience, this error means the weight's datatype is float32, but the input datatype is float64. you need debug and check the datatype, then change it |
I would say that input tensor device does not match mode weight tensor device (one is cpu, another is cuda), so more debugging / patching is needed |
Your solution is indeed more meaningful, but I recommend changing the input variable device on colab first so that novice users can run successfully |
I also encountered this problem, I have changed the code as follows, and now it is work: In section: Define model and load checkpoint:
In section: Load image and predict class agnostic results:
In section: Plot results:
Other problems that I solved:
|
Would you like to share how to train with a single GPU. |
hello! Do you know how to train this model with only one GPU? |
i meet this error:
Traceback (most recent call last):
File "wkktest.py", line 22, in
res = model(im_t.unsqueeze(0))
File "/ssd2/wangkangkang/anaconda3_torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/ssd2/wangkangkang/projects/test_detreg/another/DETReg-main/models/deformable_detr.py", line 138, in forward
return self.forward_samples(samples)
File "/ssd2/wangkangkang/projects/test_detreg/another/DETReg-main/models/deformable_detr.py", line 167, in forward_samples
query_embeds)
File "/ssd2/wangkangkang/anaconda3_torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/ssd2/wangkangkang/projects/test_detreg/another/DETReg-main/models/deformable_transformer.py", line 153, in forward
memory = self.encoder(src_flatten, spatial_shapes, level_start_index, valid_ratios, lvl_pos_embed_flatten, mask_flatten)
File "/ssd2/wangkangkang/anaconda3_torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/ssd2/wangkangkang/projects/test_detreg/another/DETReg-main/models/deformable_transformer.py", line 256, in forward
output = layer(output, pos, reference_points, spatial_shapes, level_start_index, padding_mask)
File "/ssd2/wangkangkang/anaconda3_torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/ssd2/wangkangkang/projects/test_detreg/another/DETReg-main/models/deformable_transformer.py", line 221, in forward
src2 = self.self_attn(self.with_pos_embed(src, pos), reference_points, src, spatial_shapes, level_start_index, padding_mask)
File "/ssd2/wangkangkang/anaconda3_torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/ssd2/wangkangkang/projects/test_detreg/another/DETReg-main/models/ops/modules/ms_deform_attn.py", line 113, in forward
value, input_spatial_shapes, input_level_start_index, sampling_locations, attention_weights, self.im2col_step)
File "/ssd2/wangkangkang/projects/test_detreg/another/DETReg-main/models/ops/functions/ms_deform_attn_func.py", line 26, in forward
value, value_spatial_shapes, value_level_start_index, sampling_locations, attention_weights, ctx.im2col_step)
RuntimeError: Not implemented on the CPU
another error:
i run these:
cd ./models/ops
sh ./make.sh
and when i run python test.py, it report:
RuntimeError: CUDA out of memory. Tried to allocate 7.50 GiB (GPU 0; 31.75 GiB total capacity; 22.52 GiB already allocated; 656.44 MiB free; 23.52 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
my device is v100.
how to run the detreg code?
The text was updated successfully, but these errors were encountered: