How to install pytorch on linux

On the basis that Anaconda has been installed, go to install pytorch.

1. Open Anaconda Prompt (terminal) to create a virtual environment. For example, to create a virtual environment named pytorch, you can enter it as follows. Where python=3.7 specifies the python version number of the virtual environment.

The command line is: conda create -n pytorch pyrhon=3.7

2. Answer y to install the virtual environment pytorch. After a while, the installation is successful.

3. Activate the virtual environment just installed, and enter the command line in the terminal: conda activate pytorch. After entering this command, the previous "base" becomes "pytorch".

4. Enter pytorch.org/get-started/locally/ in Google to enter the official website of pytorch.f1d3ab39fc784f1cb4b5803313717cc5.png

 Because we are installing pytorch on linux, change windows to linux, choose 10.2 if you have a GPU, and choose None if you don’t have a GPU. After selection, copy the command statement of the line Run this Command.

5. Go back to the terminal just now, copy the statement just copied to the terminal, and press enter. Install pytorch. Answer y once in the middle, and pytorch is installed.

6. Check whether pytorch is installed. Enter python in the terminal to enter the python environment.

Enter import torch first, and then enter the next statement if no error is reported.

Enter print(torch.__version__), and enter the version number of pytorch after execution. Note that __ is two _.

If there is no problem with the execution of the above two-day statement, it means that the pytorch installation is complete.

The above are the steps to install pytorch on linux.

Guess you like

Origin blog.csdn.net/m0_73939236/article/details/131545707