cuda
和 cudnn
百度云 下载:
zp8d
anaconda
nvidia驱动
历史版本驱动下载
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 |
+-------------------------------+----------------------+----------------------+
找到nvidia驱动版本对应的cuda的Release Notes版本信息
下载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
下载cudnn
微信注册账户即可,填完问卷即可下载
下载后解压缩
将cudnn对应文件夹中所有文件拷贝到cuda安装目录中
"""更换清华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/
"""开始安装"""
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
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