当前位置:   article > 正文

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

保姆 深度学习环境

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

第一章 系统安装

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
/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://blog.csdn.net/sinat_42239797/article/details/103251474
https://blog.csdn.net/gdkyxy2013/article/details/79463859
卸载

打开: 先转到路径cd /media///***/anaconda3
anaconda-navigator
打开终端 conda activate
退出终端 conda deactivate
彻底退出终端(base)
conda config --set auto_activate_base false
更新库

Anaconda Navigator打不开的解决办法
有时候,在通过anaconda prompt窗口执行conda install ***的安装库的命令后发生无法打开anaconda navigator的情况。
以管理员权限打开anaconda prompt
输入conda update conda
输入conda update --all
尝试打开anaconda navigator
如果不行,输入 conda update anaconda-navigator
输入anaconda-navigator --reset
输入conda update anaconda-client
输入conda update -f anaconda-client
执行以上所有命令行,大概率可修复anaconda navigator

安装 (终端)
bash Anaconda3-5.3.1-Linux-x86_64.sh -u -u是重新安装时才使用
安装成功后更改清华源(add即可)
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
卸载 rm -rf anaconda3 #文件夹名
创建快捷方式
出现错误:ModuleNotFoundError: No module named ‘conda’
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

不要卸载python2.7

sudo apt install python-pip
sudo apt install python3-pip
pip3 --version
sudo apt install build-essential python-dev python-setuptools
sudo apt install build-essential python3-dev  python3-setuptools
  • 1
  • 2
  • 3
  • 4
  • 5

pip换源
最简单方法:直接 -i 加 url 即可
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ###
升级python

python3指向python

echo alias python=python3 >> ~/.bashrc
echo alias pip=pip3 >> ~/.bashrc
source ~/.bashrc
  • 1
  • 2
  • 3

将pip和pip3都指向pip

which pip3
sudo vim /usr/local/bin/pip3
  • 1
  • 2

不要改pip而是pip3

python升级3.9

如果需要用到两个python3版本,3.9\3.8.直接安装就可。pip安装的库是分开的

第三章 进阶安装

所有东西一站式安装 (仅参考) 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 include/cudnn*.h /usr/local/cuda/include
sudo cp -P lib/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

最简单方法:直接在官网获取命令
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch torchvision torchaudio
另一种复杂方法:
下载
安装 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
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

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu

验证 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 -i https://mirrors.aliyun.com/pypi/simple/ numpy
pip install -i https://mirrors.aliyun.com/pypi/simple/ matplotlib
pip install -i https://mirrors.aliyun.com/pypi/simple/ scipy
pip install -i https://mirrors.aliyun.com/pypi/simple/ 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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/622542
推荐阅读
相关标签
  

闽ICP备14008679号