PyTorch 使用一些错误记录

[亡魂溺海] 提交于 2020-03-02 19:55:47
  • 错误一
Traceback (most recent call last):
2012   File "train.py", line 131, in <module>
2013     for _, (input_images, ground_truths, masks) in enumerate(data_loader):
2014   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
2015     data = self._next_data()
2016   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
2017     return self._process_data(data)
2018   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
2019     data.reraise()
2020   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/_utils.py", line 394, in reraise
2021     raise self.exc_type(msg)
2022 OSError: Caught OSError in DataLoader worker process 3.
2023 Original Traceback (most recent call last):
2024   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
2025     data = fetcher.fetch(index)
2026   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
2027     data = [self.dataset[idx] for idx in possibly_batched_index]
2028   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
2029     data = [self.dataset[idx] for idx in possibly_batched_index]
2030   File "/home/guoxiefan/PyTorch/ImageInpainting/LBAM/src/dataset.py", line 76, in __getitem__
2031     ground_truth = self.image_files_transforms(image.convert('RGB'))
2032   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/PIL/Image.py", line 873, in convert
2033     self.load()
2034   File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/PIL/ImageFile.py", line 247, in load
2035     "(%d bytes not processed)" % len(b)
2036 OSError: image file is truncated (16 bytes not processed)

解决方案:[Link]

  • 错误二
Traceback (most recent call last):
  File "train.py", line 143, in <module>
    outputs = generator(input_images, masks)
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 148, in forward
    inputs, kwargs = self.scatter(inputs, kwargs, self.device_ids)
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 159, in scatter
    return scatter_kwargs(inputs, kwargs, device_ids, dim=self.dim)
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 36, in scatter_kwargs
    inputs = scatter(inputs, target_gpus, dim) if inputs else []
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 28, in scatter
    res = scatter_map(inputs)
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 15, in scatter_map
    return list(zip(*map(scatter_map, obj)))
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/parallel/scatter_gather.py", line 13, in scatter_map
    return Scatter.apply(target_gpus, None, dim, obj)
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/parallel/_functions.py", line 89, in forward
    outputs = comm.scatter(input, target_gpus, chunk_sizes, ctx.dim, streams)
  File "/data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/cuda/comm.py", line 147, in scatter
    return tuple(torch._C._scatter(tensor, devices, chunk_sizes, dim, streams))
RuntimeError: CUDA error: out of memory (malloc at /opt/conda/conda-bld/pytorch_1579022051443/work/c10/cuda/CUDACachingAllocator.cpp:260)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x47 (0x7f654a439627 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libc10.so)
frame #1: <unknown function> + 0x1ea4a (0x7f654a67da4a in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libc10_cuda.so)
frame #2: <unknown function> + 0x1ff2e (0x7f654a67ef2e in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libc10_cuda.so)
frame #3: THCStorage_resize + 0xa3 (0x7f64bc77bbb3 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #4: at::native::empty_strided_cuda(c10::ArrayRef<long>, c10::ArrayRef<long>, c10::TensorOptions const&) + 0x606 (0x7f64be1b3e96 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #5: <unknown function> + 0x41681fa (0x7f64bc68d1fa in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #6: <unknown function> + 0x1afb151 (0x7f64ba020151 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #7: <unknown function> + 0x3659480 (0x7f64bbb7e480 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #8: <unknown function> + 0x1afb151 (0x7f64ba020151 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #9: <unknown function> + 0x1863b6e (0x7f64b9d88b6e in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #10: at::native::to(at::Tensor const&, c10::TensorOptions const&, bool, bool, c10::optional<c10::MemoryFormat>) + 0x245 (0x7f64b9d89bc5 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #11: <unknown function> + 0x1ba906a (0x7f64ba0ce06a in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #12: <unknown function> + 0x388ed36 (0x7f64bbdb3d36 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #13: <unknown function> + 0x1bf3ab2 (0x7f64ba118ab2 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #14: torch::cuda::scatter(at::Tensor const&, c10::ArrayRef<long>, c10::optional<std::vector<long, std::allocator<long> > > const&, long, c10::optional<std::vector<c10::optional<c10::cuda::CUDAStream>, std::allocator<c10::optional<c10::cuda::CUDAStream> > > > const&) + 0x710 (0x7f64bca87420 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so)
frame #15: <unknown function> + 0x9f74eb (0x7f655787d4eb in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
frame #16: <unknown function> + 0x28c076 (0x7f6557112076 in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
<omitting python frames>
frame #27: THPFunction_apply(_object*, _object*) + 0xa1f (0x7f65574fbe3f in /data/guoxiefan/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!