Newly installed Ubuntu system basic environment installation configuration (conda)

Ubuntu system uses conda to configure deep learning environment

1. Configure graphics driver

# 查看显卡驱动
nvidia-smi

 If this command does not respond, it means that there is no graphics card driver. At this time, the graphics card driver must be installed first. Then install cuda. ​​In this figure, 470.74 represents the version number of the graphics card driver, and 11.4 represents the highest supported cuda version information. Note that the corresponding relationship between the graphics card driver version and the cuda version is shown in the table below.

 For cuda version graphics card driver version correspondence, please refer to: Release Notes :: CUDA Toolkit Documentation

Remarks: Graphics card driver download:

Driver download link: Download Drivers | NVIDIA

 Fill in the driver requirements you are looking for, then click search, and finally you can get the download button to download the runfile file for driver installation. Then execute the runfile file.

# 换成自己的显卡驱动.run文件
sudo sh NVIDIA-Linux-x86_64-418.211.00.run

2. Install cuda

cuda download address: https://developer.nvidia.com/cuda-toolkit-archive

Find the version you want to download, download the corresponding runfile, and then execute the corresponding runfile. Open terminal:

# 安装cuda
sudo sh cuda_11.4.0_470.42.01_linux.run
  1. When the installation screen starts, select continue.
  2. Then enter accept and press Enter.

Since you already have an NVIDIA graphics card driver in your system, if you don’t want to install the driver that comes with CUDA 10.1, move to the Driver option and press the space bar to cancel it. As shown below.
insert image description here
Move to the Install option, press Enter, and wait for the installation to complete. 

If an error is reported during the installation of cuda, use the following command to reinstall

sudo sh cuda_11.4.0_470.42.01_linux.run --librarypath=/usr/local/cuda-11.4

After the installation is complete, the environment needs to be configured for CUDA 11.4.

Note that if the graphics card driver version is high but the installed cuda version is low, an error that the gcc version is too high may be reported. For example, the following error occurs when cuda10.1 is installed on this graphics card, so if you want to install cuda10. gcc downgrade.

Failed to verify gcc version. See log at /var/log/cuda-installer.log for details.

The explanation is that the gcc version is too high. Refer to Ubuntu20.04 to install cuda10.1_feng98ren's column-CSDN blog_ubuntu20.04 to install cuda to downgrade gcc.

After running the command, open /usr/local and there should be a cuda-11.4 folder.

Next configure the system path of cuda, first open the .bashrc file in the home directory

sudo gedit ~/.bashrc

 Add the following at the end of the file:

# added install cuda
export PATH=/usr/local/cuda-11.4/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Save and close the file to complete the configuration. Update environment:
source ~/.bashrc

 Finally check if cuda is successfully installed. You can use the nvcc -V command to check whether the installation is successful. More importantly, check whether there are cuda-11.4 and cuda folders in the /usr/local folder. If there are, it means that the installation is successful with a high probability.

3. Install cudnn

Download cudnn: https://developer.nvidia.com/rdp/cudnn-download
The downloaded file is a tar.gz compressed file
Unzip tar -zxvf cudnn-11.4-linux-x64-v8.2.2.26.tgz 
Move the configuration file into cuda :
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/ -d
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

After executing the above command, cuDNN is installed

After successful installation, check :
nvcc –V

If Cuda compilation tools, release 11.4, V11.4.48 is displayed, it means success.

4. Install Anaconda

Download the anaconda installation package, then run

bash Miniconda3-py38_4.9.2-Linux-x86_64.sh

The others are yes all the way, when you encounter Do you wish the installer to initialize Anaconda3 by running conda init? Enter no and press Enter.

Then add anaconda to the user environment variable (corresponding to the bin file location of conda). sudo gedit ~/.bashrc to open the configuration file and add the following sentence at the end.

export PATH="/home/yc/miniconda3/bin:$PATH"

update it

source ~/.bashrc

Finally, enter conda -V to check whether the installation is successful.

At this time, the base environment of conda comes with a python version.

5. Install pytorch

installpytorch1.7.0

pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.douban.com/simple

The version should correspond to the version of cuda as much as possible. If the download speed is slow, try changing the source. Which source is faster, or the default source is faster, depends on luck. For details, please refer to the official website of pytorch.

6. Install mmdetection (optional)

mmdetection is a Pytorch-based deep learning object detection toolbox open sourced by SenseTime and The Chinese University of Hong Kong, supporting mainstream object detection frameworks such as Faster-RCNN and YOLO.

To install mmdetection, you must first install mmcv, and pay attention to the pytorch version and cuda version when installing. Also pay attention to the version correspondence between mmcv and mmdetection. For details, refer to https://github.com/open-mmlab/mmdetection/blob/master/docs/get_started.md

For example, install mmdetection2.7

pip install mmcv-full==1.2.7 -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html

Then unzip the mmdetection installation package downloaded online: mmdet_2.7.zip

After entering the folder, run

pip install matplotlib opencv-python requests -i https://pypi.douban.com/simple
pip install -r requirements/build.txt -i https://pypi.douban.com/simple
python setup.py develop

mmdetection installed successfully.

Guess you like

Origin blog.csdn.net/Eyesleft_being/article/details/120138519