delphi-suite / delphi

small language models training made easy
Apache License 2.0
8 stars 1 forks source link

run_context.json should register the GPU used #141

Closed jettjaniak closed 1 month ago

jettjaniak commented 1 month ago

it just says "cuda"

jettjaniak commented 1 month ago

gpt says

import torch
import subprocess

def get_gpu_info():
    if torch.cuda.is_available():
        gpu_id = torch.cuda.current_device()
        gpu_name = torch.cuda.get_device_name(gpu_id)
        try:
            result = subprocess.check_output(['nvidia-smi', '--query-gpu=gpu_name', '--format=csv,noheader'], encoding='utf-8')
            gpu_name = result.strip().split('\n')[gpu_id]
        except subprocess.CalledProcessError as e:
            print(f"Error executing nvidia-smi: {e}")
            gpu_name = torch.cuda.get_device_name(gpu_id)
        return gpu_name
    else:
        return "No GPU available."

print(get_gpu_info())