概述
本文参考https://detectron2.readthedocs.io/en/latest/tutorials/install.html
- conda create -n maskrcnn pip python==3.7
执行这个命令,由于之前设置了conda的清华安装源,结果命令卡住了,然后参考这个链接https://zhuanlan.zhihu.com/p/378258193
用这个命令“conda config --remove-key channels” 将安装源命令设置成了default值 - conda activate maskrcnn
- 安装pytorch,参考pytorch官网: pip3 install torch1.10.2+cu113 torchvision0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
- 这里提供了两种安装detectron2的方式:
Build Detectron2 from Source(从源代码编译安装)
Install Pre-Built Detectron2 (Linux only)(安装已经编译好的文件)
我选在了从源代码安装。 - 依次执行以下命令:
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
# (add --user if you don't have permission)
# Or, to install it from a local clone:
git clone https://github.com/facebookresearch/detectron2.git
python -m pip install -e detectron2
在执行第一条命令时出现/usr/local/cuda/bin/nvcc: No such file or directory错误,这个提示表示没有找到到cuda驱动,需要从新安装cuda驱动。
发现/usr/local/cuda/bin这个目录下面确实没有nvcc文件
通过which nvcc命令发现/usr/bin/nvcc下面有这个文件,这个貌似是系统自带的老版本的cuda驱动,于是便重新安装cuda驱动,进入官网
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=18.04&target_type=deb_network
选择好配置生成一下命令
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda
安装好cuda驱动后修改home 目录下面.bashrc文件在末尾添加cuda相关的路径
/usr/local/cuda-11.6/bin
export CUDA_HOME=/usr/local/cuda-11.6
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/cuda-11.6/bin
export CUDA_HOME=/usr/local/cuda-11.6
再次执行python -m pip install ‘git+https://github.com/facebookresearch/detectron2.git’,然后安装成功
Building wheels for collected packages: detectron2
Building wheel for detectron2 (setup.py) ... done
Created wheel for detectron2: filename=detectron2-0.6-cp37-cp37m-linux_x86_64.whl size=5415423 sha256=6a59f4656416a8748ab09bcb56f28641b50df380a3e7f7c5ef6c7af107ace48e
Stored in directory: /tmp/pip-ephem-wheel-cache-e6sx0sjt/wheels/07/dc/32/0322cb484dbefab8b9366bfedbaff5060ac7d149d69c27ca5d
Successfully built detectron2
Installing collected packages: detectron2
Successfully installed detectron2-0.6
最后
以上就是沉默服饰为你收集整理的Detectron2 安装(ubuntu 18.04.6 LTS)的全部内容,希望文章能够帮你解决Detectron2 安装(ubuntu 18.04.6 LTS)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复