RTX3070+Ubuntu18.04+cuda11.1+cudnn8.0.4+TensorFlow1.15.4+PyTorch1.7.0+yolov3环境配置
一、VMware+Ubuntu18.04安装
(1)安装虚拟机
16Pro虚拟机下载
16Pro版破解密钥16
ZF3R0-FHED2-M80TY-8QYGC-NPKYFYF390-0HF8P-M81RQ-2DXQE-M2UT6ZF71R-DMX85-08DQY-8YMNC-PPHV8
15pro虚拟机下载
(2)下载ubuntu镜像源
官网镜像源
ubuntu18.04镜像源
ubuntu安装过程:
1.打开VMware,选创建新的虚拟机
2.弹出窗口中选择自定义(高级)
3.保持默认选项,下一步
4.选择稍后安装操作系统
5.选择Linux->Ubuntu 64位(PS:选完Linux之后默认选项是Ubuntu,如果要安装32位Ubuntu这个默认选项就可以了,但这里博主要装的是64位所以,需要下拉选项里改成Ubuntu
64位,不然后期会报错)
二、安装NVIDIA显卡驱动
1.禁用nouveau
sudo gedit /etc/modprobe.d/blacklist.conf 加上以下两句: blacklist nouveau options nouveau modest=0
2.保存后,然后执行:
sudo updata-initramfs -u sudo reboot
3.重启后,Ctrl+Alt+F1切换到tty界面,关闭lightdm(如果没有则不用管):
sudo service lightdm stop
4.然后更新一下apt源以及看一下系统推荐的NVIDIA驱动版本:
sudo add-apt-repository ppa:graphics-drivers/ppa sudo apt-get update ubuntu-drivers devices
5.根据推荐的驱动版本,安装NVIDIA驱动:
sudo apt-get install nvidia-driver-460
6.如果下载速度巨慢,可以添加源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup sudo gedit /etc/apt/sources.list
7.添加源,保存
# 阿里云源 deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse ##測試版源 deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse # 源碼 deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse ##測試版源 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse # 清华大学源 deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse ##測試版源 deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse # 源碼 deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse ##測試版源 deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
8.添加完成,更新
sudo apt-get update sudo apt-get upgrade
三、cuda、cudnn、anaconda、pytorch、TensorFlow的安装
cuda安装
(1)下载cuda cuda_11.1下载地址
(2)找到下载好的cuda包,安装
bash sudo sh cuda_11.1.0_455.23.05_linux.run
会出来一堆blabla的选项(按照图中勾选,安装):
(3)配置环境变量
sudo gedit ~/.bashrc #在文件结尾处添加 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 export PATH=$PATH:/usr/local/cuda/bin export CUDA_HOME=$CUDA_HOME:/usr/local/cuda #保存完 sudo source ~/.bashrc
#检查版本
tar -xzvf cudnn-11.1-linux-x64-v8.0.4.30.tgz sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo chmod a+r /usr/local/cuda/include/cudnn.h
查看当前cudnn版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
nvcc -V nvidia-smi
pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
测试是否安装成功
python3
#安装 pip install --upgrade setuptools #先更新一下pip,不然后面的安装有可能报错 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.15.4 #GPU版 #测试 import tensorflow as tf a = tf.test.is_built_with_cuda() #判断CUDA是否可用 b = tf.test.is_gpu_available(cuda_only=False,min_cuda_compute_capability=None) #判断GPU是否可用 print(a) print(b)
安装参考:
https://blog.csdn.net/qq_39557270/article/details/102926282
https://blog.csdn.net/weixin_47658790/article/details/115419933
https://blog.csdn.net/betterman2017/article/details/111561364
https://blog.csdn.net/IAMoldpan/article/details/114500720