1x1カーネルを使用するConv2dはGPUでは機能しませんが、CPUでは正常に機能します。
net = nn.Conv2d(1, 6, kernel_size=(1,1))
net.cuda()
x = Variable(torch.randn(1, 1, 100, 100))
x.cuda()
net(x)
エラーメッセージ:
TypeError: FloatSpatialConvolutionMM_updateOutput received an invalid combination of arguments - got (int, torch.FloatTensor, torch.FloatTensor, torch.cuda.FloatTensor, torch.cuda.FloatTensor, torch.FloatTensor, torch.FloatTensor, int, int, int, int, int, int), but expected (int state, torch.FloatTensor input, torch.FloatTensor output, torch.FloatTensor weight, [torch.FloatTensor bias or None], torch.FloatTensor finput, torch.FloatTensor fgradInput, int kW, int kH, int dW, int dH, int padW, int padH)
torch.backends.cudnn.enabled = False
cudnnを無効にしようとしましたが、それでも同じエラーメッセージが表示されました。
私はUbuntu14.04、Cuda 7.5、Cudnn 5.1.5、Python 3.5.2を使用しており、Pytorchはバイナリからインストールされています。
あなたがコンバージョンに与えられた引数の型をよく見ると、あなたはテンソルの一部であることがわかりますtorch.cuda.FloatTensor
他の人がいる一方で、S torch.FloatTensor
sの。 おそらくGPUに入力を送信するのを忘れたでしょう。
明確にするために、代わりに:
x = Variable(torch.randn(1, 1, 100, 100))
x.cuda() # This creates a copy on the GPU and immediately discards it. "x" is still on the CPU
あなたは書くべきです:
x = Variable(torch.randn(1, 1, 100, 100).cuda())
混乱を避けるために、 model.cuda()
とx.cuda()
一貫して動作させる方が良いと思います。
最も参考になるコメント
明確にするために、代わりに:
あなたは書くべきです: