小编Kjy*_*ong的帖子

GPU内存为空,但出现CUDA内存不足错误

在使用rayune (1 个 GPU 进行 1 次试验)训练此代码期间,经过几个小时的训练(大约 20 次试验)后,GPU 出现错误:0,1。即使终止训练过程后,GPU 仍然给出错误。CUDA out of memoryout of memory

Nvidia-SMI 结果

如上所述,目前我的所有 GPU 设备都是空的。并且除了这两个进程之外没有其他Python进程在运行。

import torch
torch.rand(1, 2).to('cuda:0') # cuda out of memory error
torch.rand(1, 2).to('cuda:1') # cuda out of memory error
torch.rand(1, 2).to('cuda:2') # working
torch.rand(1, 2).to('cuda:3') # working

torch.cuda.device_count() # 4
torch.cuda.memory_reserved() # 0
torch.cuda.is_available() # True
Run Code Online (Sandbox Code Playgroud)
# error message of GPU 0, 1
RuntimeError: CUDA error: out of memory
Run Code Online (Sandbox Code Playgroud)

但是,GPU:0,1 会出错out of memory。如果我重新启动计算机(ubuntu …

cuda gpu nvidia ray pytorch

10
推荐指数
1
解决办法
5931
查看次数

第二次调用model.fit()时CNTK内存不足错误

我正在使用Keras和CNTK(后端)

我的代码是这样的:

def run_han(embeddings_index, fname, opt)
    ...
    sentence_input = Input(shape=(MAX_SENT_LENGTH,), dtype='int32')
    embedded_sequences = embedding_layer(sentence_input)
    l_lstm = Bidirectional(GRU(GRU_UNITS, return_sequences=True, kernel_regularizer=l2_reg, 
                           implementation=GPU_IMPL))(embedded_sequences)
    l_att = AttLayer(regularizer=l2_reg)(l_lstm)            
    sentEncoder = Model(sentence_input, l_att)

    review_input = Input(shape=(MAX_SENTS, MAX_SENT_LENGTH), dtype='int32')
    review_encoder = TimeDistributed(sentEncoder)(review_input)
    l_lstm_sent = Bidirectional(GRU(GRU_UNITS, return_sequences=True, kernel_regularizer=l2_reg, 
                                implementation=GPU_IMPL))(review_encoder)
    l_att_sent = AttLayer(regularizer=l2_reg)(l_lstm_sent) 
    preds = Dense(n_classes, activation='softmax', kernel_regularizer=l2_reg)(l_att_sent)
    model = Model(review_input, preds)

    model.compile(loss='categorical_crossentropy',
          optimizer=opt, #SGD(lr=0.1, nesterov=True),
          metrics=['acc'])
   ...
   model.fit(x_train[ind,:,:], y_train[ind,:], epochs=NUM_EPOCHS, batch_size=BATCH_SIZE, shuffle=False, 
          callbacks=[cr_result, history, csv_logger], 
          verbose=2,validation_data=(x_test, y_test), class_weight = class_weight)
   ...
    %xdel model
    gc.collect()
Run Code Online (Sandbox Code Playgroud)

更改优化程序时,我多次调用上述模型。像这样:

opt = optimizers.RMSprop(lr=0.0001, …
Run Code Online (Sandbox Code Playgroud)

python keras cntk

5
推荐指数
1
解决办法
392
查看次数

为什么在 iOS 上使用 Caffe2 或 Core-ML 而不是 LibTorch(.pt 文件)?

似乎有几种方法可以在 iOS 上运行 Pytorch 模型。

  1. PyTorch(.pt) -> onnx -> caffe2
  2. PyTorch(.pt) -> onnx -> Core-ML (.mlmodel)
  3. PyTorch(.pt) -> LibTorch (.pt)
  4. PyTorch 移动版?

上述方法有什么区别?为什么人们使用 caffe2 或需要模型格式转换的 Core-ml (.mlmodel),而不是 LibTorch?

pytorch caffe2 coreml onnx libtorch

4
推荐指数
1
解决办法
415
查看次数

标签 统计

pytorch ×2

caffe2 ×1

cntk ×1

coreml ×1

cuda ×1

gpu ×1

keras ×1

libtorch ×1

nvidia ×1

onnx ×1

python ×1

ray ×1