Trying to train with pytorch hangs in debug mode, but works in run mode.
sampler_train = WeightedRandomSampler(
sample_weights_train,
num_samples=len(sample_weights_train),
replacement=True
)
train_loader = torch.utils.data.DataLoader(
train_set,
sampler=sampler_train,
batch_size=32,
num_workers=2
)
for epoch in range(10):
for i, data in enumerate(train_loader, 0):
model.train()
print("something")
After placing a breakpoint on model.train(), then moving on to the next line, "something" is never printed in debug mode, but is printed in run mode in Pycharm.
How to debug my code?
CodePudding user response:
After a long search, I found the answer here, which led to here
Setting Gevent Compatible in Preferences | Build, Execution, Deployment | Python Debugger solves the issue.
