Libtorch move Variable from CPU to GPU Excessive CPU usage

for (int k = 0; k < img_vars.size(); ++k) {
		
		img_var = img_vars[k]; //**vector of variable on CPU**
		if (use_gpu)                                
			img_var = img_var.cuda();//to(at::kCUDA);// **I find this code will Excessive CPU usage**
}

image

Is such a high CPU usage normal? and any way to reduce CPU usage?

Could you try setting OMP_NUM_THREADS=1, and see if there is still a high CPU usage?

3 Likes

still too high, any other suggestions?