win10下最新最完整pytorch和cuda安装过程

本文详细介绍如何为GPU计算环境安装配置必要的软件,包括Anaconda、NVIDIA驱动、CUDA、cuDNN及PyTorch等,确保深度学习应用顺利运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


cudacudnn百度云 下载
提取码: zp8d

1. 安装anaconda

anaconda

2. 安装nvidia

2.1 驱动下载安装

nvidia驱动
历史版本驱动下载

2.2 测试

win+R输入cmd打开终端
输入

cd C:\Program Files\NVIDIA Corporation\NVSMI\
nvidia-smi.exe
cd C:\Program Files\NVIDIA Corporation\NVSMI\
C:\Program Files\NVIDIA Corporation\NVSMI>nvidia-smi.exe
Sat Mar 20 20:08:16 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 461.72       Driver Version: 461.72       CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 108... WDDM  | 00000000:1B:00.0  On |                  N/A |
|  0%   31C    P8    12W / 280W |    999MiB / 11264MiB |      1%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

3. 安装cuda

3.1 查看版本

找到nvidia驱动版本对应的cuda的Release Notes版本信息

3.2 下载安装cuda

下载cuda

3.3 测试cuda

  • 使用nvcc -V测试是否安装成功
(base) C:\Users\daicong>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Apr_24_19:11:20_Pacific_Daylight_Time_2019
Cuda compilation tools, release 10.1, V10.1.168

4. 安装cudnn

下载cudnn
微信注册账户即可,填完问卷即可下载
下载后解压缩
在这里插入图片描述
将cudnn对应文件夹中所有文件拷贝到cuda安装目录中
在这里插入图片描述

5. torch安装

5.1 更换conda源

"""更换清华conda源"""
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

5.2 安装torch

"""开始安装"""
conda install pytorch torchvision cudatoolkit=10.1 

或者

pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html --user -i https://pypi.tuna.tsinghua.edu.cn/simple

5.3 测试

import torch
torch.__version__           		# 返回版本号
torch.cuda.is_available()   		# 返回True
torch._C._cuda_getDeviceCount()     # 返回数量

(base) C:\Users\daicong>python
Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.8.0'
>>> torch.cuda.is_available()
True

后记

中途使用了pip安装,安装的是cpu的版本,记录一下安装过程
注意:下面的方式gpu行不通

pip3 download -d . -r 1.txt -f https://download.pytorch.org/whl/torch_stable.html --no-cache-dir
pip install --no-index --find-links=./pytorch -r 1.txt

cat 1.txt
torch==1.8.0+cu101
torchvision==0.9.0+cu101
torchaudio==0.8.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值