Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report mode GPU is in and write out gpu UUID #699

Merged
merged 11 commits into from
Jun 2, 2023
15 changes: 10 additions & 5 deletions openmmtools/multistate/multistatesampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import inspect
import logging
import datetime
import subprocess

import numpy as np

Expand Down Expand Up @@ -1773,11 +1774,15 @@ def _update_timing(self, iteration_time, partial_total_time, run_initial_iterati
@staticmethod
def _display_cuda_devices():
"""Query system nvidia-smi to get available GPUs indices and names in debug log."""
# Read nvidia-smi query, should return empty strip if no GPU is found.
cuda_query_output = os.popen("nvidia-smi --query-gpu=index,gpu_name --format=csv,noheader").read().strip()
# Split by line jump and comma
cuda_devices_list = [entry.split(',') for entry in cuda_query_output.split('\n')]
logger.debug(f"CUDA devices available: {*cuda_devices_list,}")
try:
cuda_query_output = subprocess.run("nvidia-smi --query-gpu=gpu_uuid,gpu_name,compute_mode --format=csv", shell=True, capture_output=True, text=True)
mikemhenry marked this conversation as resolved.
Show resolved Hide resolved
# Split by line jump and comma
cuda_devices_list = [entry for entry in cuda_query_output.stdout.splitlines()]
logger.debug(f"CUDA devices available: {*cuda_devices_list,}")
if "Exclusive_Process" in cuda_query_output.stdout:
mikemhenry marked this conversation as resolved.
Show resolved Hide resolved
logger.warn(f"GPU in 'Exclusive_Process' mode, one context is allowed per device. This may prevent some openmmtools features from working.")
except CalledProcessError:
logger.debug(f"nvidia-smi command failed: {cuda_query_output.stderr}, this is expected if there is no GPU available")

def _flatten_moves_iterator(self):
"""Recursively flatten MCMC moves. Handles the cases where each move can be a set of moves, for example with
Expand Down