By doing debugging mode, it stopped at libcudart
Compiling
!cd examples/cpp/mnist;export CFLAGS="-g -O0 -G";cmake -DCMAKE_PREFIX_PATH=/usr/local/lib/python3.6/dist-packages/torch/lib/ -DTorch_DIR=/usr/local/lib/python3.6/dist-packages/torch/share/cmake/Torch/ ; make
!apt install gdb
!cd examples/cpp/mnist;gdb ./mnist

Output of gdb
Thread 1 "mnist" received signal SIGSEGV, Segmentation fault.
0x00007f4325e8a9fe in ?? () from /usr/local/cuda/lib64/libcudart.so.10.0
(gdb) bt
#0  0x00007f4325e8a9fe in ?? () from /usr/local/cuda/lib64/libcudart.so.10.0
#1  0x00007f4325e8f96b in ?? () from /usr/local/cuda/lib64/libcudart.so.10.0
#2  0x00007f4325ea4be2 in cudaDeviceSynchronize ()
   from /usr/local/cuda/lib64/libcudart.so.10.0
#3  0x00007f42eb590394 in cudnnDestroy ()
   from /usr/local/lib/python3.6/dist-packages/torch/lib/libcaffe2_gpu.so
#4  0x00007f42e710ecf1 in std::unordered_map<int, at::native::(anonymous namespace)::Handle, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, at::native::(anonymous namespace)::Handle> > >::~unordered_map() ()
   from /usr/local/lib/python3.6/dist-packages/torch/lib/libcaffe2_gpu.so
#5  0x00007f42e4f58615 in __cxa_finalize (d=0x7f4318cd2780)
    at cxa_finalize.c:83
#6  0x00007f42e6f1cfb3 in __do_global_dtors_aux ()
   from /usr/local/lib/python3.6/dist-packages/torch/lib/libcaffe2_gpu.so
#7  0x00007ffd33020160 in ?? ()
#8  0x00007f4329c43b73 in _dl_fini () at dl-fini.c:138
Backtrace stopped: frame did not save the PC