meetps/pytorch-semseg

KeyError: 'n_workers' when trying to train

Opened this issue · 5 comments

Tried to run the train.py for ICNet using the README guide with Cityscapes dataset.
Windows 10
CUDA 10.1
GPU: Nvidia GEFORCE GTX 1050Ti
Using the Conda virtual environment. Issued the following command to train on the cityscapes
dataset:
python train.py --config configs\icnet_cityscapes.yml
The output from the PowerShell window

train.py:217: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  cfg = yaml.load(fp)
RUNDIR: runs\icnet_cityscapes\83671
Found 2975 train images
Found 500 val images
Traceback (most recent call last):
  File "train.py", line 229, in <module>
    train(cfg, writer, logger)
  File "train.py", line 63, in train
    num_workers=cfg["training"]["n_workers"],
KeyError: 'n_workers'

The config file

model:
    arch: icnet
data:
    dataset: cityscapes
    train_split: train
    val_split: val
    img_rows: 512
    img_cols: 1024
    path: D:\Workspace\datasets\nn\cityscapes
training:
    train_iters: 85000
    batch_size: 2
    val_interval: 500
    print_interval: 25
    optimizer:
        lr: 1.0e-2
    l_rate: 1.0e-2
    l_schedule:
    momentum: 0.99
    weight_decay: 0.0005
    resume: icnet_cityscapes_best_model.pkl
    visdom: False
    loss:
        name: cross_entropy

Hi @reaktr4
Could you share the solution?I also encounter this issue.
Thank you.

Hi @reaktr4
Could you share the solution?I also encounter this issue.
Thank you.

Hi @keishatsai
I solved it by specifying n_workers under the training section of the yaml file. Here is the sample config

model:
    arch: icnet
data:
    dataset: cityscapes
    train_split: train
    val_split: val
    img_rows: 512
    img_cols: 1024
    path: D:\Workspace\datasets\nn\cityscapes
training:
    train_iters: 85000
    batch_size: 2
    n_workers: 2 # a sample value
    val_interval: 500
    print_interval: 25
    optimizer:
        lr: 1.0e-2
    l_rate: 1.0e-2
    l_schedule:
    momentum: 0.99
    weight_decay: 0.0005
    resume: icnet_cityscapes_best_model.pkl
    visdom: False
    loss:
        name: cross_entropy

Hope this helps!

That is the big help.
Thank you.

Now I got another error to fix.

That is the big help.
Thank you.

Now I got another error to fix.

Glad to be of help!
Did you manage to solve all the issues?

does using cross_entropy as the loss while training icnet work for you ?