ubuntu 20.04 pytorch 安装 数据加载预处理

安装

安装 pytorch 运行环境 本文基于Ubuntu 20.04 server版 安装pytorch相关。

安装cuda cudnn

参考文章 cuda113 cudNN.

显卡驱动

查看硬件 显卡信息

 lspci | grep -e VGA
04:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
05:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
08:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
09:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
0c:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 30)
84:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
85:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
88:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)
89:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1)

查看当前显卡驱动

dpkg -l | grep nvidia

在这里插入图片描述

查看显卡可用驱动

ubuntu-drivers devices

在这里插入图片描述

卸载旧的

sudo apt-get purge nvidia*
sudo apt autoremove

更新最新的驱动

sudo add-apt-repository ppa:graphics-drivers/ppa -y
sudo apt update
sudo apt install nvidia-driver-510 -y

nvidia-smi 查看驱动 cuda nvcc

在这里插入图片描述

nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0

安装pytorch

进去 Pytorch 官网

根据需求进行配置
在这里插入图片描述

安装命令

pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

IDE. Pycharm

安装

进入pycharm官网
下载需要的版本

配置远程调试

配置SSH

在这里插入图片描述

配置interpreter

在这里插入图片描述

pythorch 打印 cuda等信息

import torch

def print_torch():
    print(torch.__version__)
    print('device:', torch.cuda.current_device())
    print('count:', torch.cuda.device_count())
    print('name:', torch.cuda.get_device_name(0))
    print('gpu:', torch.cuda.is_available())

if __name__ == '__main__':
    print_torch()

打印结果:

1.10.2+cu113
device: 0
count: 8
name: NVIDIA GeForce GTX 1080
gpu: True

Process finished with exit code 

参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lin_AIOS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值