I’ve found an alternative solution by forcing the linker to link libtorch_cuda.so to my artifact. However, this is more of a hack and I would still appreciate if someone knows a more elegant way to fix this.
My solution was to add -Wl,--no-as-needed ltorch_cuda -Wl, --as-needed to the linker.