vpulab / Semantic-Aware-Scene-Recognition

Code repository for paper https://www.sciencedirect.com/science/article/pii/S0031320320300613 @ Pattern Recognition 2020
MIT License
102 stars 17 forks source link

AttributeError: Can't pickle local object 'ADE20KDataset.__init__.<locals>.<lambda>' #11

Closed JiahangWu closed 4 years ago

JiahangWu commented 4 years ago

Hi, I downloaded all the available Model Zoo, and ran the evaluation.py. However, there are some bugs in my project. Please, give me some suggestions and solutions. Thanks.

The error is following:

Traceback (most recent call last):
  File "evaluation.py", line 279, in <module>
    sample = next(iter(val_loader))
  File "D:\Software\Code\Anaconda3\envs\SA-Scene-Recognition\lib\site-packages\torch\utils\data\dataloader.py", line 279, in __iter__
    return _MultiProcessingDataLoaderIter(self)
  File "D:\Software\Code\Anaconda3\envs\SA-Scene-Recognition\lib\site-packages\torch\utils\data\dataloader.py", line 719, in __init__
    w.start()
  File "D:\Software\Code\Anaconda3\envs\SA-Scene-Recognition\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "D:\Software\Code\Anaconda3\envs\SA-Scene-Recognition\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\Software\Code\Anaconda3\envs\SA-Scene-Recognition\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "D:\Software\Code\Anaconda3\envs\SA-Scene-Recognition\lib\multiprocessing\popen_spawn_win32.py", line 89, in __init__
    reduction.dump(process_obj, to_child)
  File "D:\Software\Code\Anaconda3\envs\SA-Scene-Recognition\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'ADE20KDataset.__init__.<locals>.<lambda>'
DGideas commented 4 years ago

@Lollipop9z If you're use Windows, please consider switching to Ubuntu.

Some strange error with pickle often occur when your OS environment is inconsistent with the author's recommand operation system.

JiahangWu commented 4 years ago

But I still have other error on the Ubuntu with the GPU. This error told me that there is no memory of the GPU, but it still have. Please, help me. ^&^

Traceback (most recent call last):
  File "evaluation.py", line 300, in <module>
    val_top1, val_top2, val_top5, val_loss, val_ClassTPDic = evaluationDataLoader(val_loader, model, set='Validation')
  File "evaluation.py", line 76, in evaluationDataLoader
    outputSceneLabel, feature_conv, outputSceneLabelRGB, outputSceneLabelSEM = model(RGB_image, semanticTensor)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lollipop/Semantic-Aware-Scene-Recognition/SASceneNet.py", line 165, in forward
    e1 = self.encoder1(x)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/container.py", line 92, in forward
    input = module(input)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torchvision/models/resnet.py", line 41, in forward
    out = self.conv1(x)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 320, in forward
    self.padding, self.dilation, self.groups)
RuntimeError: CUDA out of memory. Tried to allocate 338.50 MiB (GPU 0; 5.79 GiB total capacity; 3.59 GiB already allocated; 340.94 MiB free; 307.46 MiB cached)
JiahangWu commented 4 years ago

But I still have other error on the Ubuntu with the GPU. This error told me that there is no memory of the GPU, but it still have. Please, help me. ^&^

Traceback (most recent call last):
  File "evaluation.py", line 300, in <module>
    val_top1, val_top2, val_top5, val_loss, val_ClassTPDic = evaluationDataLoader(val_loader, model, set='Validation')
  File "evaluation.py", line 76, in evaluationDataLoader
    outputSceneLabel, feature_conv, outputSceneLabelRGB, outputSceneLabelSEM = model(RGB_image, semanticTensor)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lollipop/Semantic-Aware-Scene-Recognition/SASceneNet.py", line 165, in forward
    e1 = self.encoder1(x)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/container.py", line 92, in forward
    input = module(input)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torchvision/models/resnet.py", line 41, in forward
    out = self.conv1(x)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lollipop/anaconda3/envs/SA-Scene-Recognition/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 320, in forward
    self.padding, self.dilation, self.groups)
RuntimeError: CUDA out of memory. Tried to allocate 338.50 MiB (GPU 0; 5.79 GiB total capacity; 3.59 GiB already allocated; 340.94 MiB free; 307.46 MiB cached)

The solution is that modify the batch_size being smaller, such as 2, 4, 6, in the config file. For example:

/Config/config_MITIndoor.yaml

VALIDATION:
    PRINT_FREQ: 10
    BATCH_SIZE:
        TRAIN: 100
        TEST: 2