-
Notifications
You must be signed in to change notification settings - Fork 243
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
RuntimeError: expected scalar type Half but found Float: issues when I tried to run DCN on pytorch without C++ #245
Comments
Change the function in dcnv3_func.py in the functions folder in the ops--_dcnv3 folder Replace dtype=torch.float32 in _get_reference_points and _generate_dilation_grids with dtype=torch.float16, so that the data type of the code when performing dcnv3-related data calculations is 16-bit floating point instead of 32-bit floating point, so that it can be used on the GPU Calculate on the GPU instead of the CPU, so that the ref and grid parameters can be calculated on the GPU. Modify the code as follows:
################################################################### |
and in the first part def _get_reference_points,there are still float32 remain. You need to change it into float16 or an error:meshgrid need the same type. And so on, in issue dcnv3 in modules also have two float need to change into float16. |
Since I cannot compile C++ in my environment because of the imcompatibility of pakages, I then tried to use DCN with pytorch, but I encounter and error as below:
File "/root/data/andy/newyolov8/ultralytics/ultralytics/nn/modules/block.py", line 708, in dcnv3_core_pytorch
sampling_input_ = F.grid_sample(
File "/root/miniconda3/envs/newyolov8benchmark/lib/python3.8/site-packages/torch/nn/functional.py", line 4244, in grid_sample
return torch.grid_sampler(input, grid, mode_enum, padding_mode_enum, align_corners)
RuntimeError: expected scalar type Half but found Float
Please help me to take a look!!!
The text was updated successfully, but these errors were encountered: