silx
silx copied to clipboard
GPU memory used when devicetype='CPU'
trafficstars
After running the following code in a notebook (so the process stays alive), a look at nvidia-smi shows there has been memory reserved on the GPU. If that is expected, is there any way to prevent that?
import numpy as np
from silx.opencl import sift
devicetype = 'CPU'
shape = (512, 512)
im1 = np.random.randint(0, 65536, shape, np.uint16)
sift_ocl = sift.SiftPlan(shape=im1.shape, dtype=im1.dtype, devicetype=devicetype)
keypoints1 = sift_ocl.keypoints(im1)
Hi @chrisroat
These contexts are created when silx.opencl.common scans the available platforms/devices with pyopencl.get_platforms(). These contexts are unfortunately not destroyed if the nvidia-persistenced daemon is running.
So regardless if you choose a "CPU" device, importing any silx.opencl module will do this "scanning" step to build the ocl = OpenCL() singleton.
To restrict visible platforms/devices, you can use environment variables, for example:
PYOPENCL_CTX="0:" to restrict opencl to platform 0CUDA_VISIBLE_DEVICES=""to ignore all Nvidia GPUs (GPU_DEVICE_ORDINALfor AMD GPUs)