Pytorch: 1x1 μ»€λ„λ‘œ CUDA Conv2dλ₯Ό μˆ˜ν–‰ν•  λ•Œ 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

에 λ§Œλ“  2017λ…„ 01μ›” 23일  Β·  3μ½”λ©˜νŠΈ  Β·  좜처: pytorch/pytorch

1x1 컀널이 μžˆλŠ” Conv2dλŠ” CPUμ—μ„œλŠ” 잘 μž‘λ™ν•˜μ§€λ§Œ GPUμ—μ„œλŠ” μž‘λ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

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을 λΉ„ν™œμ„±ν™”ν•˜λ €κ³  μ‹œλ„ν–ˆμ§€λ§Œ μ—¬μ „νžˆ λ™μΌν•œ 였λ₯˜ λ©”μ‹œμ§€κ°€ λ‚˜νƒ€λ‚©λ‹ˆλ‹€.

Ubuntu 14.04, Cuda 7.5, Cudnn 5.1.5, Python 3.5.2λ₯Ό μ‚¬μš©ν•˜κ³  PytorchλŠ” λ°”μ΄λ„ˆλ¦¬μ—μ„œ μ„€μΉ˜λ©λ‹ˆλ‹€.

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

λ‹€μŒ λŒ€μ‹ μ— λͺ…ν™•νžˆ ν•˜κΈ° μœ„ν•΄:

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())

λͺ¨λ“  3 λŒ“κΈ€

conv에 제곡된 인수 μœ ν˜•μ„ μžμ„Ένžˆ μ‚΄νŽ΄λ³΄λ©΄ 일뢀 ν…μ„œλŠ” torch.cuda.FloatTensor 이고 λ‚˜λ¨Έμ§€λŠ” torch.FloatTensor μž„μ„ μ•Œ 수 μžˆμŠ΅λ‹ˆλ‹€. 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() μΌκ΄€λ˜κ²Œ λ™μž‘ν•˜λ„λ‘ ν•˜λŠ” 것이 더 λ‚«λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰