深度学习环境搭建(保姆级教程)

整理不易,敬请三连。
注:安装完ubuntu之后第一件事,将软件和系统的源换掉
https://blog.csdn.net/bigdog_1027/article/details/78924768.
https://mp.weixin.qq.com/s/QFnYHu_htLG1dxl3Xfa-gg.

文章目录

  • 第一章 系统安装
    • 1. Ubuntu安装
    • 2. 安装英伟达驱动(重启之后才能使用)
  • 第二章 基础安装
    • 1. anaconda安装
    • 2. pycharm安装
    • 3. ubuntu 安装pip
  • 第三章 进阶安装
    • 1. CUDA 安装
    • 2. CUDNN安装
    • 3. ubuntu 安装pytorch
    • 4. 安装TensorFlow
    • 5. 安装Keras
    • 6. 安装Opencv
    • 7. PyQt安装(选择安装)

第一章 系统安装

1. Ubuntu安装

https://blog.csdn.net/qq_24624539/article/details/81775635.
https://zhuanlan.zhihu.com/p/61500610.
分区 https://www.cnblogs.com/raina/articles/11129375.html.
推荐分区
/ 100G 102400 SWAP 16G 16384 /boot 500M /var 5G 5120
/usr 50G 51200 /home 200G
美化 https://www.jianshu.com/p/16b36b912b02.

2. 安装英伟达驱动(重启之后才能使用)

教程:
10、20系列等显卡https://zhuanlan.zhihu.com/p/59618999
30系列显卡https://blog.csdn.net/chentianting/article/details/85089403
https://blog.csdn.net/qq_41549249/article/details/109557321#commentBox

重启之后https://www.cnblogs.com/yutian-blogs/articles/13019226.html
(装驱动之前会有一个设置的密码一定要记住)

遇到的问题:
ubuntu开机黑屏左上角有光标闪烁,DP线没有接到显卡上

第二章 基础安装

1. anaconda安装

下载 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
安装https://blog.csdn.net/sinat_42239797/article/details/103251474
https://blog.csdn.net/gdkyxy2013/article/details/79463859
卸载https://blog.csdn.net/howyoungareyou/article/details/109511508

打开: anaconda-navigator
打开终端 conda activate
退出终端 conda deactivate

更新库https://blog.csdn.net/xiexu911/article/details/80282440

安装 (终端)
bash Anaconda3-5.3.1-Linux-x86_64.sh -u -u是重新安装时才使用
安装成功后更改清华源https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
卸载 rm -rf anaconda3 #文件夹名
创建快捷方式: https://blog.csdn.net/weixin_35757704/article/details/89066529
出现错误:ModuleNotFoundError: No module named ‘conda’
[https://www.jianshu.com/p/f7d735370c76] (https://www.jianshu.com/p/f7d735370c76)

2. pycharm安装

下载 https://www.jetbrains.com/pycharm/download/#section=windows
安装 https://blog.csdn.net/qq_15192373/article/details/81091278
卸载 https://blog.csdn.net/weixin_31484477/article/details/81133590

以后运行Pycharm的方法:
方法一:每次运行也需要使用cd命令,进入pycharm的安装路径下的bin目录,用sh命令 来启动pycharm。 sh ./pycharm.sh
方法二:或者直接把绝对路径给出,方便把Pycharm安装到其他地方的同学。只使用一条命令就可以运行,很方便。
方法三:(一劳永逸) 创建快捷方式
https://blog.csdn.net/qq_20515461/article/details/90745100
https://www.cnblogs.com/Jimc/p/10303896.html

3. ubuntu 安装pip

http://blog.csdn.net/weixin_37911283/article/details/70799481

第三章 进阶安装

所有东西一站式安装 (仅参考) https://www.cnblogs.com/moon3/p/12199588.html

1. CUDA 安装

下载 https://developer.nvidia.com/cuda-toolkit-archive
安装 https://blog.csdn.net/qq_42902997/article/details/103104697
http://www.cppcns.com/os/linux/328317.html

命令行10.1
sudo chmod 777 cuda_10.1.243_418.87.00_linux.run
sudo ./cuda_10.1.243_418.87.00_linux.run
或者
sudo sh cuda_10.1.105_418.39_linux.run 当前安装版本

测试CUDA是否安装成功
https://blog.csdn.net/qq_41481731/article/details/86658336
cd /usr/local/cuda-11.2/samples/1_Utilities/deviceQuery
make
sudo ./deviceQuery

CUDA卸载
https://blog.csdn.net/qq_41381395/article/details/86775470
sudo apt-get remove cuda
sudo apt-get autoclean
sudo apt-get remove cuda*
cd /usr/local/
sudo rm -r cuda*

nvidia-smi 查看配置
查看cuda版本 nvcc --version 或者 cat /usr/local/cuda/version.txt

2. CUDNN安装

下载 https://developer.nvidia.com/rdp/cudnn-archive

教程 https://blog.csdn.net/wanzhen4330/article/details/81699769#commentBox
sudo cp cuda/include/cudnn*.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

CUDNN卸载
sudo rm -rf /usr/local/cuda/include/cudnn*.h
sudo rm -rf /usr/local/cuda/lib64/libcudnn*

验证是否安装成功及查看CUDNN版本 :
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

结果:版本6.0.21
#define CUDNN_MAJOR 6
#define CUDNN_MINOR 0
#define CUDNN_PATCHLEVEL 21
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
#include "driver_types.h

3. ubuntu 安装pytorch

下载https://download.pytorch.org/whl/torch_stable.html
安装 https://blog.csdn.net/red_stone1/article/details/78727096
https://blog.csdn.net/wuzhiwuweisun/article/details/82753403

sudo pip3 install torch=1.7.1+cu110 torchvision=0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch-1.7.1+cu110-cp38-cp38-linux_x86_64.whl
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torchvision-0.8.2+cu110-cp38-cp38-linux_x86_64.whl
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torchaudio-0.7.2-cp38-cp38-linux_x86_64.whl

卸载
pip uninstall torch
pip uninstall torchvision

conda中用程序验证
import torch
import torchvision
print(torch.cuda.is_available())

查看版本
import torch
print(torch.version) #注意是双下划线

https://blog.csdn.net/red_stone1/article/details/78727096#commentBox

问题:import-im6.q16: not authorized `torch’ @ error/constitute.c/WriteImage/1037.
https://blog.csdn.net/qq_41874879/article/details/106122293

出现的问题:
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
https://blog.csdn.net/qq_44762986/article/details/104794147

sudo -i
pip install --upgrade pip
pip install PyHamcrest

4. 安装TensorFlow

官网: https://tensorflow.google.cn/install/source?hl=zh_cn
安装: https://blog.csdn.net/lifengxun20121019/article/details/80530701

pip install -i https://mirrors.aliyun.com/pypi/simple/ tensorflow_gpu-2.3.1-cp37-cp37m-manylinux2010_x86_64.whl
pip3 install tensorflow==2.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
(2.4.0支持3.6-3.7-3.8)

验证 https://jingyan.baidu.com/article/af9f5a2d4b7b8843140a45d1.html

卸载:

遇到的问题:Cannot uninstall wrapt
https://blog.csdn.net/weixin_41923658/article/details/96127770
pip install wrapt --ignore-installed

验证:
python
import tensorflow as tf
tf.version

5. 安装Keras

https://www.cnblogs.com/windyrainy/p/10585226.html

pip install numpy
pip install matplotlib
pip install scipy -i https://mirrors.aliyun.com/pypi/simple/
pip install keras
卸载 pip uninstall keras

6. 安装Opencv

Opencv-python安装
pip install -i https://mirrors.aliyun.com/pypi/simple/ opencv-python
或者pip install -i https://mirrors.aliyun.com/pypi/simple/ opencv-python==4.1.0.25

Opencv卸载与安装
https://blog.csdn.net/qq_36486890/article/details/97511295
https://blog.csdn.net/qq_35759272/article/details/109156043
https://blog.csdn.net/public669/article/details/99044895#commentBox
./darknet-master detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
项目1: https://blog.csdn.net/qq_40574708/article/details/106006959

Opencv的安装
https://blog.csdn.net/public669/article/details/99044895 https://blog.csdn.net/qq_36486890/article/details/97511295
问题
https://blog.csdn.net/zhangping1987/article/details/106552189#commentBox

7. PyQt安装(选择安装)

PyQt5简述 https://blog.csdn.net/qq_38278799/article/details/83871040

PyQt5安装https://blog.csdn.net/weixin_45216118/article/details/111912613
问题:创建虚拟环境只能用默认源defaults
https://blog.csdn.net/weixin_45216118/article/details/111995350
教程https://zhuanlan.zhihu.com/p/48373518

Qt5安装 https://blog.csdn.net/m0_37688984/article/details/80216123
http://c.biancheng.net/view/3858.html
教程 https://www.cnblogs.com/lizhigang/p/12308119.html

你可能感兴趣的:(深度学习环境搭建,ubuntu,linux,cuda,gpu,深度学习)