def log_device_info(device, prefix: str, csvwriter, display_log):
    """
    Logs device information.

    Parameters:
        device: The device object with GPU information.
        prefix: The prefix string for log identification.
        csvwriter: The CSV writer object for writing logs to a file.
        display_log: print out on shell
    """
    total_memory_gb = float(device.memory_total_human()[:-3])
    used_memory_bytes = device.memory_used()
    gpu_utilization = device.gpu_utilization()

    if display_log:
        print(f"Device: {device.name}")
        print(f"  - Used memory    : {bytes_to_gb(used_memory_bytes):.2f} GB")
        print(f"  - Used memory%   : {bytes_to_gb(used_memory_bytes)/total_memory_gb * 100:.2f}%")
        print(f"  - GPU utilization: {gpu_utilization}%")
        print("-" * 40)

    current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    (bytes_to_gb(used_memory_bytes) / total_memory_gb) * 100

    csvwriter.writerow([current_time, bytes_to_gb(used_memory_bytes), gpu_utilization])

    Logs device information.

    Parameters:
        device: The device object with GPU information.
        prefix: The prefix string for log identification.
        csvwriter: The CSV writer object for writing logs to a file.
        display_log: print out on shell
    
scripts/train_kohya/utils/gpu_info.py