import torch
# 检查CUDA是否可用
cuda_available = torch.cuda.is_available()
if cuda_available:
print(f"CUDA is available with version: {torch.version.cuda}")
else:
print("CUDA is not available.")
# 检查PyTorch版本
print(f"PyTorch version: {torch.__version__}")
# 检查CUDA的device属性
if cuda_available:
device = torch.device("cuda")
print(f"CUDA device name: {torch.cuda.get_device_name(0)}")
print(f"CUDA device memory: {torch.cuda.get_device_properties(0).total_memory / 1024 ** 2} MB")
输出:
"D:\software install location\anaconda\envs\idm\python.exe" "E:/008 virtual_clothes/IDM-VTON/测试.py"
CUDA is available with version: 11.8
PyTorch version: 2.0.1+cu118
CUDA device name: NVIDIA GeForce RTX 4080
CUDA device memory: 16375.375 MB
进程已结束,退出代码为 0