1
0

refactor: merge multiple project into one and create new project

This commit is contained in:
2026-04-07 08:30:41 +08:00
parent 7aa7ae3335
commit 6cb1a89751
49 changed files with 2932 additions and 4 deletions

17
dl-exp/gpu_utils.py Normal file
View File

@@ -0,0 +1,17 @@
import torch
def print_gpu_availability():
"""打印PyTorch的GPU可用性"""
if torch.cuda.is_available():
print(f"GPU可用{torch.cuda.get_device_name(0)}")
else:
print("GPU不可用")
def get_gpu_device() -> torch.device:
"""获取PyTorch的GPU设备"""
if torch.cuda.is_available():
return torch.device("cuda")
else:
raise Exception("找不到CUDA")