Skip to content

Instantly share code, notes, and snippets.

View udibr's full-sized avatar
🏠
Working from home

Ehud Ben-Reuven udibr

🏠
Working from home
View GitHub Profile
@udibr
udibr / py_cudart_memory.py
Last active January 18, 2016 17:45 — forked from justinfx/py_cudart_memory.py
Get memory usage of CUDA GPU, using ctypes and libcudart
import ctypes
# Path to location of libcudart
# Change the path to "cudart<x>_<ver>.dll" to use on Windows, where <x>={32|64} and <ver> is the CUDA version.
_CUDA = "/usr/local/cuda/lib/libcudart.dylib"
cuda = ctypes.cdll.LoadLibrary(_CUDA)
cuda.cudaMemGetInfo.restype = int
cuda.cudaMemGetInfo.argtypes = [ctypes.c_void_p, ctypes.c_void_p]