记录自己搭建深度学习环境的全过程,后面可能还会用到,电脑本身只有windows系统,所以从安装Ubuntu开始。
日常U盘写入镜像安装,Ubuntu系统开源,官网下载,UltraISO写入镜像,启动时进入BIOS,设置为U盘启动,进入安装时会一直卡在Ubuntu的Logo加载界面直到卡死,重启,在选择Ubuntu install那里按E进入编辑画面(图为转载)
把鼠标移到linux那一行最后面先按一下space键加入一个空白,输入"acpi_osi=linux nomodeset"。重新安装成功。(图为转载)
anaconda官网下载地址: https://www.anaconda.com/download/#linux
anaconda清华源下载地址: https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
安装anaconda 3:
输入下面命令进行安装:
bash Anaconda2-5.2.0-Linux-x86_64.sh
安装完之后执行如下命令把conda更新为清华源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
先禁止系统自带的显卡驱动nouveau:
sudo vim /etc/modprobe.d/blacklist.conf //修改这个文件,在文件的后面添加第2行的内容
blacklist nouveau
sudo update-initramfs -u //执行这条语句之后重启系统
lsmod | grep no //如果没有任何输出证明禁止nouveau驱动成功
nvidia-smi
CUDA 10.2 官网地址:https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
sudo sh cuda_10.2.89_440.33.01_linux.run
测试CUDA:
执行以下命令:
cd ~/NVIDIA_CUDA-10.2_Samples/1_Utilities/deviceQuery
make
./deviceQuery
链接:https://developer.nvidia.com/rdp/cudnn-archive
下载后就是解压然后拷贝到相应的系统CUDA路径下:
tar -zxvf cudnn-8.0-linux-x64-v6.0.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
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
链接:https://github.com/open-mmlab/mmdetection/blob/master/docs/INSTALL.md
安装NCCL 2
链接:https://developer.nvidia.com/nccl
参考:https://docs.ksyun.com/documents/2593
不过并未完成其第四步
安装mmcv
链接:https://github.com/open-mmlab/mmcv
安装mmdetection
链接:https://github.com/open-mmlab/mmdetection/blob/master/docs/INSTALL.md
安装成功后测试demo
在demo文件下新建 test_retinaNet_res50.py,git下载model至根目录创建的checkpoints文件夹retinanet_r50_fpn_1x_20181125-7b0c2548.pth(model链接:https://github.com/open-mmlab/mmdetection/blob/master/docs/MODEL_ZOO.md)
from mmdet.apis import init_detector, inference_detector, show_result
import mmcv
config_file = '../configs/retinanet_r50_fpn_1x.py'
checkpoint_file = '../checkpoints/retinanet_r50_fpn_1x_20181125-7b0c2548.pth'
# build the model from a config file and a checkpoint file
model = init_detector(config_file, checkpoint_file, device='cuda:0')
# test a single image and show the results
img = 'demo.jpg' # or img = mmcv.imread(img), which will only load it once
result = inference_detector(model, img)
# visualize the results in a new window
show_result(img, result, model.CLASSES)
# or save the visualization results to image files
show_result(img, result, model.CLASSES, out_file='result.jpg')
demo目录下输入
python test_retinaNet_res50.py
报错,缺少一堆安装,conda加pip轮流发力,直到:
百度之,尝试了下面这句后成功:
pip install opencv-contrib-python