关于nvidia,python,pytorch,cuda,tensorflow,cudnn 的版本对照,官方链接及简短安装

GeForce® 驱动程序

控制面板

opencv-python GPU 读取 rtsp

cuda

# 自定义安装

# 安装路径
# CUDA Development
D:\NVIDIA GPU Computing Toolkit\CUDA\v12.0
# CUDA Documentation
D:\NVIDIA GPU Computing Toolkit\CUDA\v12.0
# Samples
D:\NVIDIA Corporation\CUDA\Samples\v12.0

# 添加系统环境变量
CUDA_PATH
D:\NVIDIA GPU Computing Toolkit\CUDA\v12.0

CUDA_PATH_V12_0
D:\NVIDIA GPU Computing Toolkit\CUDA\v12.0

# 添加 path 变量
D:\NVIDIA GPU Computing Toolkit\CUDA\v12.0\bin
D:\NVIDIA GPU Computing Toolkit\CUDA\v12.0\libnvvp
D:\NVIDIA GPU Computing Toolkit\CUDA\v12.0\include

# 验证
nvcc -V
CUDA ToolkitMinimum Required Driver Version for CUDA Minor Version Compatibility*
Linux x86_64 Driver VersionWindows x86_64 Driver Version
CUDA 12.x>=525.60.13>=528.33
CUDA 11.8.x CUDA 11.7.x CUDA 11.6.x CUDA 11.5.x CUDA 11.4.x CUDA 11.3.x CUDA 11.2.x CUDA 11.1.x>=450.80.02>=452.39
CUDA 11.0 (11.0.3)>=450.36.06**>=451.22**

torch

import torch
print(torch.__version__)
print(torch.cuda.is_available())

cuDNN

# 将文件放入对应文件内

# ...\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\demo_suite
# deviceQuery.exe
# bandwidthTest.exe
# 打开 cmd,然后拖入程序

在这里插入图片描述

tensorflow

CUDA - Pytorch - Torchvision - Torchaudio - Python

cuda 和 cudnn 的版本对照直接参照官网上

CUDATorchTorchvisionTorchaudioPython
12.4
12.3
12.2
12.12.2.00.17.02.2.0>=3.8, <=3.11
12.12.1.10.16.12.1.1>=3.8, <=3.11
12.12.1.20.16.22.1.2>=3.8, <=3.11
12.12.1.00.16.02.1.0>=3.8, <=3.11
11.82.2.00.17.02.2.0>=3.8, <=3.11
11.82.1.20.16.22.1.2>=3.8, <=3.11
11.82.1.10.16.12.1.1>=3.8, <=3.11
11.82.1.00.16.02.1.0>=3.8, <=3.11
11.82.0.10.15.22.0.2>=3.8, <=3.11
11.82.0.00.15.12.0.1>=3.8, <=3.11
11.72.0.10.15.22.0.2>=3.8, <=3.11
11.72.0.00.15.12.0.1>=3.8, <=3.11
11.71.13.10.14.10.13.1>=3.7.2, <=3.10
11.71.13.00.14.00.13.0>=3.7.2, <=3.10
11.61.13.10.14.10.13.1>=3.7.2, <=3.10
11.61.13.00.14.00.13.0>=3.7.2, <=3.10
11.61.12.10.13.10.12.1>=3.7, <=3.10
11.61.12.00.13.00.12.0>=3.7, <=3.10
11.31.12.10.13.10.12.1>=3.7, <=3.10
11.31.12.00.13.00.12.0>=3.7, <=3.10
11.31.11.00.12.00.11.0>=3.7, <=3.10
11.11.10.10.11.20.10.1>=3.6, <=3.9
11.11.10.00.11.00.10.0>=3.6, <=3.9
11.11.9.10.10.10.9.1>=3.6, <=3.9
11.11.9.00.10.00.9.0>=3.6, <=3.9
11.11.8.20.9.20.8.2>=3.6, <=3.9
11.11.8.10.9.10.8.1>=3.6, <=3.9
11.11.8.00.9.00.8.0>=3.6, <=3.9
11.01.7.10.8.20.7.2>=3.6, <=3.9
11.01.7.00.8.00.7.0>=3.6, <=3.9
10.21.12.10.13.10.12.1>=3.7, <=3.10
10.21.12.00.13.00.12.0>=3.7, <=3.10
10.21.11.00.12.00.11.0>=3.7, <=3.10
10.21.10.10.11.20.10.1>=3.6, <=3.9
10.21.10.00.11.00.10.0>=3.6, <=3.9
10.21.9.10.10.10.9.1>=3.6, <=3.9
10.21.9.00.10.00.9.0>=3.6, <=3.9
10.21.8.20.9.20.8.2>=3.6, <=3.9
10.21.8.10.9.10.8.1>=3.6, <=3.9
10.21.8.00.9.00.8.0>=3.6, <=3.9
10.21.7.10.8.20.7.2>=3.6, <=3.9
10.21.7.00.8.00.7.0>=3.6, <=3.9
10.21.6.00.7.0->=3.6, <=3.8
10.11.8.10.9.10.8.1>=3.6, <=3.9
10.11.8.00.9.00.8.0>=3.6, <=3.9
10.11.7.10.8.20.7.2>=3.6, <=3.9
10.11.7.00.8.00.7.0>=3.6, <=3.9
10.11.6.00.7.0->=3.6, <=3.8
9.21.7.10.8.20.7.2>=3.6, <=3.9
9.21.7.00.8.00.7.0>=3.6, <=3.9
9.21.6.00.7.0->=3.6, <=3.8

CPU - Pytorch - Torchvision - Torchaudio

CUDATorchTorchvisionTorchaudio
CPU only2.2.00.17.02.2.0
CPU only2.1.20.16.22.1.2
CPU only2.1.10.16.12.1.1
CPU only2.1.00.16.02.1.0
CPU only2.0.10.15.22.0.2
CPU only2.0.00.15.12.0.1
CPU only1.13.10.14.10.13.1
CPU only1.13.00.14.00.13.0
CPU only1.12.10.13.10.12.1
CPU only1.12.00.13.00.12.0
CPU only1.11.00.12.00.11.0
CPU only1.10.10.11.20.10.1
CPU only1.10.00.11.00.10.0
CPU only1.9.10.10.10.9.1
CPU only1.9.00.10.00.9.0
CPU only1.8.20.9.20.8.2
CPU only1.8.10.9.10.8.1
CPU only1.8.00.9.00.8.0
CPU only1.7.10.8.20.7.2
CPU only1.7.00.8.00.7.0
CPU only1.6.00.7.0-

CUDA - Tensorflow - cuDNN - Python

CUDATensorflowcuDNNpython
12.4
12.32.16.18.9?3.9-3.12
12.22.15.08.93.9-3.11
11.82.14.08.73.9-3.11
11.82.13.08.63.8-3.11
11.82.12.08.63.8-3.11
11.22.11.08.13.7-3.10
11.22.10.08.13.7-3.10
11.22.9.08.13.7-3.10
11.22.8.08.13.7-3.10
11.22.7.08.13.7-3.9
11.22.6.08.13.6-3.9
11.22.5.08.13.6-3.9
11.02.4.08.03.6-3.8
10.12.3.07.63.5-3.8
10.12.2.07.63.5-3.8
10.12.1.07.62.7, 3.5-3.7
10.02.0.07.42.7, 3.3-3.7
10.01.15.07.42.7, 3.3-3.7

示例程序 torch

import torch
import time

# 返回当前设备索引
print(torch.cuda.current_device())

# 返回GPU的数量
print(torch.cuda.device_count())

# 返回gpu名字,设备索引默认从0开始
print(torch.cuda.get_device_name(0))

# cuda是否可用
print(torch.cuda.is_available())

# pytorch 查看 cuda 版本
# 由于 pytorch 的 whl 安装包名字都一样,所以很难区分到底是基于 cuda 的哪个版本
print(torch.version.cuda)

# 判断 pytorch 是否支持 GPU 加速
print (torch.cuda.is_available())

# 以下代码只有在PyTorch GPU版本上才会执行
print(torch.cuda.is_available())
a = torch.randn(10000, 1000)
b = torch.randn(1000, 2000)
t0 = time.time()
c = torch.matmul(a, b)
t1 = time.time()
print(a.device, t1 - t0, c.norm(2))

device = torch.device('cuda')
a = a.to(device)
b = b.to(device)
t0 = time.time()
c = torch.matmul(a, b)
t1 = time.time()
print(a.device, t1 - t0, c.norm(2))

t0 = time.time()
c = torch.matmul(a, b)
t1 = time.time()
print(a.device, t1 - t0, c.norm(2))

其他

pip 创建虚拟环境

# 创建环境 env-py311
python -m venv env-py311

cd .\env-py311\
cd .\Scripts\

# 激活环境
.\activate

(env-py311) PS C:\Users\xulon\Desktop\env-py311\Scripts>

# 退出环境
deactivate

关于环境激活的问题

PS E:\py_env\Scripts> .\activate
.\activate : 无法加载文件 E:\py_env\Scripts\activate.ps1,因为在此系统上禁止运行脚本。
有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_E xecution_Policies。
所在位置 行:1 字符: 1
+ .\activate
+ ~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

# 解决:
PS E:\py_env\Scripts> get-executionpolicy
Restricted
PS E:\py_env\Scripts> Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Y
PS E:\py_env\Scripts> .\activate
(py_env) PS E:\py_env\Scripts>

更新 pip

# 重新安装Python
python -m ensurepip

# 升级 pip
pip install pip -U
pip install --upgrade pip
python -m pip install --upgrade pip

pip 换源

# 临时换源
# 清华源
pip install markdown -i https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip install markdown -i https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip install markdown -i http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip install markdown -i http://pypi.douban.com/simple/

# 永久换源
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
# 换回默认源
pip config unset global.index-url
  • 15
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值