昇腾 300Tpro
CANN 7.0
pytorch 2.0.1
麒麟 V10 sp2 arm系统
添加了调用NPU的指令后报错
import torch_npu
from torch_npu.contrib import transfer_to_npu
报错如下:
Traceback (most recent call last):
File "/home/xxx/project/evaluate/duikangyangben/ssd-pytorch-master/对抗样本检测-ssdnew.py", line 100, in <module>
detect(state="原始模型",attack="原始样本",out_path="map_out_raw",flag=True)
File "/home/xxx/project/evaluate/duikangyangben/ssd-pytorch-master/对抗样本检测-ssdnew.py", line 41, in detect
ssd = SSD(confidence = confidence, nms_iou = nms_iou)
File "/home/xxx/project/evaluate/duikangyangben/ssd-pytorch-master/ssd.py", line 108, in __init__
self.generate()
File "/home/xxx/project/evaluate/duikangyangben/ssd-pytorch-master/ssd.py", line 121, in generate
self.net.load_state_dict(torch.load(self.model_path, map_location=device))
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch_npu/utils/serialization.py", line 126, in load
return se._load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1172, in _load
result = unpickler.load()
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1142, in persistent_load
typed_storage = load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location))
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1116, in load_tensor
wrap_storage=restore_location(storage, location),
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1083, in restore_location
return default_restore_location(storage, map_location)
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 217, in default_restore_location
result = fn(storage, location)
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 187, in _cuda_deserialize
return obj.cuda(device)
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/_utils.py", line 81, in _cuda
untyped_storage = torch.UntypedStorage(
TypeError: torch.UntypedStorage() received an invalid combination of arguments - got (int, device=torch_npu._C.device), but expected one of:
* (*, int allocator, torch.device device)
* (int size, *, int allocator, torch.device device)
* (object sequence, *, int allocator, torch.device device)
昇腾 300Tpro
CANN 7.0
pytorch 2.0.1
麒麟 V10 sp2 arm系统
添加了调用NPU的指令后报错
import torch_npu
from torch_npu.contrib import transfer_to_npu
报错如下:
Traceback (most recent call last):
File "/home/xxx/project/evaluate/duikangyangben/ssd-pytorch-master/对抗样本检测-ssdnew.py", line 100, in <module>
detect(state="原始模型",attack="原始样本",out_path="map_out_raw",flag=True)
File "/home/xxx/project/evaluate/duikangyangben/ssd-pytorch-master/对抗样本检测-ssdnew.py", line 41, in detect
ssd = SSD(confidence = confidence, nms_iou = nms_iou)
File "/home/xxx/project/evaluate/duikangyangben/ssd-pytorch-master/ssd.py", line 108, in __init__
self.generate()
File "/home/xxx/project/evaluate/duikangyangben/ssd-pytorch-master/ssd.py", line 121, in generate
self.net.load_state_dict(torch.load(self.model_path, map_location=device))
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch_npu/utils/serialization.py", line 126, in load
return se._load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1172, in _load
result = unpickler.load()
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1142, in persistent_load
typed_storage = load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location))
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1116, in load_tensor
wrap_storage=restore_location(storage, location),
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 1083, in restore_location
return default_restore_location(storage, map_location)
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 217, in default_restore_location
result = fn(storage, location)
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/serialization.py", line 187, in _cuda_deserialize
return obj.cuda(device)
File "/home/xxx/miniconda3/envs/py39/lib/python3.9/site-packages/torch/_utils.py", line 81, in _cuda
untyped_storage = torch.UntypedStorage(
TypeError: torch.UntypedStorage() received an invalid combination of arguments - got (int, device=torch_npu._C.device), but expected one of:
* (*, int allocator, torch.device device)
* (int size, *, int allocator, torch.device device)
* (object sequence, *, int allocator, torch.device device)