Comments (11)
I have met the same error. The solution is change the t._TensorBase to t._C._TensorBase
from simple-faster-rcnn-pytorch.
Also, I'm guessing another problem you will gonna encounter is something like 'Can't call numpy() on Variable'
I changed line 11 from array_tool.py
if isinstance(data, t._C._TensorBase):
to
if isinstance(data, t._C._TensorBase) and (data.requires_grad==False):
I don't know if it's an error with pytorch or not, but it works for now
from simple-faster-rcnn-pytorch.
I am also encountering a similar problem here.
I followed @dami23 , then changed the line [ loc_loss /= (gt_label >= 0).sum() ] to [ loc_loss /= (gt_label >= 0).sum().float() ].
from simple-faster-rcnn-pytorch.
I cant find anything about torch._TensorBase,but torch.cuda.LongTensor,so I change utils/array_tool.py in line 43:
if isinstance(data, t._TensorBase):
to
if isinstance(data, t.cuda.LongTensor):
it occured that:RecursionError: maximum recursion depth exceeded
How to solve it?
from simple-faster-rcnn-pytorch.
@dami23 thank you for replying.
I have changed it already,but a new error occured like this:
Traceback (most recent call last):
File "train.py", line 131, in <module>
fire.Fire()
File "/home/htu/.local/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/home/htu/.local/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/home/htu/.local/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, **kwargs)
File "train.py", line 81, in train
trainer.train_step(img, bbox, label, scale)
File "/home/htu/yc/simple-faster-rcnn-pytorch-master/trainer.py", line 168, in train_step
losses = self.forward(imgs, bboxes, labels, scale)
File "/home/htu/yc/simple-faster-rcnn-pytorch-master/trainer.py", line 135, in forward
self.rpn_sigma)
File "/home/htu/yc/simple-faster-rcnn-pytorch-master/trainer.py", line 253, in _fast_rcnn_loc_loss
loc_loss /= (gt_label >= 0).sum() # ignore gt_label==-1 for rpn_loss
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.cuda.LongTensor for argument #3 'other'
from simple-faster-rcnn-pytorch.
@rxqy thank you so much!
I encountered a new problem like this:
Traceback (most recent call last):
File "train.py", line 131, in <module>
fire.Fire()
File "/home/htu/.local/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/home/htu/.local/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/home/htu/.local/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, **kwargs)
File "train.py", line 65, in train
faster_rcnn = FasterRCNNVGG16()
File "/home/htu/yc/simple-faster-rcnn-pytorch-master/model/faster_rcnn_vgg16.py", line 62, in __init__
extractor, classifier = decom_vgg16()
File "/home/htu/yc/simple-faster-rcnn-pytorch-master/model/faster_rcnn_vgg16.py", line 16, in decom_vgg16
model.load_state_dict(t.load(opt.caffe_pretrain_path))
File "/usr/local/lib/python3.5/dist-packages/torch/serialization.py", line 267, in load
return _load(f, map_location, pickle_module)
File "/usr/local/lib/python3.5/dist-packages/torch/serialization.py", line 420, in _load
result = unpickler.load()
AttributeError: Can't get attribute '_rebuild_tensor_v2' on <module 'torch._utils' from '/usr/local/lib/python3.5/dist-packages/torch/_utils.py'>
That's because the version of Pytorch is too old.https://github.com/pytorch/pytorch/issues/5729
I have encountered so many problems about packages version. So could you tell me what's the version of your packages like torch,torchvision,tronado and cupy.
Here is mine:
cupy-cuda80 4.0.0
torch 0.4.0
torchfile 0.1.0
torchnet 0.0.2
torchvision 0.2.1
tornado 4.5.3
from simple-faster-rcnn-pytorch.
Name Version Build Channel
cupy-cuda80 4.0.0
pytorch 0.4.0 py36_cuda8.0.61_cudnn7.1.2_1 pytorch
torchfile 0.1.0
torchnet 0.0.2
torchvision 0.2.1 py36_1 pytorch
tornado 4.5.3 py36_0
I'm using most of them from the latest version in anaconda3.
Did you run commands like
pip install -r requirements.txt
?
I think that'll solve most dependency problems
from simple-faster-rcnn-pytorch.
@rxqy I have already run pip install -r requirements.txt
without errors.Then I run python3 build.py build_ext --inplace
,a warning occured like this:
running build_ext
cythoning _nms_gpu_post.pyx to _nms_gpu_post.c
building '_nms_gpu_post' extension
creating build
creating build/temp.linux-x86_64-3.5
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c _nms_gpu_post.c -o build/temp.linux-x86_64-3.5/_nms_gpu_post.o
In file included from /usr/include/numpy/ndarraytypes.h:1777:0,
from /usr/include/numpy/ndarrayobject.h:18,
from /usr/include/numpy/arrayobject.h:4,
from _nms_gpu_post.c:566:
/usr/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by " \
^
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/_nms_gpu_post.o -o /home/htu/yc/simple-faster-rcnn-pytorch-master/model/utils/nms/_nms_gpu_post.cpython-35m-x86_64-linux-gnu.so
I think it won't trouble me,yes?
Then I run python3 train.py train --env='fasterrcnn_caffe' --plot_every=100 --caffe_pretrain
,the AttributeError occured again~
It really troubles me a lot! The version of my Python is 3.5.2.Is it because of this problem?
from simple-faster-rcnn-pytorch.
Sorry but I didn't build this gpu version of nms, I just skipped that step.
About the attribute error, you might want to refer to this link from pytorch forum.
https://discuss.pytorch.org/t/question-about-rebuild-tensor-v2/14560/4
I think all these errors are coming from the different versions of pytorch....
Maybe switch to a 0.3 may help..
from simple-faster-rcnn-pytorch.
The reference url is https://discuss.pytorch.org/t/question-about-rebuild-tensor-v2/14560/2
Putting the following line just after import torch
. Works for me. torch 0.4, python3.
# Monkey-patch because I trained with a newer version.
# This can be removed once PyTorch 0.4.x is out.
# See https://discuss.pytorch.org/t/question-about-rebuild-tensor-v2/14560
import torch._utils
try:
torch._utils._rebuild_tensor_v2
except AttributeError:
def _rebuild_tensor_v2(storage, storage_offset, size, stride, requires_grad, backward_hooks):
tensor = torch._utils._rebuild_tensor(storage, storage_offset, size, stride)
tensor.requires_grad = requires_grad
tensor._backward_hooks = backward_hooks
return tensor
torch._utils._rebuild_tensor_v2 = _rebuild_tensor_v2
from simple-faster-rcnn-pytorch.
In my case, under the torch 0.4.1, I occur another similar error:
File "/home/ubuntu/anaconda3/envs/pytorch/lib/python3.6/site-packages/torchnet/meter/averagevaluemeter.py", line 29, in add
self.std = np.sqrt(self.m_s / (self.n - 1.0))
File "/home/ubuntu/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/tensor.py", line 397, in array
return self.cpu().numpy()
RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.
As disscussed in this link: https://github.com/pytorch/pytorch/issues/7610
numpy tries to call the array in tensor.py and the raise the error
so I change the array in site-packages/torch/tensor.py in line 397 as follows:
def __array__(self, dtype=None): if dtype is None: if (self.requires_grad==False): return self.cpu().numpy() else: return self.data.cpu().numpy() else: return self.cpu().numpy().astype(dtype, copy=False)
It works for me, and it may be helpful for others.
from simple-faster-rcnn-pytorch.
Related Issues (20)
- Time consumption mainly comes from the i/o of cpu and gpu(such as numpy to tensor(cuda)) is that correct?
- Why do I need to copy a formal parameter in your codes? Is there some trick?(data/util.py bbox = bbox.copy())It's common in C++, but in python, i'm very curious.
- How to train Faster R-CNN on my own custom dataset and changing the RPN loss functions? HOT 2
- ValueError: need at least one array to stack HOT 3
- 关于RPN网络softmax HOT 2
- connection error HOT 1
- Can I test this model for real-time object detection? Is there a demo for it? HOT 1
- Without the incoming socket you cannot receive events from the server or register event handlers to your Visdom client. HOT 4
- In train.py line: 76
- 训练过程的loss HOT 2
- train mine dataset had an error!!! HOT 2
- Visdom and aws Sagemaker - output ?
- 训练好的模型在哪里保存啊? HOT 1
- out of memory 训练的时候显存一直在增长 HOT 4
- 怎么打印fps HOT 1
- step by step understanding approximate joint training method #192 HOT 5
- approximate joint training method problem
- How can I cite your work in my thesis?
- Convert to onnx
- Dependencies versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-faster-rcnn-pytorch.