Jupyter笔记本崩溃服务器

时间:2020-04-07 19:14:30

标签: jupyter-notebook pytorch

我刚购买了GPU,然后将其放置在装有Jupyter笔记本电脑的计算机中。我通过ssh将jupyter笔记本的输出从塔传输到我的笔记本。我正在运行一些代码,而jupyter笔记本每次都冻结在同一行中。 jupyter笔记本不仅冻结,而且塔上的所有内容都冻结。如果我还有其他ssh连接,它们将冻结。如果我直接在塔上使用GUI,则会冻结。在我按下电源按钮以重置计算机之前,没有任何响应。

奇怪的是,尽管没有响应,但也没有超时。 ssh会话保持其连接。 jupyter笔记本主页声称它仍处于连接状态。这很奇怪,我不确定这是否是代码或塔的问题,所以我不确定是否应该在此处或其他地方发布。但是这是代码

def show_img(x):
    x = x.clone().detach().permute(1,2,0).numpy()
    print(x.shape)
    x = rio.convert_tensor_to_rgb(x)
    print(x.shape)
    plt.figure(figsize=(8, 8))
    plt.axis('off')
    _ = plt.imshow(x)

# define generator discriminator, dataloader, other stuff....
G.cuda()
D.cuda()
g_optim = optim.RMSprop(G.parameters(), lr=lr)
d_optim = optim.RMSprop(D.parameters(), lr=lr)
g_losses = []
d_losses = []
i_losses = []
for epoch in range(n_epochs):
    dataloader = DataLoader(train_dataset, batch_size=batch_size,
                            shuffle=True, pin_memory=True,
                            num_workers=num_workers)
    g_loss = 0.0 # g_loss is the generator's loss
    d_loss = 0.0 # d_loss is the discriminator's loss
    i_loss = 0.0 # i_loss is the generator's loss for not being invertable
    i_weight = 10 # prioritize being invertible ten times more than minimizing g_loss
    x,y,z = train_dataset[0]
    print("image")
    show_img(x)
    print("target")
    show_img(y)
    print("generated")
    x,y = x.cuda(), y.cuda()
    g = G(x.unsqueeze(0),y.unsqueeze(0))
    print(g.shape)
    show_img(g.squeeze().cpu())
    loop = tqdm(total=len(dataloader), position=0, file=sys.stdout)
    print("just to be sure") #prints this
    for minibatch, (image, batchImage, exp_batch) in enumerate(dataloader): #this is the line it freezes on?
        print("image ", image.shape, " batchImage ", batchImage.shape, " experiment batch ", exp_batch) # doesn't print this. already frozen

编辑:GUI和ssh响应迅速,但异常慢。我想主要的问题是代码仍在上述代码行中冻结,我不知道为什么。

1 个答案:

答案 0 :(得分:0)

我发现了问题。批处理大小为32,考虑到图像的大小,这非常大。我认为在尝试全部加载后它刚刚崩溃了。