Learning record: cuda10.0 under Windows system chooses to install python3.9 version and fails to install pytorch (additional solution)

cutting edge:

       Personally, I prefer to use GPU for training, so I use cuda to run algorithm programs. A few days ago, I installed python3.9 version on the basis of cuda10.0, and used the labeling tool labeling to label pictures. I recently reproduced the target detection algorithm. I wanted to install pytorch on this basis, but the installation failed. According to the error message, it turns out that the torch version supported by cuda10.0 is too low to match the higher version of python3.9. The following is the process record of pytorch installation failure and how to solve it.

1. Create an environment and activate the environment

 

conda create -n mbjc python==3.9  #创建环境 python版本:3.9 环境名称:mbjc
conda activate mbjc               #激活环境 环境名称:mbjc

2. Check that the python version is 3.9

(mbjc) C:\Users\24701>python
Python 3.9.0 (default, Nov 15 2020, 08:30:55) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'

Go to the pytorch official website to find the torch version corresponding to cuda10.0: https://pytorch.org/get-started/previous-versions/

 Copy the command line and install pytorch

(mbjc) C:\Users\24701>conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: /
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
Examining python:  37%|██████████████████████▌                                      | 27/73 [00:00<00:00, 12463.81it/|
Examining wincertstore:  49%|████████████████████████████▌                             | 36/73 [04:05<03:44,  6.06s/i/
failed                                                                                                                 /
                                                                                                                       -
UnsatisfiableError: The following specifications were found                                                            |
to be incompatible with the existing python installation in your environment:

Specifications:

  - pytorch==1.2.0 -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']
  - torchvision==0.4.0 -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']

Your python: python==3.9

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

The following specifications were found to be incompatible with each other:



Package wincertstore conflicts for:
torchvision==0.4.0 -> python[version='>=3.5,<3.6.0a0'] -> pip -> setuptools -> wincertstore[version='>=0.2']
pytorch==1.2.0 -> python[version='>=3.7,<3.8.0a0'] -> pip -> setuptools -> wincertstore[version='>=0.2']
python==3.9 -> pip -> setuptools -> wincertstore[version='>=0.2']
Package setuptools conflicts for:
torchvision==0.4.0 -> python[version='>=3.5,<3.6.0a0'] -> pip -> setuptools
pytorch==1.2.0 -> python[version='>=3.7,<3.8.0a0'] -> pip -> setuptools
python==3.9 -> pip -> setuptools
Package msgpack-python conflicts for:
pytorch==1.2.0 -> python[version='>=3.7,<3.8.0a0'] -> pip -> cachecontrol -> msgpack-python[version='>=0.5.2']
torchvision==0.4.0 -> python[version='>=3.5,<3.6.0a0'] -> pip -> cachecontrol -> msgpack-python[version='>=0.5.2']
Package pip conflicts for:
torchvision==0.4.0 -> python[version='>=3.5,<3.6.0a0'] -> pip
pytorch==1.2.0 -> python[version='>=3.7,<3.8.0a0'] -> pip
python==3.9 -> pip

3. According to the above error message, it is found that the torch version corresponding to cuda10.0 is fine. The problem mainly occurs in the python version, which is caused by the mismatch between python 3.9 and pytorch 1.2.0. We need to recreate a compatible environment. How do you know that the python environment you created matches the cuda version and the torch version? ?

The following shows the correspondence between pytorch, torchvision, and python, source address: https://github.com/pytorch/vision#installation

4. If you use GPU for training, you need to install cuda and cudnn to support subsequent calls to GPU for calculation. The mainstream deep learning frameworks are based on cuda for GPU parallel acceleration, while cudnn is an acceleration library for deep convolutional neural networks, and both are installed together.

        At this time, when installing pytorch on the basis of cuda, you need to pay attention to the version model of cuda. ​​Taking this article as an example, the cuda version is 10.0, so go to the official website of pytorch and find that cuda10.0 only supports the version of pytorch<=1.2.0, corresponding to the above table Only the following python versions can be selected.

 Therefore, it is impossible to choose cuda10.0+pytorch1.2.0+python3.7 incompatible versions. Therefore, for the pytorch installation failure, the correct approach without changing the cuda version is to recreate a python 3.7 environment. (python3.6 is also possible, python2.7 and python3.5 may report an error, I have not tried it myself)

Guess you like

Origin blog.csdn.net/weixin_47247597/article/details/129427627