<jupyter_start><jupyter_text>File Logger ExampleThis notebook is a small demo of how to use gpumon in Jupyter notebooks and some convenience methods for working with GPUs<jupyter_code>from gpumon.file import log_context<jupyter_output><empty_output><jupyter_text>device_name and device_count will return the name of the GPU found on the system and the number of GPUs<jupyter_code>from gpumon import device_name, device_count
device_count() # Returns the number of GPUs available
device_name() # Returns the type of GPU available
from bokeh.io import output_notebook, show
import time
output_notebook()<jupyter_output><empty_output><jupyter_text>Here we are simply going to tell the log context to record GPU measurements to the file test_gpu.txt<jupyter_code>with log_context('test_gpu.txt') as log:
    time.sleep(10)<jupyter_output><empty_output><jupyter_text>We can then cat the file to see what we recorded in the 10 seconds<jupyter_code>!cat test_gpu.txt<jupyter_output>#Date       Time        gpu   pwr  temp    sm   mem   enc   dec  mclk  pclk
#YYYYMMDD   HH:MM:SS    Idx     W     C     %     %     %     %   MHz   MHz
 20180330   16:21:28      0    10    21     0     0     0     0   405   544
 20180330   16:21:28      1     9    26     0     0     0     0   405   544
 20180330   16:21:28      2     9    21     0     0     0     0   405   544
 20180330   16:21:28      3     9    21     0     0     0     0   405   544
 20180330   16:21:29      0     9    21     0     0     0     0   405   544
 20180330   16:21:29      1     9    26     0     0     0     0   405   544
 20180330   16:21:29      2     9    21     0     0     0     0   405   544
 20180330   16:21:29      3     9    21     0     0     0     0   405   544
 20180330   16:21:31      0     9    21     0     0     0     0   405   544
 20180330   16:21:31      1     9    26     0     0     0     0   405   544
 20180330   16:21:31      2     9    21     0     0     0     0   405   544
[...]<jupyter_text>By calling the log object we get all the data returned to us in a dataframe<jupyter_code>df = log()
df<jupyter_output><empty_output><jupyter_text>We can also call plot on the log object to plot the measurements we want<jupyter_code>p = log.plot(gpu_measurement='pwr', num_gpus=4)
show(p)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.05235828645607962, 'fraction_numerical': 0.13587191691908265, 'mean_word_length': 2.050131926121372, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '284663', 'license': 'MIT', 'n_tokens_mistral': 969, 'n_tokens_neox': 789, 'n_words': 280, 'path': 'examples/notebooks/FileLoggerExample.ipynb', 'repo_name': 'msalvaris/gpu_monitor', 'size': '2311'}