I have run into an Out of Memory problem while running a python script. The trace reads -
490426.070081] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice,task=python3,pid=18456,uid=1003
[490426.070085] Out of memory: Killed process 18456 (python3) total-vm:82439932kB, anon-rss:63127200kB, file-rss:4kB, shmem-rss:0kB
[490427.453131] oom_reaper: reaped process 18456 (python3), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
I strongly suspect it is because of the concatenations I do in the script when the smaller test sample script was applied a larger dataset of 105,000 entries.
So a bit of overview of how my script looks. I have about 105,000 rows of timestamps and other data.
dataset -
2020-05-24T10:44:37.923792|[0.0, 0.0, -0.246047720313072, 0.0]
2020-05-24T10:44:36.669264|[1.0, 1.0, 0.0, 0.0]
2020-05-24T10:44:37.174584|[1.0, 1.0, 0.0, 0.0]
2020-05-24T10:57:53.345618|[0.0, 0.0, 0.0, 0.0]
For each Nth timestamp there are N*3 images. For example - 4 timestamps = 12 images. I would like to concatenate all the 3 images for every timestamp as one in axis = 2. Result dimension would be 70x320x9
. Then go through all the rows in such a way and get an end tensor of dimension Nx70x320x9
I solved that with help from here -- Python - Numpy 3D array - concatenate issues using dictionary for each timestamp and concatenating later.
collected_images[timepoint].append(image)
.
.
.
output = []
for key, val in collected_iamges.items():
temp = np.concatenate(val, axis=2)
output.append(temp[np.newaxis, ...])
output = np.concatenate(output, axis=0)
However,as you would've guessed when applied to 105K timestamps(105K *3 images), the script crashes with OOM. This is where I seek your help.
- I'm looking for ideas to solve this bottleneck. What other strategy can I use to accomplish my requirement.
- Is it possible to do some modifications to overcome the kernel OOM behaviour temporarily?