配置环境:Python3.6.9、Ubuntu 18.04、PyTorch 1.2.0、CUDA 10.1、NCCL 2、GCC 7.5.0、GTX1660Ti
显卡驱动安装
执行命令,查看当前推荐显卡 ubuntu-drivers devices

安装推荐版本 sudo apt install nvidia-440 nvidia-settings nvidia-prime
CUDA 安装
https://developer.nvidia.com/cuda-10.1-download-archive-update1
也可以根据自己的需求下载对应的版本。


执行命令 chmod +x cuda_10.1.168_418.67_linux.run


注意:因为我们已经安装好了驱动,所以此时不需要安装驱动418.67了。
等待安装完毕之后执行以下命令:
sudo nano ~/.bashrc
打开.bashrc文件之后,将以下两句写到最末尾
export PATH="/usr/local/cuda-10.1/bin:$PATH"
export LD_LIBRARY_PATH="/usr/lcoal/cuda-10.1/lib64:$LD_LIBRARY_PATH"
完成之后,保存退出。最后执行以下命令
source ~/.bashrc
cudnn下载及其安装
https://developer.nvidia.com/cudnn
选择好与cuda对应版本的cudnn下载, 我当时选择的是cuDNN Library for Linux

下载完成之后,执行以下命令,将相关文件复制到cuda文件夹中。注意的是,cuDNN解压后的文件夹名称就是cuda。
sudo cp cuda/lib64/* /usr/local/cuda-10.1/lib64/
sudo cp cuda/include/* /usr/local/cuda-10.1/include/
pytorch1.2.0安装
https://pytorch.org/get-started/previous-versions/
这里为什么选择以前的版本安装,是因为使用pytorch1.5后,安装mmdetection可能会报错。
报错结果可能如下:
mmdet/ops/nms/src/nms_cuda.cpp:4:23: error: ‘AT_CHECK’ was not declared in this scope
#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")
后来,我重新安装了pytorch1.2版本,则没有报错。
在安装过程中,可能会出现如下错误:

ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-392mjzes/future/setup.py'"'"'; __file__='"'"'/tmp/pip-install-392mjzes/future/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-wsfxr0g3
cwd: /tmp/pip-install-392mjzes/future/
Complete ou

本文档详细介绍了在Ubuntu 18.04上手动安装mmdetection的过程,包括环境配置(Python 3.6.9、Ubuntu 18.04、PyTorch 1.2.0、CUDA 10.1、NCCL 2、GCC 7.5.0、GTX1660Ti)、显卡驱动安装、CUDA安装、cudnn下载与安装、PyTorch 1.2.0安装、mmcv安装以及解决安装过程中遇到的问题,如错误提示和依赖缺失。通过此教程,读者可以成功在Ubuntu 18.04环境下搭建mmdetection的开发环境。

1048

被折叠的 条评论
为什么被折叠?



