win安装cuda、cudnn检测是否安装成功
1、win+R cmd进入终端
激活创建的虚拟环境
conda activate PyTorch
(PyTorch) E:\Wan_ji_project\yolo3-pytorch-master>python
Python 3.8.13 (default, Mar 28 2022, 06:59:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc
. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available() # cuda是否可用
True
>>> print(torch.version.cuda) # 查看pytorch 对应的cuda版本
11.3
>>> print(torch.__version__) # 查看pytorch版本
1.11.0
>>> torch.cuda.device_count() # 返回gpu数量
1
>>> torch.cuda.get_device_name(0) # 返回gpu名字,设备索引默认从0开始;
'NVIDIA GeForce MX250'
>>> torch.cuda.current_device() # 返回当前设备索引
0
通过nvcc -V和nvidia-smi分别查看cuda版本
(PyTorch) E:\Wan_ji_project\yolo3-pytorch-master>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:36:24_Pacific_Standard_Time_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0
(PyTorch) E:\Wan_ji_project\yolo3-pytorch-master>nvidia-smi
Thu Apr 28 11:16:49 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 511.65 Driver Version: 511.65 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| 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 NVIDIA GeForce ... WDDM | 00000000:02:00.0 Off | N/A |
| N/A 43C P8 N/A / N/A | 0MiB / 2048MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 288 C ...l\envs\PyTorch\python.exe N/A |
+-----------------------------------------------------------------------------+
检测cudnn可用性
(PyTorch) E:\Wan_ji_project\yolo3-pytorch-master>python
Python 3.8.13 (default, Mar 28 2022, 06:59:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.backends.cudnn.version())
8200
>>> a = torch.tensor(1.)
>>> a.cuda()
tensor(1., device='cuda:0')
>>> from torch.backends import cudnn # 若正常则静默
>>> cudnn.is_available() # 若正常返回True
True
>>> cudnn.is_acceptable(a.cuda()) # 若正常返回True
True
>>>
|