pytorch与cuda环境安装操作

Pytorch

pytorch与cuda环境安装操作_第1张图片

  • 安装 11.8 Windows版本的

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

在cmd或者power shell中运行
![需要python环境]
pytorch与cuda环境安装操作_第2张图片
安装完成后可以使用以下命令检测cuda是否安装好

nvidia-smi

Thu Dec  7 19:51:03 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 528.89       Driver Version: 528.89       CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| 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 RTX A300... WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A   56C    P8    14W /  80W |     30MiB /  6144MiB |      1%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A     54484    C+G   ...trix\ICACLI~1\wfica32.exe    N/A      |
+-----------------------------------------------------------------------------+

输入检查torch和cuda的命令

C:\Windows\system32>python
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True

返回true则表明,cuda和pytorch环境成功安装

你可能感兴趣的:(pytorch,人工智能,python)