在学习过程中,出现cuda错误:
CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`
Run Code Online (Sandbox Code Playgroud)
我以前没有遇到过这样的问题。在谷歌中我没有找到可以帮助我的解决方案。也许这与我的 GPU 内存很少(2GB)有关
型号代码:
num_epochs = 2
batch_size = 4
for epoch in range(num_epochs):
# In each epoch, we do a full pass over the training data:
start_time = time.time()
model.train(True) # enable dropout / batch_norm training behavior
for (X_batch, y_batch) in train_batch_gen:
loss = compute_loss(X_batch, y_batch)
loss.backward()
opt.step()
opt.zero_grad()
train_loss.append(loss.data.cpu().numpy())
model.train(False) # disable dropout / use averages for batch_norm
for X_batch, y_batch in val_batch_gen:
logits = model(Variable(torch.FloatTensor(X_batch)).cuda())
y_pred = logits.max(1)[1].data
val_accuracy.append(np.mean( (y_batch.cpu() …Run Code Online (Sandbox Code Playgroud)