Hello ptrblck :
When the programme start , first run at
time.sleep(5)

GPU state as following ,only take 650MB

image632×512 82.8 KB

When in loop function ,GPU state as following ,take 1136MiB

image637×534 87 KB

When the loop function return to test function ,python still resident in GPU memory ,take 1028MiB

How to release GPU resource when loop function return , which means no python resident in GPU memory ? Than you.