setting device using cutilDeviceInit How to set the device from command line using cutilDeviceInit?

cutilDeviceInit(argc, argv) seems to offer the option of setting the device from a command line argument. How do I do that?

I have unsuccessfully tried the following run commands:

./myexe 1 ./myexe device1
./myexe device=1 ./myexe device 1

Here, ‘myexe’ is my executable file. My program uses cutilDeviceInit(argc, argv), and this automatically results in it running on device 0 when I do not specify any command line arguments:

$ ./myexe
(this runs successfully on device 0)

(I have also successfully ran this program on device 1 by using cudaSetDevice(1) instead of cutilDeviceInit(argc, argv), but I would now like to use the latter.)

(Also, I know that the common subdirectory of the SDK has a file named cutil_inline_runtime.h which has the cutilDeviceInit(argc, argv) function definition, but I found it obscure).

Many thanks!
Daniel.

Try “./myexe --device=1”.

Try “./myexe --device=1”.

That worked! Thanks.

That worked! Thanks.