If don’t use .cuda() on img, I get the following error (shortened to fit the comment size limit) when y = net.updateOutput(img) is run:
*** Error in `python': free(): invalid pointer: 0x00007fba64a87780 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fba6b8a47e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fba6b8ad37a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fba6b8b153c]
/usr/local/lib/python2.7/dist-packages/torch/_thnn/_THNN.so(+0x6bc3e)[0x7fba29d20c3e]
python(PyEval_EvalFrameEx+0x68a)[0x4c468a]
python(PyEval_EvalFrameEx+0x5d8f)[0x4c9d8f]
python(PyEval_EvalFrameEx+0x5d8f)[0x4c9d8f]
python(PyEval_EvalCodeEx+0x255)[0x4c2765]
python(PyEval_EvalCode+0x19)[0x4c2509]
python[0x4f1def]
python(PyRun_FileExFlags+0x82)[0x4ec652]
python(PyRun_SimpleFileExFlags+0x191)[0x4eae31]
python(Py_Main+0x68a)[0x49e14a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fba6b84d830]
python(_start+0x29)[0x49d9d9]
======= Memory map: ========
00400000-006ea000 r-xp 00000000 ca:01 50831                              /usr/bin/python2.7
008e9000-008eb000 r--p 002e9000 ca:01 50831                              /usr/bin/python2.7
008eb000-00962000 rw-p 002eb000 ca:01 50831                              /usr/bin/python2.7
00962000-00985000 rw-p 00000000 00:00 0
01a7c000-0ffe6000 rw-p 00000000 00:00 0                                  [heap]
10000000-10001000 rw-s 00000000 00:06 388                                /dev/nvidia0
1000e000-1000f000 rw-s 00000000 00:06 388                                /dev/nvidia0
1000f000-10010000 rw-s 00000000 00:06 388                                /dev/nvidia0
10010000-20000000 ---p 00000000 00:00 0
200000000-200100000 rw-s 00000000 00:06 387                              /dev/nvidiactl
200100000-200104000 rw-s 00000000 00:06 387                              /dev/nvidiactl
200104000-200120000 ---p 00000000 00:00 0
200120000-200520000 rw-s 00000000 00:06 387                              /dev/nvidiactl
200520000-200524000 rw-s 00000000 00:06 387                              /dev/nvidiactl
200524000-200540000 ---p 00000000 00:00 0
200540000-200940000 rw-s 00000000 00:06 387                              /dev/nvidiactl
200940000-200944000 rw-s 00000000 00:06 387                              /dev/nvidiactl
7fba6bbf7000-7fba6bc0f000 r-xp 00000000 ca:01 1971                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7fba6bc0f000-7fba6be0e000 ---p 00018000 ca:01 1971                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7fba6be0e000-7fba6be0f000 r--p 00017000 ca:01 1971                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7fba6be0f000-7fba6be10000 rw-p 00018000 ca:01 1971                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7fba6be10000-7fba6be14000 rw-p 00000000 00:00 0
7fba6be14000-7fba6be3a000 r-xp 00000000 ca:01 1966                       /lib/x86_64-linux-gnu/ld-2.23.so
7fba6be69000-7fba6bf29000 rw-p 00000000 00:00 0
7fba6bf5a000-7fba6c01f000 rw-p 00000000 00:00 0
7fba6c024000-7fba6c025000 rw-p 00000000 00:00 0
7fba6c025000-7fba6c026000 rw-s 00000000 00:06 387                        /dev/nvidiactl
7fba6c032000-7fba6c033000 rw-s 00000000 00:06 387                        /dev/nvidiactl
7fba6c033000-7fba6c034000 rw-s 00000000 00:06 387                        /dev/nvidiactl
7fba6c034000-7fba6c035000 rw-s 00000000 00:06 387                        /dev/nvidiactl
7fba6c035000-7fba6c036000 r--s 00000000 00:06 388                        /dev/nvidia0
7fba6c036000-7fba6c037000 rwxp 00000000 00:00 0
7fba6c037000-7fba6c039000 rw-p 00000000 00:00 0
7fba6c039000-7fba6c03a000 r--p 00025000 ca:01 1966                       /lib/x86_64-linux-gnu/ld-2.23.so
7fba6c03a000-7fba6c03b000 rw-p 00026000 ca:01 1966                       /lib/x86_64-linux-gnu/ld-2.23.so
7fba6c03b000-7fba6c03c000 rw-p 00000000 00:00 0
7ffec2915000-7ffec2936000 rw-p 00000000 00:00 0                          [stack]
7ffec29ad000-7ffec29af000 r--p 00000000 00:00 0                          [vvar]
7ffec29af000-7ffec29b1000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted (core dumped)

I have absolutely no idea on how to solve this error.