posted on 2023-05-21 16:24 read(669) comment(0) like(7) collect(2)
pytorch itself has a cuda environment, so there is no need to force it to be consistent with the previous tensorflow environment.
torch1.13.0 does not support cuda10.2 and 11.3 versions
nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 526.47 Driver Version: 526.47 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 GeForce ... WDDM | 00000000:01:00.0 On | N/A |
| 0% 44C P8 22W / 170W | 1486MiB / 12288MiB | 31% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
conda create -name torch python=3.9
activate torch
The torch official website
provides several sample codes:
# CUDA 10.2
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch
# CUDA 11.3
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
# CUDA 11.6
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge
# CPU Only
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cpuonly -c pytorch
Delete the last -c pytorch
and then modify the cudatoolkit version to 11.2 (this sentence means to download the 11.2 version of cuda, and this cuda can be inconsistent with the system's cuda version, but it must be lower than the system itself, that is, The version (12.0) obtained by the nidia-smi command query)
that is, use the following command in the torch environment: (note that this command is wrong and will be modified later)
conda install pytorch torchvision torchaudio cudatoolkit=11.2
Package Version
----------------- -------
numpy 1.21.6
Pillow 9.2.0
pip 22.3.1
setuptools 65.5.1
six 1.16.0
torch 1.13.0
torchaudio 0.13.0
torchvision 0.2.2
typing_extensions 4.4.0
wheel 0.38.2
import torch
torch.cuda.is_available()
The cashback returns false.
Use the conda list to check and find that the downloaded version is the cpu version.
pytorch 1.13.0 py3.7_cpu_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
pytorch-mutex 1.0 cpu https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
setuptools 65.5.1 pyhd8ed1ab_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
six 1.16.0 pyh6c4a22f_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
sqlite 3.39.4 hcfcfb64_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda uninstall pytorch
View the installation command in the form of pip on the official website:
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
feasible
Author:gfg
link:http://www.pythonblackhole.com/blog/article/25278/6b54391dbf12356a4293/
source:python black hole net
Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.
name:
Comment content: (supports up to 255 characters)
Copyright © 2018-2021 python black hole network All Rights Reserved All rights reserved, and all rights reserved.京ICP备18063182号-7
For complaints and reports, and advertising cooperation, please contact vgs_info@163.com or QQ3083709327
Disclaimer: All articles on the website are uploaded by users and are only for readers' learning and communication use, and commercial use is prohibited. If the article involves pornography, reactionary, infringement and other illegal information, please report it to us and we will delete it immediately after verification!