[英]When training with pytorch, debugger hangs, even though running works fine
Trying to train with pytorch hangs in debug mode, but works in run mode.尝试使用 pytorch 进行训练会在调试模式下挂起,但可以在运行模式下工作。
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.在
model.train()
上放置断点,然后转到下一行后,“something”永远不会在调试模式下打印,而是在 Pycharm 中以运行模式打印。
How to debug my code?如何调试我的代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.