报错内容:
网络推理的时候,出现下面错误:
Traceback (most recent call last):
File "test.py", line 230, in <module>
output = test_tracking(model, dataloader)
File "test.py", line 145, in test_tracking
similarity = model(inputs)['logits'].cpu()
File "/mnt/A/hust_csj/anaconda3/envs/iKUN/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/mnt/A/hust_csj/anaconda3/envs/iKUN/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 167, in forward
outputs = self.parallel_apply(replicas, inputs, kwargs)
File "/mnt/A/hust_csj/anaconda3/envs/iKUN/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 177, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/mnt/A/hust_csj/anaconda3/envs/iKUN/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 86, in parallel_apply
output.reraise()
File "/mnt/A/hust_csj/anaconda3/envs/iKUN/lib/python3.8/site-packages/torch/_utils.py", line 429, in reraise
raise self.exc_type(msg)
TypeError: Caught TypeError in replica 0 on device 0.
报错原因:
推理的时候,采用了多卡推理。
解决办法:
推理的时候,改成单卡推理。
eg:
self.parser.add_argument('--gpus', type=str, default='0')