[Deeplabv3+] Use pytorch to reproduce Deeplabv3+ in Ubutu18.04 (the first step)-----Environment configuration

Use pytorch to reproduce Deeplabv3+ (first step)-----Environment configuration 

  • This article is based on Ubuntu 18.04, one of the Linux distributions used, and is reproduced under pytorch. Students who use Windows or reproduce on tensorflow will automatically skip it;
  • This article is being continuously updated. If students have questions about environment configuration, they can leave comments in the comment area at any time. The blogger will give guidance after seeing it;
  • The hardware graphics card required to run Deeplabv3 needs to be better. This article uses NVIDIA GeForce RTX-2060.
  • Finally, you may encounter various problems when learning deep learning. If you encounter problems, just search for solutions in Baidu, Zhihu, Bilibili, csdn, and Google Chrome. I hope everyone can learn something. become.

Deeplabv3+ paper address: https://arxiv.org/pdf/1802.02611.pdf Github

Deeplabv3+ code address: https://github.com/VainF/DeepLabV3Plus-Pytorch

Environment for this article: Ubuntu18.04 cuda 9.0.176 cudnn7.6.5 Anaconda3-5.3.0 torch1.13.1

Table of contents

1.Ubuntu18.04 installation

2.cuda9.0 & cuDNN7.6.5 installation

1. Verify whether the system has a CUDA-supported GPU

 2.cuda 9 requires gcc>=6, g++>=6, make sure your system meets these requirements

3.Install NVIDIA driver

4. Install other import packages

5 Download and install cuda9 toolkit and cuDNN7.6.5

3.anaconda3 installation

Download the Anaconda installation package

4. Code environment configuration


1.Ubuntu18.04 installation

If there are too many problems during the deeplabv3+ environment configuration process, reinstall the system. Refer to my previous article:

[Ubuntu18.04] Installation and configuration problems solved----Continuously updated

2.cuda9.0 & cuDNN7.6.5 installation

1. Verify whether the system has a CUDA-supported GPU

Enter the following code on the command line:

lspci | grep -i nvidia

You can view your graphics card information as: GeForce RTX 2060

You can also check your graphics card information in settings.

Check the NVIDIA website  https://developer.nvidia.com/cuda-gpus for products that support CUDA . If you can find your own graphics card, it proves that your graphics card can install CUDA.

 2.cuda 9 requires gcc>=6, g++>=6, make sure your system meets these requirements

Enter in the terminal:

gcc -v
g++ -v
#如果不满足要求,下载安装
sudo apt install gcc-6
sudo apt install g++-6

3.Install NVIDIA driver

#Check your own graphics card and driver versions that can be installed

sudo ubuntu-drivers devices 

Install according to the recommended driver version, mine is 470 ( CUDA9 requires driver version 384 and above, so it is OK ).

 First remove the old NVIDIA driver:

sudo apt-get purge nvidia-*

then install

sudo add-apt-repository ppa:graphics-drivers/ppa

sudo apt-get update

sudo apt-get upgrade

#Install

sudo apt install nvidia-driver-470

Just restart .

4. Install other import packages

sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

5 Download and install cuda9 toolkit and cuDNN7.6.5

  • cuda 9 installation:

# Installation package download

wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run 

# Make the downloaded file executable

chmod +x cuda_9.0.176_384.81_linux-run 

# Install

sudo ./cuda_9.0.176_384.81_linux-run  --override

Answer the following questions when installation begins:

You are attempting to install on an unsupported configuration. Do you wish to continue? y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n
Install the CUDA 9.0 Toolkit? y

For the installation process, please refer to the following article: Installing cuda-9 on Ubuntu

  • Install matching cuDNN 7.6.5 for cuda

To download cudnn, you must first register on the official website, official website address: https://developer.nvidia.com/cudnn

Register and log in, then find Download cuDNN v7.6.5 (November 5th, 2019), for CUDA 9.0 in Archived cuDNN Releases (cuDNN archived releases) and download it.

 Extract cuda directory

# Switch to the download directory

cd ~/Downloads

# Unzip
tar -xzvf cudnn-9.0-linux-x64-v7.3.0.29.tgz

Copy the unzipped files to the cuda toolkit directory

sudo cp -P cuda/include/cudnn.h /usr/local/cuda-9.0/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
sudo chmod a+r /usr/local/cuda-9.0/lib64/libcudnn*

Set environment variables

# Add cuda-9/bin to the path

echo 'export PATH=/usr/local/cuda-9.0/bin:$PATH' >> ~/.bashrc

# Add cuda-9/lib64 to the library path
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc

# Close the environment variable file .bashrc, and enter the environment variable update command
source ~/.bashrc in the terminal

Add symlinks for gcc and g++

sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++

Restart your computer to activate changes

Verify successful installation

nvidia-smi

# Check the cuda version, which is shown as 9.0.176

nvcc -V

# Check the cuDNN version, which shows 7.6.5

 cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

3.anaconda3 installation

This article installs Anaconda3-5.3.0-Linux-x86_64.sh. Before installation, make sure that python3.7 is installed. If not, install python3.7 first. If pip is not installed, you can install it by following the link below: https://blog.csdn.net/hymanjack/article/details/80285400

# Install python3.7

sudo apt install python3.7

# Let both pip and python point to python3

gedit ~/.bashrc

#Add these two lines at the end of the file, save and exit

alias pip=/usr/local/bin/pip3.7
alias python=/usr/bin/python3.7

# Update environment

source ~/.bashrc

Download the Anaconda installation package

Terminal download

wget https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh

# It may happen that wget is not installed. Install wget first and then download it again.

Web page download

Anaconda download

 Installation reference: Super detailed Ubuntu installation Anaconda steps + Anconda common commands-CSDN Blog

After the installation is complete, install the visual studio option and select no.

Seeing Thank you for installing Anaconda3! means that your installation has been completed.

4. Code environment configuration

Create a virtual environment:

# deeplabv3+ is the environment name, you can choose it yourself

conda create -n deeplabv3+ python=3.7

# Start the installation environment

conda activate deeplabv3+

In the virtual environment, use the command to install the required packages (pytorch, etc.)

#Create the folder requirements.txt on the desktop and put the following files there

touch requirements.txt

#Copy the following files and put them in requirements.txt

torch
torchvision
numpy
pillow
scikit-learn
tqdm
matplotlib
visdom

Installation (may take several hours depending on internet speed)

cd Desktop

pip install -r requirements.txt

 

 After the installation is complete, you can see the packages you have installed below.

 View the packages installed in the virtual environment

conda list

 Verifytorch

 At this point, the environment configuration is successful. Thank you everyone. If you have any questions, please feel free to contact me.

Guess you like

Origin blog.csdn.net/m0_62648611/article/details/129400154