ubuntu16 build a deep learning environment (three)-install pytorch-gpu

1. Preparation

(1) Install nvidia driver: ubuntu16 build a deep learning environment (1)-install nvidia driver
(2) install cuda and cudnn: ubuntu16 build a deep learning environment (2)-install cuda and cudnn
(3) install Anaconda: ubuntu16 installation Anaconda3

2. Create a virtual environment

First add the mirror source:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

Create the virtual environment again:

conda create -n pytorchgpu python=3.7  //pytorchgpu是自己设置的环境名字
conda activate pytorchgpu  //激活环境

3. Install pytorch

First go to pytorch official website https://pytorch.org/ to search for the corresponding version, as shown in the figure below.
Insert picture description hereSimply paste the command given.

4. Verify whether cuda and cudnn are available under pytorch

Enter python in the terminal, and then enter the following code:

import torch
print(torch.cuda.is_available()) //return True to have installed cuda
from torch.backends import cudnn
print(cudnn.is_available()) //Return True to have installed cuda

Guess you like

Origin blog.csdn.net/qq_43265072/article/details/107174326
Recommended