一. Ubuntu 换源
# sed -i 's|ports.ubuntu.com|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
# apt update -y
二. Pip 换源
# pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
三. python 检查 CUDA 是否可用
import torch
# 1. 检查CUDA是否可用
if torch.cuda.is_available():
print("CUDA is available!")
# 2. 查看当前CUDA版本
print("CUDA version:", torch.version.cuda)
# 3. 查看GPU设备数量
print("GPU devices:", torch.cuda.device_count())
# 4. 查看当前GPU设备名称
print("Device name:", torch.cuda.get_device_name(0))
else:
print("CUDA is not available.")