目录
1. 硬件配置
2. 配置两款型号遇见的问题
3. 软件方面
4. 测试使用
1. 硬件配置
显卡3080
显卡2080ti
2. 配置两款型号遇见的问题
(1)显卡电源线不够
只有两根8pin电源线
追加显卡的话需要额外买一根电源线,我买了一个8pin转双6+2pin电源线,型号是:佳翼(JEYI)显卡电源线 台式主机8Pin母转双6+2pin公头电源供电转接线 8P转双6+2P延长线加长线 XK888,花费19.9.
(2)机箱空间不够
买了显卡电源线后,发现空间不够,且显卡间的插槽靠得太近,所以额外又买了显卡数据延长线,型号:追风者(PHANTEKS) FL22 PCI-E4.0 x16倍 通用型无损耗电脑竖向显卡延长线180°转 90°转接延长线220mm(不推荐这款,线过短,可以选30cm的)
硬件搞定后,整体效果如下,虽然丑,但能用:
3. 软件方面
检查系统是否能检测到显卡,注意显卡驱动用的是511.79
4. 测试使用
测试代码:
import torch
from tqdm import tqdm
import torch.nn as nnclass Model(torch.nn.Module):def __init__(self, in_channels, out_channels, kernel_size, stride=1):super(Model, self).__init__()self.conv = torch.nn.Sequential(nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride))def forward(self, x):b = self.conv(x)loss = torch.sum(b)loss = loss * lossreturn loss, xif __name__ == '__main__':a = torch.randn([4, 3, 500, 500])model = Model(3, 100, 1, 1)device = torch.device("cuda" if torch.cuda.is_available() else "cpu")if torch.cuda.is_available():print("using cuda")model = model.cuda(device)a = a.cuda()print(torch.cuda.device_count() > 1)if torch.cuda.device_count() > 1:model = torch.nn.DataParallel(model)passoptimizor = torch.optim.Adam(model.parameters(), lr=0.005)for i in tqdm(range(100000000)):loss, _ = model(a)optimizor.zero_grad()loss.backward(torch.ones_like(loss))optimizor.step()if i % 100 == 0:pass