Python environment configuration test code gpu: false in win10

Python environment configuration test code gpu: false in win10

problem

By articles configuration python environment, following the articles 2 the operation of the installation pytorch, pycharm the input test code

import torch
print(torch.__version__)
print('gpu:',torch.cuda.is_available())

The output is "gpu: False"

Although the article 1 written by Dong Ge is false=. =

the reason

After asking Cheng, I found the problem because Tsinghua Yuan only has a CPU version and no corresponding GPU version.

Knowing method

win+R to open the run shortcut key, enter cmd to open the command window, enter the following code

conda list

Find pytorch and torchvision

Mine is like this

pytorch 1.4.0 cpu_py38ha775e86_0

torchvision 0.2.2 py_3

Does it look like the cpu version? ! !

Solution

Uninstall and reinstall pytorch.

Uninstall

1. Use conda to uninstall it

win+R to open the run shortcut key, enter cmd to open the command window, enter the following code

conda uninstall pytorch
conda uninstall libtorch

2. If you use pip to install, you must use pip to uninstall

Although I guess our group of people should not use pip

win+R to open the run shortcut key, enter cmd to open the command window, enter the following code

pip uninstall torch

installation

Obediently follow Posts 1 Ba pytorch installed it is not fragrant it [doge]

If it is found that the speed is very slow, then it is an external network after all. You can understand what you should do and live a healthy life online scientifically.

supplement

PS1: The two lines of commands using conda may not be able to delete the virtual environment, so you need to delete it manually. The address of the virtual environment should be the folder called pytorch in anaconda-envs . I don't know whether to delete it or not, I deleted it anyway. Delete at your own risk .

PS2: In fact, just reload finished pytorch I went pycharm in the input test code, will report the wrong file not found, then I think it is estimated that a path you want to python.exe conda installation of re-import, refer to article 1 Import namely can.

PS3: Finally! ! ! gpu: true! ! ! At least fifteen hours of hard work a day and a night! No! Have! White! fee!

PS4: Give it a thumbs up

Guess you like

Origin blog.csdn.net/qq_51330164/article/details/113061991