Article directory
1. Commonly used instructions
1.1 Check whether the CPU is Intel or AMD:
cat /proc/cpuinfo
orpersonlscpu
1.2. Check ubuntu version
lsb_release -a
1.3. View the architecture
arch
或者
uname -a
1.4. Check the installed nvidia driver
nvidia-detector
1.5. Enter tty mode
Ctrl + Alt + F3 enter tty mode
Ctrl + Alt + Delete exit tty mode
2. Install ubuntu22.04 and nvidia driver
https://blog.csdn.net/takedachia/article/details/130354110
3.ubuntu install anaconda
https://developer.aliyun.com/article/988482
export PATH="~/anaconda3/bin":$PATH Import variable source ~/.bashrc to take effect< /span>
conda create -n pytorch python=3.9
4. Install pytorch gpu version
Remember that the cuda installed at this time is incomplete, but it is enough for pytorch.
https://pytorch.org/get-started/previous-versions/
You can see:
conda install pytorch 1.13.1 torchvision0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia
After installation, the gpu version of pytorch can be used.
But there is no cuda under /usr/local/ at this time.
For cuda version-related issues such as the inconsistency between nvidia-smi and nvcc --version and print(torch.version.cuda), please check:
https://www.jb51.net/ article/278075.htm
https://www.jianshu.com/p/eb5335708f2a
https://www.cnblogs.com/yhjoker/p/ 10972795.html
5. Install the full version of cuda and cudnn
Reference:
https://blog.csdn.net/takedachia/article/details/130375718
The introduction is very detailed.
The above tutorial is to install cudnn through https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html Package Manager Installation method
The installed header files and so files are in
You can also use the tar file installation method:
No installation is required, only decompression and permission settings are required
6.nvidia-driver, cuda-toolkit, cudnn
In addition to the above installation by downloading the runfile, you can also install it through the package
For example, install nvidia driver:
ubuntu-drivers devices Find the ones that can be installed driver
sudo ubuntu-drivers autoinstall installation recommendation
or
sudo apt-get install cuda-drivers-418 to install a specific version of the driver.
nvidia-smi confirms that the driver is installed correctly
Install cuda:
conda search -c conda-forge cudatoolkit # 列出所有可以安装的版本 conda install -c conda-forge cudatoolkit=xx.x.x
nvcc-V confirms successful installation
cudnn: There are also multiple installation methods
https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html
7.opencv
There are many installation methods
Install from source code
First install the dependencies
mkdir build
cd build
compile
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=./install -D OPENCV_GENERATE_PKGCONFIG=ON ..
You can also install it through commands, which saves a lot of trouble, and the environment is automatically configured.
apt install libopencv-dev