python download pytorch (via pip+tsinghua source)

python download pytorch (via pip+tsinghua source)

Using conda to download always reports an http error, and the download fails. When trying to remove -c pytorch downloads only the cpu version, not the gpu version

cmd interface to view the highest conda supported by your computer

D:\Tool\Anaconda\envs>NVIDIA-smi
Wed Jul 20 23:08:23 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 511.69       Driver Version: 511.69       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:01:00.0 Off |                  N/A |
| N/A   45C    P8    N/A /  N/A |      0MiB /  4096MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A       484    C+G   ...2txyewy\TextInputHost.exe    N/A      |
|    0   N/A  N/A      2020    C+G   ...tracted\WechatBrowser.exe    N/A      |
|    0   N/A  N/A      2792    C+G   ...e6\promecefpluginhost.exe    N/A      |
|    0   N/A  N/A      3716    C+G   ...5n1h2txyewy\SearchApp.exe    N/A      |
|    0   N/A  N/A     12960    C+G   ...onnectUniversalClient.exe    N/A      |
|    0   N/A  N/A     14900    C+G   ...d\runtime\WeChatAppEx.exe    N/A      |
|    0   N/A  N/A     16184    C+G   ...cw5n1h2txyewy\LockApp.exe    N/A      |
|    0   N/A  N/A     16440    C+G                                   N/A      |
|    0   N/A  N/A     20296    C+G   ...llMobileConnectClient.exe    N/A      |
+-----------------------------------------------------------------------------+

.CUDA Version: 11.6 represents the highest conda version supported by your computer

pip command download

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib==2.2.4
  1. pip uses Tsinghua source image ;
    insert image description here

  2. pytorch's official website pip
    insert image description here

Use in the corresponding conda environment

insert image description here

Verify whether the installation of pytorch-gpu is successful

(python3.6) C:\Users\小黄鸭>python
Python 3.6.13 |Anaconda, Inc.| (default, Mar 16 2021, 11:37:27) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
1.10.2+cu113
>>> torch.cuda.is_available()
True
>>>

Guess you like

Origin blog.csdn.net/qq_44464101/article/details/125903136