This is a very useful solution, especially you are going to run with someone else’s code without specifying the cuda id.