在使用rayune (1 个 GPU 进行 1 次试验)训练此代码期间,经过几个小时的训练(大约 20 次试验)后,GPU 出现错误:0,1。即使终止训练过程后,GPU 仍然给出错误。CUDA out of memoryout of memory
如上所述,目前我的所有 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 …
我正在使用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) 似乎有几种方法可以在 iOS 上运行 Pytorch 模型。
上述方法有什么区别?为什么人们使用 caffe2 或需要模型格式转换的 Core-ml (.mlmodel),而不是 LibTorch?