Using the runtime API to query free memory of all cards?

Hi - I have an application that uses as many graphics cards as available in separate threads, but in the main() thread when I’m trying to figure out what cards are valid to use, I can’t figure out how to query the free memory of multiple cards. cudaSetDevice only works once, and cudaMemGetInfo doesn’t take a device # argument.

Is there any way using the runtime API to query the memory of all available cards?

Thanks in advance