Created
October 31, 2018 03:14
-
-
Save serihiro/4a9dace1235ce692a18d597c588dab06 to your computer and use it in GitHub Desktop.
nvidia-ml-py3 sample https://pypi.org/project/nvidia-ml-py3/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pynvml | |
| pynvml.nvmlInit() | |
| handle0 = pynvml.nvmlDeviceGetHandleByIndex(0) | |
| handle1 = pynvml.nvmlDeviceGetHandleByIndex(1) | |
| util_rate0 = pynvml.nvmlDeviceGetUtilizationRates(handle0) | |
| util_rate1 = pynvml.nvmlDeviceGetUtilizationRates(handle1) | |
| print(f'device0 nvml.util.gpu: {util_rate0.gpu}') | |
| print(f'device0 nvml.util.gpu: {util_rate0.memory}') | |
| print(f'device1 nvml.util.gpu: {util_rate1.gpu}') | |
| print(f'device1 nvml.util.gpu: {util_rate1.memory}') | |
| print('') | |
| mem0 = pynvml.nvmlDeviceGetMemoryInfo(handle0) | |
| mem1 = pynvml.nvmlDeviceGetMemoryInfo(handle1) | |
| print(f'device0 nvml.mem.total: {mem0.total}') | |
| print(f'device0 nvml.mem.used: {mem0.used}') | |
| print(f'device0 nvml.mem.free: {mem0.free}') | |
| print(f'device1 nvml.mem.total: {mem1.total}') | |
| print(f'device1 nvml.mem.used: {mem1.used}') | |
| print(f'device1 nvml.mem.free: {mem1.free}') | |
| pynvml.nvmlShutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment