Create a python environment on the linux server and install torch

Install anaconda to create a python virtual environment

Here I will not focus on how to install anconda, the following link is for your reference:

(24 messages) The first step of scientific research: Create a python virtual environment on a Linux server_fs1341825137's Blog-CSDN Blog

Next, the anconda environment has been created successfully. The next step is to create a python environment and install pytorch

step:

conda create -n virtual environment name python=version number

Take python=3.7 as an example to create a virtual environment named deblur

conda create -n deblur python=3.7

After the python environment is created, install pytorch.

Before installing pytorch, you need to check the version number of cuda in the server, because the versions of pytorch and cuda need to correspond:

The installation of pytorch-cuda version:
download the version from pytorch official website,
select the corresponding adaptation, and you can use different instructions

Use nvcc -V to view the cuda version number.

nvcc -V

 The cuda version number that must be viewed with nvcc -V is correct.

Then go to the pytorch official website to check the corresponding version and install it. PyTorch icon-default.png?t=LA92https://pytorch.org/

 Previous versions can be viewed by clicking on the links circled in the image.

 Take pytorch as 1.7.1 and cuda as 10.1 version as an example:

Excuting an order:

conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch

The content shown in the figure appears, indicating that pytorch is successfully installed:

Enter the python environment to see if pytorch cude is available:

python

import torch

torch.cuda.is_available()

 If true, it means it can be used.

 Note: The above steps need to be installed under the condition of networking. Otherwise it may be unsuccessful.

Guess you like

Origin blog.csdn.net/qq_44808827/article/details/122034792