非常贴心给大家准备了一个能一键运行的代码,运行完就可以顺利装完所有东西!直接跑demo!
conda create --name openmmlab python=3.8 -y
conda activate openmmlab
conda install pytorch==1.12.0 torchvision==0.13.0 pytorch-cuda=11.6 -c pytorch -c nvidia -y
pip install -U openmim
mim install mmcv-full
conda install -c conda-forge pycocotools -y
pip install mmdet
cd /home/jovyan/mmrotate
pip install -v -e .
conda install -n openmmlab ipykernel -y
pip install opencv-python-headless
我来详细介绍一下。首先创建虚拟环境,然后配置各个版本的包。要注意这些包的版本一定是要按照我上面的那些版本,其他的版本不一定能跑通!!!!要不然我为什么踩了四天的坑跑了四天的demo!!!!!!!(摔
之所以要创建一个ipykernel,是因为如果不创建你就不能在notebook里面进入虚拟环境!就是明明看到自己有虚拟环境丹斯死活进不去!
之所以要单独下载pycocotool,是因为如果直接pip install mmdet就会报错!
因为行星计算机每一次初始化基本都是相同的,每个人都是一样的配置!所以在我这里能跑通,大概率在您那里也可以跑通!
如果你在安装和跑demo的过程中遇到任何问题,首先看官网的安装须知(具体的链接我放在了我上一个博客:http://t.csdn.cn/WUDoR)。强烈建议好好从头到尾读mmrotate、mmcv、mmdection的安装须知!解决99%的问题!剩下1%的问题才是各种搜。
首先下载权重和config文件,也就对应着pth和py文件,代码:
mim download mmrotate --config oriented_rcnn_r50_fpn_fp16_1x_dota_le90 --dest .
可以自己更换权重文件!在官网的config那个文件夹,可以找到全部的模型的全部权重和config,比如这次用到的那个:
请注意一定要下载在这个目录!在mmrotate的第一层目录底下!也就是从根目录双击mmrotate的目录!一定一定是这个!
这时候在notebook上写代码:
from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import mmrotate
config_file = 'oriented_rcnn_r50_fpn_1x_dota_le90.py'
checkpoint_file = 'oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth'
model = init_detector(config_file, checkpoint_file,'cuda:0')
result = inference_detector(model, 'demo/demo.jpg')
show_result_pyplot(model,'demo/demo.jpg',result)
这个脚本也请放在那个目录里面!和权重和config文件一起! 那个demo.jpg是本来就有的!
理论上运行是可以出现结果的!如果有bug的那就请检查你的安装!
这个表格请务必重视!版本问题基本占据了我踩坑的99%问题!什么pillow,mmcv,pytorch。。。。能踩的我都踩过www
# packages in environment at /srv/conda/envs/openmmlab:
#
# Name Version Build Channel
_ipython_minor_entry_point 8.7.0 h3b92ee0_0 conda-forge
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_kmp_llvm conda-forge
addict 2.4.0 pypi_0 pypi
asttokens 2.2.1 pyhd8ed1ab_0 conda-forge
backcall 0.2.0 pyh9f0ad1d_0 conda-forge
backports 1.0 pyhd8ed1ab_3 conda-forge
backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge
blas 2.116 mkl conda-forge
blas-devel 3.9.0 16_linux64_mkl conda-forge
brotli 1.0.9 h166bdaf_8 conda-forge
brotli-bin 1.0.9 h166bdaf_8 conda-forge
brotlipy 0.7.0 py38h0a891b7_1005 conda-forge
bzip2 1.0.8 h7f98852_4 conda-forge
ca-certificates 2022.12.7 ha878542_0 conda-forge
certifi 2022.12.7 pyhd8ed1ab_0 conda-forge
cffi 1.15.1 py38h4a40e3a_3 conda-forge
charset-normalizer 2.1.1 pyhd8ed1ab_0 conda-forge
click 8.1.3 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
comm 0.1.2 pyhd8ed1ab_0 conda-forge
commonmark 0.9.1 pypi_0 pypi
contourpy 1.0.6 py38h43d8883_0 conda-forge
cryptography 38.0.4 py38h80a4ca7_0 conda-forge
cuda 11.6.1 0 nvidia
cuda-cccl 11.6.55 hf6102b2_0 nvidia
cuda-command-line-tools 11.6.2 0 nvidia
cuda-compiler 11.6.2 0 nvidia
cuda-cudart 11.6.55 he381448_0 nvidia
cuda-cudart-dev 11.6.55 h42ad0f4_0 nvidia
cuda-cuobjdump 11.6.124 h2eeebcb_0 nvidia
cuda-cupti 11.6.124 h86345e5_0 nvidia
cuda-cuxxfilt 11.6.124 hecbf4f6_0 nvidia
cuda-driver-dev 11.6.55 0 nvidia
cuda-gdb 12.0.90 0 nvidia
cuda-libraries 11.6.1 0 nvidia
cuda-libraries-dev 11.6.1 0 nvidia
cuda-memcheck 11.8.86 0 nvidia
cuda-nsight 12.0.78 0 nvidia
cuda-nsight-compute 12.0.0 0 nvidia
cuda-nvcc 11.6.124 hbba6d2d_0 nvidia
cuda-nvdisasm 12.0.76 0 nvidia
cuda-nvml-dev 11.6.55 haa9ef22_0 nvidia
cuda-nvprof 12.0.90 0 nvidia
cuda-nvprune 11.6.124 he22ec0a_0 nvidia
cuda-nvrtc 11.6.124 h020bade_0 nvidia
cuda-nvrtc-dev 11.6.124 h249d397_0 nvidia
cuda-nvtx 11.6.124 h0630a44_0 nvidia
cuda-nvvp 12.0.90 0 nvidia
cuda-runtime 11.6.1 0 nvidia
cuda-samples 11.6.101 h8efea70_0 nvidia
cuda-sanitizer-api 12.0.90 0 nvidia
cuda-toolkit 11.6.1 0 nvidia
cuda-tools 11.6.1 0 nvidia
cuda-visual-tools 11.6.1 0 nvidia
cudatoolkit 11.6.0 habf752d_9 nvidia
cycler 0.11.0 pyhd8ed1ab_0 conda-forge
cython 0.29.32 py38hfa26641_1 conda-forge
debugpy 1.6.4 py38hfa26641_0 conda-forge
decorator 5.1.1 pyhd8ed1ab_0 conda-forge
e2cnn 0.2.2 pypi_0 pypi
entrypoints 0.4 pyhd8ed1ab_0 conda-forge
executing 1.2.0 pyhd8ed1ab_0 conda-forge
ffmpeg 4.3 hf484d3e_0 pytorch
fonttools 4.38.0 py38h0a891b7_1 conda-forge
freetype 2.12.1 hca18f0e_1 conda-forge
gds-tools 1.5.0.59 0 nvidia
gmp 6.2.1 h58526e2_0 conda-forge
gnutls 3.6.13 h85f3911_1 conda-forge
icu 70.1 h27087fc_0 conda-forge
idna 3.4 pyhd8ed1ab_0 conda-forge
importlib-metadata 5.1.0 pypi_0 pypi
ipykernel 6.19.2 pyh210e3f2_0 conda-forge
ipython 8.7.0 pyh41d4057_0 conda-forge
jedi 0.18.2 pyhd8ed1ab_0 conda-forge
jpeg 9e h166bdaf_2 conda-forge
jupyter_client 7.4.8 pyhd8ed1ab_0 conda-forge
jupyter_core 5.1.0 py38h578d9bd_0 conda-forge
kiwisolver 1.4.4 py38h43d8883_1 conda-forge
lame 3.100 h166bdaf_1003 conda-forge
lcms2 2.14 h6ed2654_0 conda-forge
ld_impl_linux-64 2.39 hcc3a1bd_1 conda-forge
lerc 4.0.0 h27087fc_0 conda-forge
libblas 3.9.0 16_linux64_mkl conda-forge
libbrotlicommon 1.0.9 h166bdaf_8 conda-forge
libbrotlidec 1.0.9 h166bdaf_8 conda-forge
libbrotlienc 1.0.9 h166bdaf_8 conda-forge
libcblas 3.9.0 16_linux64_mkl conda-forge
libcublas 11.9.2.110 h5e84587_0 nvidia
libcublas-dev 11.9.2.110 h5c901ab_0 nvidia
libcufft 10.7.1.112 hf425ae0_0 nvidia
libcufft-dev 10.7.1.112 ha5ce4c0_0 nvidia
libcufile 1.5.0.59 0 nvidia
libcufile-dev 1.5.0.59 0 nvidia
libcurand 10.3.1.50 0 nvidia
libcurand-dev 10.3.1.50 0 nvidia
libcusolver 11.3.4.124 h33c3c4e_0 nvidia
libcusparse 11.7.2.124 h7538f96_0 nvidia
libcusparse-dev 11.7.2.124 hbbe9722_0 nvidia
libdeflate 1.14 h166bdaf_0 conda-forge
libffi 3.4.2 h7f98852_5 conda-forge
libgcc-ng 12.2.0 h65d4601_19 conda-forge
libgfortran-ng 12.2.0 h69a702a_19 conda-forge
libgfortran5 12.2.0 h337968e_19 conda-forge
libgomp 12.2.0 h65d4601_19 conda-forge
libhwloc 2.8.0 h32351e8_1 conda-forge
libiconv 1.17 h166bdaf_0 conda-forge
liblapack 3.9.0 16_linux64_mkl conda-forge
liblapacke 3.9.0 16_linux64_mkl conda-forge
libnpp 11.6.3.124 hd2722f0_0 nvidia
libnpp-dev 11.6.3.124 h3c42840_0 nvidia
libnsl 2.0.0 h7f98852_0 conda-forge
libnvjpeg 11.6.2.124 hd473ad6_0 nvidia
libnvjpeg-dev 11.6.2.124 hb5906b9_0 nvidia
libpng 1.6.39 h753d276_0 conda-forge
libsodium 1.0.18 h36c2ea0_1 conda-forge
libsqlite 3.40.0 h753d276_0 conda-forge
libstdcxx-ng 12.2.0 h46fd767_19 conda-forge
libtiff 4.4.0 h82bc61c_5 conda-forge
libuuid 2.32.1 h7f98852_1000 conda-forge
libwebp-base 1.2.4 h166bdaf_0 conda-forge
libxcb 1.13 h7f98852_1004 conda-forge
libxml2 2.10.3 h7463322_0 conda-forge
libzlib 1.2.13 h166bdaf_4 conda-forge
llvm-openmp 15.0.6 he0ac6c6_0 conda-forge
markdown 3.4.1 pypi_0 pypi
matplotlib-base 3.6.2 py38hb021067_0 conda-forge
matplotlib-inline 0.1.6 pyhd8ed1ab_0 conda-forge
mkl 2022.1.0 h84fe81f_915 conda-forge
mkl-devel 2022.1.0 ha770c72_916 conda-forge
mkl-include 2022.1.0 h84fe81f_915 conda-forge
mmcv-full 1.7.0 pypi_0 pypi
mmdet 2.26.0 pypi_0 pypi
mmrotate 0.3.3 dev_0
model-index 0.1.11 pypi_0 pypi
mpmath 1.2.1 pypi_0 pypi
munkres 1.1.4 pyh9f0ad1d_0 conda-forge
ncurses 6.3 h27087fc_1 conda-forge
nest-asyncio 1.5.6 pyhd8ed1ab_0 conda-forge
nettle 3.6 he412f7d_0 conda-forge
nsight-compute 2022.4.0.15 0 nvidia
numpy 1.23.5 py38h7042d01_0 conda-forge
opencv-python 4.6.0.66 pypi_0 pypi
opencv-python-headless 4.6.0.66 pypi_0 pypi
openh264 2.1.1 h780b84a_0 conda-forge
openjpeg 2.5.0 h7d73246_1 conda-forge
openmim 0.3.3 pypi_0 pypi
openssl 3.0.7 h0b41bf4_1 conda-forge
ordered-set 4.1.0 pypi_0 pypi
packaging 22.0 pyhd8ed1ab_0 conda-forge
pandas 1.5.2 pypi_0 pypi
parso 0.8.3 pyhd8ed1ab_0 conda-forge
pexpect 4.8.0 pyh1a96a4e_2 conda-forge
pickleshare 0.7.5 py_1003 conda-forge
pillow 9.2.0 py38h9eb91d8_3 conda-forge
pip 22.3.1 pyhd8ed1ab_0 conda-forge
platformdirs 2.6.0 pyhd8ed1ab_0 conda-forge
prompt-toolkit 3.0.36 pyha770c72_0 conda-forge
psutil 5.9.4 py38h0a891b7_0 conda-forge
pthread-stubs 0.4 h36c2ea0_1001 conda-forge
ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge
pure_eval 0.2.2 pyhd8ed1ab_0 conda-forge
pycocotools 2.0.6 py38h26c90d9_1 conda-forge
pycparser 2.21 pyhd8ed1ab_0 conda-forge
pygments 2.13.0 pyhd8ed1ab_0 conda-forge
pyopenssl 22.1.0 pyhd8ed1ab_0 conda-forge
pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge
pysocks 1.7.1 pyha2e5f31_6 conda-forge
python 3.8.15 h4a9ceb5_0_cpython conda-forge
python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge
python_abi 3.8 3_cp38 conda-forge
pytorch 1.12.0 py3.8_cuda11.6_cudnn8.3.2_0 pytorch
pytorch-cuda 11.6 h867d48c_1 pytorch
pytorch-mutex 1.0 cuda pytorch
pytz 2022.7 pypi_0 pypi
pyyaml 6.0 pypi_0 pypi
pyzmq 24.0.1 py38hfc09fa9_1 conda-forge
readline 8.1.2 h0f457ee_0 conda-forge
requests 2.28.1 pyhd8ed1ab_1 conda-forge
rich 12.6.0 pypi_0 pypi
scipy 1.9.3 pypi_0 pypi
setuptools 65.5.1 pyhd8ed1ab_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
stack_data 0.6.2 pyhd8ed1ab_0 conda-forge
sympy 1.11.1 pypi_0 pypi
tabulate 0.9.0 pypi_0 pypi
tbb 2021.7.0 h924138e_1 conda-forge
terminaltables 3.1.10 pypi_0 pypi
tk 8.6.12 h27826a3_0 conda-forge
torchvision 0.13.0 py38_cu116 pytorch
tornado 6.2 py38h0a891b7_1 conda-forge
traitlets 5.7.1 pyhd8ed1ab_0 conda-forge
typing_extensions 4.4.0 pyha770c72_0 conda-forge
unicodedata2 15.0.0 py38h0a891b7_0 conda-forge
urllib3 1.26.13 pyhd8ed1ab_0 conda-forge
wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge
wheel 0.38.4 pyhd8ed1ab_0 conda-forge
xorg-libxau 1.0.9 h7f98852_0 conda-forge
xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge
xz 5.2.6 h166bdaf_0 conda-forge
yapf 0.32.0 pypi_0 pypi
zeromq 4.3.4 h9c3ff4c_1 conda-forge
zipp 3.11.0 pypi_0 pypi
zlib 1.2.13 h166bdaf_4 conda-forge
zstd 1.5.2 h6239696_4 conda-forge
Note: you may need to restart the kernel to use updated packages.
里面比较值得注意的是这几个东西的版本:
package | 版本 |
cuda | 11.6 |
pytorch | 1.12 |
mmcv-full | 1.7.0 |
cudatoolkit | 11.6 |
mmdet | 2.26 |
一旦你遇到了什么版本问题,请查看这个博客里面的版本!我能保证里面的版本在2022年12月18日是能跑通demo的!
最后一句忠告:本来demo就应该不会有什么bug,常见的bug早就被找出来了。所以如果你觉得非常坎坷,建议重装环境,换个环境说不定就不会遇到这个bug了。
换环境也很简单,要么新建环境,要么stop server,然后再开。