CornerNet icon indicating copy to clipboard operation
CornerNet copied to clipboard

Pytorch 1.0 change the interface for at::zeros, need to change the order while invoking it.

Open jmt330 opened this issue 6 years ago • 9 comments

error: src/right_pool.cpp: In function ‘std::vector<at::Tensor> pool_backward(at::Tensor, at::Tensor)’: src/right_pool.cpp:44:41: error: could not convert ‘torch::CUDA(((at::ScalarType)at::kFloat))’ from ‘at::TypeExtendedInterface’ to ‘at::IntList’ {aka ‘at::ArrayRef<long int>’} auto max_val = at::zeros(torch::CUDA(at::kFloat), {batch, channel, height}); ~~~~~~~~~~~^~~~~~~~~~~~ src/right_pool.cpp:45:41: error: could not convert ‘torch::CUDA(((at::ScalarType)at::kLong))’ from ‘at::TypeExtendedInterface’ to ‘at::IntList’ {aka ‘at::ArrayRef<long int>’} auto max_ind = at::zeros(torch::CUDA(at::kLong), {batch, channel, height}); ~~~~~~~~~~~^~~~~~~~~~~ src/right_pool.cpp:57:44: error: could not convert ‘torch::CUDA(((at::ScalarType)at::kByte))’ from ‘at::TypeExtendedInterface’ to ‘at::IntList’ {aka ‘at::ArrayRef<long int>’} auto gt_mask = at::zeros(torch::CUDA(at::kByte), {batch, channel, height}); ~~~~~~~~~~~^~~~~~~~~~~ src/right_pool.cpp:58:44: error: could not convert ‘torch::CUDA(((at::ScalarType)at::kFloat))’ from ‘at::TypeExtendedInterface’ to ‘at::IntList’ {aka ‘at::ArrayRef<long int>’} auto max_temp = at::zeros(torch::CUDA(at::kFloat), {batch, channel, height}); ~~~~~~~~~~~^~~~~~~~~~~~ error: command 'gcc' failed with exit status 1 solution: change the invoking order for at::zeros (in bottom_pool.cpp, left_pool.cpp, right_pool.cpp, top_pool.cpp )in CornerNet/models/py_utils/_cpools/src, For example: change: auto max_val = at::zeros(torch::CUDA(at::kFloat), {batch, channel, height}); to : auto max_val = at::zeros( {batch, channel, height}, torch::CUDA(at::kFloat));

jmt330 avatar Oct 12 '18 08:10 jmt330

hey guys, that helps me a lot, thx!

ZimingLu avatar Nov 28 '18 13:11 ZimingLu

@jmt330 That work, thx!

autocyz avatar Mar 28 '19 09:03 autocyz

Hello, I tried auto max_val = at::zeros( {batch, channel, height}, torch::CUDA(at::kFloat));. However, I get the following error: Expected tensor's dynamic type to be Variable, not Tensor. I searched on the internet and get one answer. They suggest replacing at::zeros with torch::zeros. I tried another error, which seem to be caused by using "#include <ATen/ATen.h>" and "#include <torch/torch.h>" in one file. Could you please help me? @jmt330

victorkkkk avatar Apr 21 '19 05:04 victorkkkk

Thx, it's work finally!

wuyxiquanquan avatar Apr 26 '19 03:04 wuyxiquanquan

I tried to at::zeros({batch, channel, width}, torch::CUDA(at::kFloat)); but, there are also some errors, as following: In file included from src/top_pool.cpp:1:0: /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/torch.h:7:2: warning: #warning "Including torch/torch.h for C++ extensions is deprecated. Please include torch/extension.h" [-Wcpp] #warning
^~~~~~~ src/top_pool.cpp: In function 'std::vectorat::Tensor top_pool_backward(at::Tensor, at::Tensor)': src/top_pool.cpp:45:62: warning: 'at::TypeExtendedInterface& torch::CUDA(c10::ScalarType)' is deprecated [-Wdeprecated-declarations] auto max_val = at::zeros({batch, channel, width}, torch::CUDA(at::kFloat)); ^~~~ In file included from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Type.h:5:0, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Type.h:2, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Context.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/ATen.h:5, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/types.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader_options.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/all.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/torch.h:3, from src/top_pool.cpp:1: /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/variable_tensor_functions.h:35:52: note: declared here AT_DEPRECATED(THP_CLASS at::TypeExtendedInterface& CUDA(at::ScalarType type)); ^ /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Deprecated.h:9:61: note: in definition of macro 'AT_DEPRECATED' #define AT_DEPRECATED(function) attribute((deprecated)) function ^~~~~~~~ src/top_pool.cpp:45:77: warning: 'at::TypeExtendedInterface& torch::CUDA(c10::ScalarType)' is deprecated [-Wdeprecated-declarations] auto max_val = at::zeros({batch, channel, width}, torch::CUDA(at::kFloat)); ^ In file included from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Type.h:5:0, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Type.h:2, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Context.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/ATen.h:5, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/types.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader_options.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/all.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/torch.h:3, from src/top_pool.cpp:1: /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/variable_tensor_functions.h:35:52: note: declared here AT_DEPRECATED(THP_CLASS at::TypeExtendedInterface& CUDA(at::ScalarType type)); ^ /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Deprecated.h:9:61: note: in definition of macro 'AT_DEPRECATED' #define AT_DEPRECATED(function) attribute((deprecated)) function ^~~~~~~~ src/top_pool.cpp:47:62: warning: 'at::TypeExtendedInterface& torch::CUDA(c10::ScalarType)' is deprecated [-Wdeprecated-declarations] auto max_ind = at::zeros({batch, channel, width}, torch::CUDA(at::kLong)); ^~~~ In file included from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Type.h:5:0, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Type.h:2, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Context.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/ATen.h:5, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/types.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader_options.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/all.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/torch.h:3, from src/top_pool.cpp:1: /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/variable_tensor_functions.h:35:52: note: declared here AT_DEPRECATED(THP_CLASS at::TypeExtendedInterface& CUDA(at::ScalarType type)); ^ /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Deprecated.h:9:61: note: in definition of macro 'AT_DEPRECATED' #define AT_DEPRECATED(function) attribute((deprecated)) function ^~~~~~~~ src/top_pool.cpp:47:76: warning: 'at::TypeExtendedInterface& torch::CUDA(c10::ScalarType)' is deprecated [-Wdeprecated-declarations] auto max_ind = at::zeros({batch, channel, width}, torch::CUDA(at::kLong)); ^ In file included from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Type.h:5:0, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Type.h:2, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Context.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/ATen.h:5, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/types.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader_options.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/all.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/torch.h:3, from src/top_pool.cpp:1: /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/variable_tensor_functions.h:35:52: note: declared here AT_DEPRECATED(THP_CLASS at::TypeExtendedInterface& CUDA(at::ScalarType type)); ^ /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Deprecated.h:9:61: note: in definition of macro 'AT_DEPRECATED' #define AT_DEPRECATED(function) attribute((deprecated)) function ^~~~~~~~ src/top_pool.cpp:60:65: warning: 'at::TypeExtendedInterface& torch::CUDA(c10::ScalarType)' is deprecated [-Wdeprecated-declarations] auto gt_mask = at::zeros({batch, channel, width}, torch::CUDA(at::kByte)); ^~~~ In file included from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/core/Type.h:5:0, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Type.h:2, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/Context.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/ATen/ATen.h:5, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/types.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader_options.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data/dataloader.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/data.h:3, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/all.h:4, from /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include/torch/torch.h:3, from src/top_pool.cpp:1: /opt/anaconda3/envs/py36/lib/python3.6/site-packages/torch/lib/include/torch/csrc/variable_tensor_functions.h:35:52: note: declared here AT_DEPRECATED(THP_CLASS at::TypeExtendedInterface& CUDA(at::ScalarType type)); Can you give me some suggestions to solve it? Tkanks.

wudi00 avatar Apr 28 '19 14:04 wudi00

thanks a lot!!!! solve my problems!!!

nuist-xinyu avatar Jun 01 '19 05:06 nuist-xinyu

Thx, solve my problems

YX2010 avatar Aug 21 '19 07:08 YX2010

thanks!it helps me a lot!

learnerjsk avatar Oct 09 '19 06:10 learnerjsk

Thanks, solve my problems!

my environment is as follows: Win7 PyTorch=1.3.1+cpu

SWHL avatar Dec 31 '19 07:12 SWHL