Sending a large number of images to the GPU

I am using the CNN (AlexNet) model implemented in Lua using Torch for image processing. I am changing the torch starter code .

My problem is that I make images with 18 channels instead of 3 channels to train the model, and it takes about 20 (2.13 s for each batch) times to send these images to the GPU than when it sends images from three channels (0.14 s for each batch). I also tried to see how long it took to send images with 4 channels to the GPU. I saw that as soon as the number of channels increased to more than 3 channels, the time increased approximately 20 times. For example, even for images with 4 channels, it took about 2 seconds for each batch, which is about 19 times more than for three-channel images.

I was wondering if there is an error that makes it take a long time, and if there are no errors, if there is any way to reduce this runtime?

+4
source share
1 answer

Short answer

This is a problem that does not disappear. This is a processor bandwidth issue for buffering the GPU. You have increased the amount of data that should be sent over the bus by a large factor.

Possible workaround

The essence of what you are trying to do is to include the previous frames in your model. If this is what you want to accomplish, there is another way to do it.

If the batch was not a random choice of stacked images, if instead the batch was in the usual way, but all were consistent in time.

In the second case, you send images with only three channels, but the images will not fail.

, -.

-, , , .

-, [batch, height, weight, channel] GPU ,

[ batch[1:], height, width, channel] - [ batch[:-1], height, width, channel]
and assign it to diffTensor 

origTensor [ batch[5:-0], height, width, channel] 
diffTensor [ batch[5:-0], height, width, channel] 
diffTensor [ batch[4:-1], height, width, channel] 
diffTensor [ batch[3:-2], height, width, channel] 
diffTensor [ batch[2:-3], height, width, channel] 
diffTensor [ batch[1:-4], height, width, channel] 
diffTensor [ batch[0:-5], height, width, channel] 

5 " "

? , 100 GPU, 95 + diff , 100 , 95 + diff , 5 500 . x5

0

Source: https://habr.com/ru/post/1679364/


All Articles