Ubuntu22.04 Python deep learning environment configuration record

主要是给自己的记录,大家愿意参考也可以,但是我是新手,不保证完全ok,当作笔记慢慢更新
另外,因为ubuntu22.04刚发布不到一周,有很多问题我也很痛苦,但是20.04的默认内核是5.13,22.04的默认内核是5.15,我没记错的话。但是我刚买的电脑,我的无线网卡等很多硬件和20.04内核不匹配,需要5.14以上,正好升级到22.04试一试

In addition, I highly recommend Huang Haiguang's Github to be more comfortable with learning

1. Python

The system comes with python3, and python2 is not used for the time being, so it will not be installed
for the time being. It needs to be installed again when installing ROS later (in my impression, ROS needs to be switched to python2)

CUDA和cuDNN安装过程是我另一篇笔记里的,直接复制过来的

2. CUDA

2.1 Check the CUDA version you need

If the input nvidia-smi
insert image description here
command does not exist, it means that your graphics card driver is wrong, not nvidia. Go and 软件与更新-附加驱动modify it .

2.2 Install CUDA

Select the corresponding version from this website and follow the steps to install it.


2022.4.26更新: The CUDA installed by deb the day before, forgot that it will automatically install the graphics card driver, resulting in the graphics card driver being changed, and uninstalled for two hours without success. Because CUDA, cuDNN and graphics card drivers are frequently uninstalled, in order to prevent problems in the later environment, I have not downloaded a lot of software while taking advantage of the newly installed 22.04, so I quickly reinstall it! ! ! Use runfile to install instead, it can choose whether to install the graphics card driver. Check
insert image description here
the graphics card driver option.
insert image description here

以上均为2022.4.26更新,更新了CUDA安装方式,请直接跳转cuDNN,不删除deb安装方式是为了避雷


Because my current version 22.04 has just been released for less than a week, there is no corresponding Ubuntu22.04 option, so I chose 20.04 for temporary use.
Bug fix later

Problems encountered during installation
insert image description here

In the last step of installing cuda, sudo apt-get -y install cuda reports an error, lacking liburcu6 and sudo apt install liburcu6showing that there is no such package, so choose to download and install the
download address
by yourself. Select the amd64 architecture and
insert image description here
you can see the Binary Package address in Download (where the mouse is located) )
insert image description here
download and install with the command

wget 	http://archive.ubuntu.com/ubuntu/pool/main/libu/liburcu/liburcu6_0.11.1-2_amd64.deb
sudo dpkg -i sudo dpkg -i liburcu6_0.11.1-2_amd64.deb

Then reinstall cuda, the problem is solved

Learn from this
After the installation is complete, update the environment variables, I use zsh, if you have not changed the shell, then the default is bash

sudo vim ~/.zshrc
#没改过用这句
sudo vim ~/.bashrc

add at the end

export CUDA_HOME=/usr/local/cuda-11.6
export PATH=$PATH:/usr/local/cuda-11.6/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.6/lib64

Note the cuda version I am 11.6

source ~/.zshrc
#或者
source ~/.bashrc

Finally enter to nvcc -Vview cuda information
insert image description here

3. Install cuDNN

There is no corresponding cuDNN version corresponding to CUDA11.6.
Temporarily use cuDNN corresponding to CUDA11.x version. Others say that this version can be used. Try to use it temporarily.
insert image description here
After downloading and decompressing, the terminal enters the decompressed folder (because the decompression After the name is not uniform, for convenience, enter the folder and then copy the file)

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

4. Anaconda

Anaconda official website
command installation

bash Anaconda3-2021.11-Linux-x86_64.sh   

All the way yes and press Enter, you can choose the installation location, you can directly press Enter by default, but I like to install the tools in the Tools folder, otherwise there are too many tools, who knows who uses
insert image description here
the system PATH changes during the installation process, you need to source it

source ~/.bashrc

At this time, the words will appear before the command line (bash), because the conda initialization code is added to the PATH during the installation process, and it will be automatically executed . There
are two ways to eliminate it. (bash)
One is to comment out the initialization code and re-source it. Exit the base environment The third is to set auto_activate_base to false
conda deactivate

conda config --set auto_activate_base false

In the future, every time you want to enter the base environment, you need to pass the command conda activate base
. Obviously, I choose the first method. Because I am a beginner, I don’t need it for the time being, and I need to change it later.
insert image description here

5. VSCode

It should have been written before, but I forgot.
The installation of vscode is very simple, just download the deb file from the official website and then install it directly with dpkg
Plugins: Python, Jupyter, Jupyter Notebook
insert image description here
insert image description here
If you want to use Jupyter Notebook, you also need to download the kernel. I can't remember the specific process, but vscode will remind you to complete it step by step.

Guess you like

Origin blog.csdn.net/qq_41746268/article/details/124415682