Ubuntu22.04安装AMD显卡驱动和pytorch

Posted V2077

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu22.04安装AMD显卡驱动和pytorch相关的知识,希望对你有一定的参考价值。

安装pip和vim

sudo apt-get -y install python3-pip vim

配置pip源

mkdir ~/.pip && vim ~/.pip/pip.conf

pip.conf

[global]
index-url = https://mirrors.cloud.tencent.com/pypi/simple
[install]
trusted-host = mirrors.cloud.tencent.com

安装显卡驱动 

$ cd ~
$ uname -srmv # rocm5.4.2需要Ubuntu内核5.15+

# Ubuntu v22.04
$ wget https://repo.radeon.com/amdgpu-install/5.4.2/ubuntu/jammy/amdgpu-install_5.4.50402-1_all.deb 

# Ubuntu v20.04
# wget https://repo.radeon.com/amdgpu-install/5.4.2/ubuntu/focal/amdgpu-install_5.4.50402-1_all.deb

$ sudo apt-get install ./amdgpu-install_5.4.50402-1_all.deb
$ sudo apt-get update
# docker安装需要修改参数,详情参考rocm安装文档
$ amdgpu-install -y --usecase=graphics,rocm

# 设置运行权限
$ ls -l /dev/dri/render*
$ sudo usermod -a -G render $LOGNAME
$ sudo usermod -a -G video $LOGNAME

# 重启
$ reboot
# 验证
$ dkms status
$ /opt/rocm-5.4.2/bin/rocminfo
# 或者
$ /opt/rocm-5.4.2/opencl/bin/clinfo
$ rocm-smi # 显示GPU活动信息

安装pytorch和测试

$ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2
$ python3
>> import torch
>> torch.cuda.is_available() # true为安装成功

参考资料

pytorch官网
AMD显卡驱动下载

AMD显卡驱动安装文档

ROCm安装文档

ubuntu下安装Amd RX470驱动

0X:ADM官方下载驱动

https://www.amd.com/en/support

查看本机驱动命令

lspci | grep -i vga

选择自己的驱动

下载对应的版本

现在最新的是:amdgpu-pro-18.50-756341-ubuntu-18.04.tar.tar

链接:https://pan.baidu.com/s/1QAdRThnOWP_fxtocVyiTkg
提取码:hasv

1X:安装驱动,Hashcat需要Opencl的支持

官方安装帮助文档https://www.amd.com/en/support/kb/release-notes/amdgpu-installation

安装分为amdgpu-pro-install -y安装和 ./amdgpu-install -y

官方说这2命令是一样的,实测还是有区别的,我的显卡的主板都比老,如果安装pro版,就会报错 无法进入系统

安装amdgpu一切正常

安装命令

 ./amdgpu-install -y --opencl=pal,legacy

 执行后的图片

2X:进入hashcat目录执行安装命令

1 make
2 make install

执行第二个命令的时候会提示无权限,这时候切换到ROOT账号,如果没有设置就新建

1  $sudo passwd root # 新建账号

2 根据提示设置密码
3 $su #切换到root账号

安装完毕

$hashcat -I  #显示当前GPU
$hashcat -b  #测试性能

性能结果

h@h-Default-string:~/下载/hashcat-5.1.0$ hashcat -b
hashcat (v5.1.0) starting in benchmark mode...

Benchmarking uses hand-optimized kernel code by default.
You can use it in your cracking session by setting the -O option.
Note: Using optimized kernel code limits the maximum supported password length.
To disable the optimized kernel code in benchmark mode, use the -w option.

OpenCL Platform #1: Advanced Micro Devices, Inc.
================================================
* Device #1: Ellesmere, 3263/4090 MB allocatable, 28MCU
* Device #2: Ellesmere, 3263/4090 MB allocatable, 28MCU
* Device #3: Ellesmere, 3263/4090 MB allocatable, 28MCU
* Device #4: Ellesmere, 3263/4090 MB allocatable, 28MCU
* Device #5: Ellesmere, 3476/4090 MB allocatable, 28MCU
* Device #6: Ellesmere, 3476/4090 MB allocatable, 28MCU
* Device #7: Ellesmere, 3476/4090 MB allocatable, 28MCU
* Device #8: Ellesmere, 3476/4090 MB allocatable, 28MCU

Benchmark relevant options:
===========================
* --optimized-kernel-enable

Hashmode: 0 - MD5

Speed.#1.........:  6625.2 MH/s (69.96ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#2.........:  6619.4 MH/s (69.96ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#3.........:  6618.6 MH/s (69.96ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#4.........:  6619.2 MH/s (69.96ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#5.........:  6618.4 MH/s (69.96ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#6.........:  6619.5 MH/s (69.96ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#7.........:  6625.4 MH/s (69.96ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#8.........:  6618.6 MH/s (69.96ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#*.........: 52964.3 MH/s

Hashmode: 100 - SHA1

Speed.#1.........:  2346.0 MH/s (49.31ms) @ Accel:128 Loops:128 Thr:256 Vec:1
Speed.#2.........:  2346.3 MH/s (49.31ms) @ Accel:128 Loops:128 Thr:256 Vec:1
Speed.#3.........:  2346.5 MH/s (49.31ms) @ Accel:128 Loops:128 Thr:256 Vec:1
Speed.#4.........:  2351.2 MH/s (49.31ms) @ Accel:128 Loops:128 Thr:256 Vec:1
Speed.#5.........:  2351.0 MH/s (49.31ms) @ Accel:128 Loops:128 Thr:256 Vec:1
Speed.#6.........:  2346.1 MH/s (49.31ms) @ Accel:128 Loops:128 Thr:256 Vec:1
Speed.#7.........:  2346.3 MH/s (49.31ms) @ Accel:128 Loops:128 Thr:256 Vec:1
Speed.#8.........:  2346.5 MH/s (49.31ms) @ Accel:128 Loops:128 Thr:256 Vec:1
Speed.#*.........: 18779.9 MH/s

Hashmode: 1400 - SHA2-256

Speed.#1.........:  1025.7 MH/s (56.63ms) @ Accel:128 Loops:64 Thr:256 Vec:1
Speed.#2.........:  1025.8 MH/s (56.64ms) @ Accel:128 Loops:64 Thr:256 Vec:1
Speed.#3.........:  1027.0 MH/s (56.64ms) @ Accel:128 Loops:64 Thr:256 Vec:1
Speed.#4.........:  1025.7 MH/s (56.64ms) @ Accel:128 Loops:64 Thr:256 Vec:1
Speed.#5.........:  1027.0 MH/s (56.64ms) @ Accel:128 Loops:64 Thr:256 Vec:1
Speed.#6.........:  1026.0 MH/s (56.64ms) @ Accel:128 Loops:64 Thr:256 Vec:1
Speed.#7.........:  1026.0 MH/s (56.64ms) @ Accel:128 Loops:64 Thr:256 Vec:1
Speed.#8.........:  1025.8 MH/s (56.64ms) @ Accel:128 Loops:64 Thr:256 Vec:1
Speed.#*.........:  8209.0 MH/s

Hashmode: 1700 - SHA2-512

Speed.#1.........:   249.2 MH/s (58.39ms) @ Accel:64 Loops:32 Thr:256 Vec:1
Speed.#2.........:   248.6 MH/s (58.39ms) @ Accel:64 Loops:32 Thr:256 Vec:1
Speed.#3.........:   248.6 MH/s (58.39ms) @ Accel:64 Loops:32 Thr:256 Vec:1
Speed.#4.........:   248.6 MH/s (58.39ms) @ Accel:64 Loops:32 Thr:256 Vec:1
Speed.#5.........:   248.6 MH/s (58.39ms) @ Accel:64 Loops:32 Thr:256 Vec:1
Speed.#6.........:   248.6 MH/s (58.38ms) @ Accel:64 Loops:32 Thr:256 Vec:1
Speed.#7.........:   249.3 MH/s (58.39ms) @ Accel:64 Loops:32 Thr:256 Vec:1
Speed.#8.........:   248.6 MH/s (58.38ms) @ Accel:64 Loops:32 Thr:256 Vec:1
Speed.#*.........:  1990.1 MH/s

Hashmode: 2500 - WPA-EAPOL-PBKDF2 

Speed.#1.........:   115.5 kH/s (61.38ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#2.........:   115.5 kH/s (61.38ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#3.........:   115.5 kH/s (61.38ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#4.........:   115.5 kH/s (61.38ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#5.........:   115.5 kH/s (61.38ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#6.........:   115.5 kH/s (61.38ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#7.........:   115.5 kH/s (61.38ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#8.........:   115.5 kH/s (61.38ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#*.........:   924.0 kH/s

Hashmode: 1000 - NTLM

Speed.#1.........: 12819.8 MH/s (72.64ms) @ Accel:128 Loops:1024 Thr:256 Vec:1
Speed.#2.........: 12810.5 MH/s (72.65ms) @ Accel:128 Loops:1024 Thr:256 Vec:1
Speed.#3.........: 12811.2 MH/s (72.64ms) @ Accel:128 Loops:1024 Thr:256 Vec:1
Speed.#4.........: 12819.9 MH/s (72.64ms) @ Accel:128 Loops:1024 Thr:256 Vec:1
Speed.#5.........: 12812.8 MH/s (72.64ms) @ Accel:128 Loops:1024 Thr:256 Vec:1
Speed.#6.........: 12811.3 MH/s (72.64ms) @ Accel:128 Loops:1024 Thr:256 Vec:1
Speed.#7.........: 12810.6 MH/s (72.64ms) @ Accel:128 Loops:1024 Thr:256 Vec:1
Speed.#8.........: 12808.5 MH/s (72.64ms) @ Accel:128 Loops:1024 Thr:256 Vec:1
Speed.#*.........:   102.5 GH/s

Hashmode: 3000 - LM

Speed.#1.........:  6507.0 MH/s (71.13ms) @ Accel:64 Loops:1024 Thr:256 Vec:1
Speed.#2.........:  6511.0 MH/s (71.13ms) @ Accel:64 Loops:1024 Thr:256 Vec:1
Speed.#3.........:  6507.3 MH/s (71.13ms) @ Accel:64 Loops:1024 Thr:256 Vec:1
Speed.#4.........:  6508.2 MH/s (71.13ms) @ Accel:64 Loops:1024 Thr:256 Vec:1
Speed.#5.........:  6510.5 MH/s (71.13ms) @ Accel:64 Loops:1024 Thr:256 Vec:1
Speed.#6.........:  6507.5 MH/s (71.11ms) @ Accel:64 Loops:1024 Thr:256 Vec:1
Speed.#7.........:  6509.8 MH/s (71.13ms) @ Accel:64 Loops:1024 Thr:256 Vec:1
Speed.#8.........:  6507.5 MH/s (71.13ms) @ Accel:64 Loops:1024 Thr:256 Vec:1
Speed.#*.........: 52068.9 MH/s

Hashmode: 5500 - NetNTLMv1 / NetNTLMv1+ESS

Speed.#1.........:  7260.3 MH/s (63.99ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#2.........:  7263.4 MH/s (64.00ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#3.........:  7268.0 MH/s (64.00ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#4.........:  7266.7 MH/s (64.00ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#5.........:  7266.0 MH/s (64.00ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#6.........:  7267.0 MH/s (64.00ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#7.........:  7260.7 MH/s (64.00ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#8.........:  7262.8 MH/s (63.99ms) @ Accel:128 Loops:512 Thr:256 Vec:1
Speed.#*.........: 58114.8 MH/s

Hashmode: 5600 - NetNTLMv2

Speed.#1.........:   473.2 MH/s (61.31ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#2.........:   473.0 MH/s (61.32ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#3.........:   474.2 MH/s (61.32ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#4.........:   474.2 MH/s (61.32ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#5.........:   474.1 MH/s (61.32ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#6.........:   473.2 MH/s (61.31ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#7.........:   473.2 MH/s (61.32ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#8.........:   474.3 MH/s (61.32ms) @ Accel:128 Loops:32 Thr:256 Vec:1
Speed.#*.........:  3789.3 MH/s

Hashmode: 1500 - descrypt, DES (Unix), Traditional DES

Speed.#1.........:   252.6 MH/s (57.05ms) @ Accel:2 Loops:1024 Thr:256 Vec:1
Speed.#2.........:   252.6 MH/s (57.05ms) @ Accel:2 Loops:1024 Thr:256 Vec:1
Speed.#3.........:   252.7 MH/s (57.05ms) @ Accel:2 Loops:1024 Thr:256 Vec:1
Speed.#4.........:   252.7 MH/s (57.04ms) @ Accel:2 Loops:1024 Thr:256 Vec:1
Speed.#5.........:   252.7 MH/s (57.04ms) @ Accel:2 Loops:1024 Thr:256 Vec:1
Speed.#6.........:   252.8 MH/s (57.04ms) @ Accel:2 Loops:1024 Thr:256 Vec:1
Speed.#7.........:   252.7 MH/s (57.04ms) @ Accel:2 Loops:1024 Thr:256 Vec:1
Speed.#8.........:   252.8 MH/s (57.04ms) @ Accel:2 Loops:1024 Thr:256 Vec:1
Speed.#*.........:  2021.6 MH/s

Hashmode: 500 - md5crypt, MD5 (Unix), Cisco-IOS $1$ (MD5) (Iterations: 1000)

Speed.#1.........:  2630.4 kH/s (84.58ms) @ Accel:512 Loops:250 Thr:64 Vec:1
Speed.#2.........:  2699.0 kH/s (82.34ms) @ Accel:512 Loops:250 Thr:64 Vec:1
Speed.#3.........:  2701.9 kH/s (82.34ms) @ Accel:512 Loops:250 Thr:64 Vec:1
Speed.#4.........:  2694.6 kH/s (82.34ms) @ Accel:512 Loops:250 Thr:64 Vec:1
Speed.#5.........:  2701.5 kH/s (82.34ms) @ Accel:512 Loops:250 Thr:64 Vec:1
Speed.#6.........:  2696.8 kH/s (82.34ms) @ Accel:512 Loops:250 Thr:64 Vec:1
Speed.#7.........:  2703.5 kH/s (82.34ms) @ Accel:512 Loops:250 Thr:64 Vec:1
Speed.#8.........:  2702.3 kH/s (82.35ms) @ Accel:512 Loops:250 Thr:64 Vec:1
Speed.#*.........: 21529.9 kH/s

Hashmode: 3200 - bcrypt $2*$, Blowfish (Unix) (Iterations: 32)

Speed.#1.........:     5689 H/s (76.65ms) @ Accel:16 Loops:4 Thr:8 Vec:1
Speed.#2.........:     5688 H/s (76.65ms) @ Accel:16 Loops:4 Thr:8 Vec:1
Speed.#3.........:     5681 H/s (76.65ms) @ Accel:16 Loops:4 Thr:8 Vec:1
Speed.#4.........:     5694 H/s (76.65ms) @ Accel:16 Loops:4 Thr:8 Vec:1
Speed.#5.........:     5692 H/s (76.66ms) @ Accel:16 Loops:4 Thr:8 Vec:1
Speed.#6.........:     5688 H/s (76.65ms) @ Accel:16 Loops:4 Thr:8 Vec:1
Speed.#7.........:     5688 H/s (76.65ms) @ Accel:16 Loops:4 Thr:8 Vec:1
Speed.#8.........:     5691 H/s (76.65ms) @ Accel:16 Loops:4 Thr:8 Vec:1
Speed.#*.........:    45512 H/s

Hashmode: 1800 - sha512crypt $6$, SHA512 (Unix) (Iterations: 5000)

Speed.#1.........:    43259 H/s (66.41ms) @ Accel:128 Loops:64 Thr:64 Vec:1
Speed.#2.........:    43103 H/s (66.49ms) @ Accel:128 Loops:64 Thr:64 Vec:1
Speed.#3.........:    43263 H/s (66.37ms) @ Accel:128 Loops:64 Thr:64 Vec:1
Speed.#4.........:    43263 H/s (66.38ms) @ Accel:128 Loops:64 Thr:64 Vec:1
Speed.#5.........:    43208 H/s (66.40ms) @ Accel:128 Loops:64 Thr:64 Vec:1
Speed.#6.........:    43107 H/s (66.52ms) @ Accel:128 Loops:64 Thr:64 Vec:1
Speed.#7.........:    43247 H/s (66.40ms) @ Accel:128 Loops:64 Thr:64 Vec:1
Speed.#8.........:    43244 H/s (66.40ms) @ Accel:128 Loops:64 Thr:64 Vec:1
Speed.#*.........:   345.7 kH/s

Hashmode: 7500 - Kerberos 5 AS-REQ Pre-Auth etype 23

Speed.#1.........: 78708.9 kH/s (92.58ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#2.........: 78723.9 kH/s (92.54ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#3.........: 78789.1 kH/s (92.59ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#4.........: 78702.9 kH/s (92.56ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#5.........: 78714.3 kH/s (92.57ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#6.........: 78709.0 kH/s (92.58ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#7.........: 78707.4 kH/s (92.56ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#8.........: 78789.3 kH/s (92.55ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#*.........:   629.8 MH/s

Hashmode: 13100 - Kerberos 5 TGS-REP etype 23

Speed.#1.........: 78335.7 kH/s (92.90ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#2.........: 78310.2 kH/s (93.00ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#3.........: 78338.1 kH/s (93.00ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#4.........: 78288.3 kH/s (93.01ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#5.........: 78341.1 kH/s (93.00ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#6.........: 78297.4 kH/s (92.98ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#7.........: 78312.2 kH/s (93.00ms) @ Accel:128 Loops:32 Thr:64 Vec:1
Speed.#8.........: 78312.4 kH/s (Ubuntu 22.04安装Cuda11.7和cudnn8.6

Ubuntu22.04安装nvidia显卡驱动

ubuntu18.04/20.04/22.04安装显卡驱动与显卡信息查询

Ubuntu 22.04 LTS (Jammy Jellyfish) Daily Build安装镜像PC ARM Raspberry Pi

Ubuntu22.04+Nvidia驱动+Cuda11.8+cudnn8.6

Ubuntu22.04+Nvidia驱动+Cuda11.8+cudnn8.6