I would probably not go down that road. As you say your executable depends on two libraries, and those depend on others. But those again may depend on even more libraries… And they all have to be on a certain version level. In Linux I would just download the CUDA repo package from NVIDIA, install it with the public key and then do ‘apt install cuda libvnrtc9.2’ in an install script.
Then you have libtorch, which again depend on external libraries.
But in theory, you could just recursively apply ldd to all entities and write up a list of libraries to deploy. Then you will have a list of minimum libraries to include.
Now you need to list out all libraries already installed on the target system and skip them during install. But one of those libraries is not compatible with your version …
And last, not all of the licences might allow redistribution by a third party.