Exemple #1
0
async def get_gpu_details():
    """Gets GPU details from nvidia-smi."""
    details = {
        NAME: '',
        DRIVER_VERSION: '',
        CUDA_VERSION: '',
        COUNT: 0,
        GPU: 0,
        MEMORY: 0,
        TEMPERATURE: '',
    }
    app_log.debug('Getting GPU information from nvidia-smi')
    process = await asyncio.create_subprocess_shell(
        NVIDIA_CMD,
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE)
    stdout, _ = await process.communicate()

    if process.returncode != 0:
        app_log.warning('Unable to determine GPU information')
        return details

    root = xml.fromstring(stdout)
    details[DRIVER_VERSION] = root.find(DRIVER_VERSION).text
    details[CUDA_VERSION] = root.find(CUDA_VERSION).text
    gpu = root.find(GPU)
    details[COUNT] = int(root.find('attached_gpus').text)
    details[NAME] = gpu.find('product_name').text
    utilization = gpu.find('utilization')
    details[GPU] = int(utilization.find('gpu_util').text[:-1].strip())
    details[MEMORY] = int(utilization.find('memory_util').text[:-1].strip())
    details[TEMPERATURE] = gpu.find(TEMPERATURE).find('gpu_temp').text

    return details
Exemple #2
0
 def get(self):
     version = 'unknown'
     try:
         env_version = os.environ[FRAMEWORK_ENV_VAR]
         with open(env_version) as f:
             version = f.read().rstrip()
     except KeyError:
         app_log.warning('Environment variable %s is not set',
                         FRAMEWORK_ENV_VAR)
     except OSError:
         app_log.warning('Unable to read framework version from %s',
                         os.environ[FRAMEWORK_ENV_VAR])
     self.finish(version)
"""Initialize server endpoints for extension"""
from notebook.utils import url_path_join
from notebook.base.handlers import app_log

from jupyterlab_bigquery.create_handler import Handlers
from jupyterlab_bigquery.version import VERSION
from jupyterlab_bigquery.query_history_handler import QueryHistoryHandler, GetQueryDetailsHandler
from jupyterlab_bigquery.pagedAPI_handler import PagedQueryHandler

in_cell_editor_enabled = False
try:
    from jupyterlab_bigquery.query_incell_editor import QueryIncellEditor, _cell_magic
    in_cell_editor_enabled = True
except ModuleNotFoundError:
    app_log.warning("Does not support in-cell editor")

__version__ = VERSION


def _jupyter_server_extension_paths():
    return [{'module': 'jupyterlab_bigquery'}]


def load_jupyter_server_extension(nb_server_app):
    """
      Called when the extension is loaded.
      Args:
          nb_server_app (NotebookWebApplication):
            handle to the Notebook webserver instance.
      """
    host_pattern = '.*$'