Delay when running CUDA APP from a startup service

I’m trying to run CUDA application on the TX2 using a startup service in ubuntu 16.04 and I notice that the first CUDA operation (upload to a GpuMat using opencv) with a compiled cpp script takes several seconds (around 2-3), while runing the same script from a startup service gives me about 6-7 minuts delay on the first CUDA operation.
Can someone explain that?

Thanks, Gal.

I can’t answer, but do realize that services are generally started from a list, or as a dependency of something in a list. If for some reason startup begins when a dependency is missing, then it will have to wait until the dependency is up. Services can also be started with different priorities, and so who knows what else will run before this (if a pool of processes all have the same priority, then it is up to the judgement of the scheduler how/when to run them). If there is someone already logged in and a context exists at the moment you try to start the program, then it will be an illusion that starting everything for a context plus the actual program is a longer program startup…time would really be a combination of a number of startup requirements.

Also, during start only the first core is running. After some time into boot other cores go online. After a certain load is reached you might find clock speeds also increase. How many cores are active and at what clock speed when you start manually? How many cores are active and at what clock speed when your service begins?

I don’t know if every unrelated service starting in that time from begin service to service running gets a log note, and the system can run on different cores if they are available, but any dmesg note on your service beginning and any other service doing something prior to your service actually running could be a clue.

I didn’t mention it but this delay happens even if I start the service after all the cores are up and over-clocked, so I don’t think there is anything to do with processing power. Perhaps is due to priority, I will check this out.