Lower precision with GPU than GPU

39 views
Skip to first unread message

Chris Gll

unread,
May 6, 2016, 12:12:20 PM5/6/16
to torch7
Is it normal that computation on GPU using Cuda has different precision that using CPU ? How can I get the same precision with GPU ?

r = 1

H = nn.Sigmoid();
print(string.format('%.60f',H:forward(x)[1]))

0.731058578630004896048433238320285454392433166503906250000000	

H=H:cuda()
x=x:cuda()
print(string.format('%.60f',H:forward(x)[1]))

0.731058597564697265625000000000000000000000000000000000000000	

Vislab

unread,
May 6, 2016, 6:42:33 PM5/6/16
to torch7
yes, cuda precision is different.

Francisco Vitor Suzano Massa

unread,
May 9, 2016, 4:05:08 AM5/9/16
to torch7
Cuda uses float types. You can set the CPU model to use float as well to have the same precision (model:float () )
Reply all
Reply to author
Forward
0 new messages