Could you cd pytorch/build/lib.linux-x86_64-2.7/torch (or wherever the build folder is) and then ldd _C.so and see what the output is?
The error suggests that it can’t find std::bad_weak_ptr, which might mean something is wrong with the linking with libstdc++