Pycharm debugging code reports Frames are not available

  When using linuxthe training neural network, the normal training code will not report any errors, but when debugging, it can only jump to the breakpoint and cannot run later, but it is ok. I have encountered it too many times. Why windows? Will this problem occur? Today I finally solved this problem, record it.
  We can use multi-threading during linuxtraining. In the following code num_workers=8, we know that windowsmulti-threading is not supported when training the network, so when using windowstraining, our thread settings here are 0, that is, whether you are debugging or Running him directly is a thread 0. But linuxit supports multi-threading. Usually we set the number of threads to be greater than 1. But there will be problems when debugging. My Pycharmdebugging interface only supports the main process, and it cannot be used after the thread is opened.

    train_data_loader = torch.utils.data.DataLoader(train_dataset,
                                                    batch_size=batch_size,
                                                    shuffle=True,
                                                    num_workers=8,
                                                    collate_fn=train_dataset.collate_fn,
                                                    drop_last=drop_last)

The solution is very simple. When running directly, you don’t need to worry about the number of threads, but it is enough to set it to when debugging 0.

    train_data_loader = torch.utils.data.DataLoader(train_dataset,
                                                    batch_size=batch_size,
                                                    shuffle=True,
                                                    num_workers=0,
                                                    collate_fn=train_dataset.collate_fn,
       

Guess you like

Origin blog.csdn.net/qq_38683460/article/details/131163997