
超详细ubuntu20.04运行安装yolact++,编译DCNv2,pytorch=1.11.0 cudatoolkit=11.3
超详细ubuntu20.04运行安装yolact++,编译DCNv2,pytorch=1.11.0 torchvision=0.12.0 torchaudio=0.11.0 cudatoolkit=11.3
超详细ubuntu20.04运行安装yolact++,编译DCNv2,pytorch=1.11.0 torchvision=0.12.0 torchaudio=0.11.0 cudatoolkit=11.3
我的电脑已经安装了CUDA11.4和cuDNN v8.2.4:ubuntu20.04,GeForce RTX 3060,CUDA Version: 11.4安装cuda
一、先安装Anaconda
超详细Ubuntu安装Anaconda步骤+Anconda常用命令
STEP1
:使用bash命令安装AnacondaControl +Alt +T
打开新的命令行窗口,使用bash
命令安装Anaconda
bash Anaconda3-2023.03-Linux-x86_64.sh
-
STEP2
:阅读并接受安装协议
在STEP1中已经执行了安装命令。指令执行结果首先让我们审阅安装协议,这里一直按Enter直到出现Do you accept the license terms? [yes|no]
,表示协议阅读完毕输入yes
即可继续安装 -
STEP3
:确认安装位置
在STEP2输入yes
后会提示确认安装位置,这里点击Enter
,默认即可,界面如下:
接下来Anaconda
就会开始安装。 -
STEP4
:初始化Anaconda
(包含环境变量的设置)
执行完STEP3
,Anaconda
在Ubuntu
系统里面的安装基本完毕了,但是还需要最后一步 初始化Anaconda
,这一步只需要根据提示输入yes
即可,界面如下:PS
:Anaconda
安装完成以后出现的个提示解读
1️⃣For changes to take effect, close and re-open your current shell.
,翻译过来就是:关闭当前命令行,并重新打开,刚刚安装和初始化Anaconda
设置才可以生效,重新打开一个命令行后(Control +Alt +T
)直接就进入了conda
的base
环境,如下:
2️⃣If you'd prefer that conda's base environment not be activated on startup, set the auto_activate_base parameter to false:
,翻译过来就是:如果您希望 conda 的基础环境在启动时不被激活,请将 auto_activate_base
参数设置为 false
,命令如下:
conda config --set auto_activate_base false
当然这一条命令执行完毕后,想要再次进入conda
的base
环境,只需要使用对应的conda
指令即可,如下:
conda activate base
效果如下:
- Anconda常用命令,参见博主另一篇博文:conda常用指令
二、克隆这个存储库:
git clone https://github.com/dbolya/yolact.git
cd yolact
三、使用手动地方法设置环境:
- 手动地使用
pip
创建yolact
环境
# 创建yolact 环境,环境名为yolact ,python版本选择3.7
conda create -n yolact python=3.7
cgm@cgm:~/yolact$ conda create -n yolact python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/cgm/anaconda3/envs/yolact
added / updated specs:
- python=3.7
The following packages will be downloaded:
package | build
---------------------------|-----------------
certifi-2022.12.7 | py37h06a4308_0 150 KB
pip-22.3.1 | py37h06a4308_0 2.7 MB
python-3.7.16 | h7a1cb2a_0 44.8 MB
setuptools-65.6.3 | py37h06a4308_0 1.1 MB
wheel-0.38.4 | py37h06a4308_0 63 KB
------------------------------------------------------------
Total: 48.9 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main
_openmp_mutex pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu
ca-certificates pkgs/main/linux-64::ca-certificates-2023.01.10-h06a4308_0
certifi pkgs/main/linux-64::certifi-2022.12.7-py37h06a4308_0
ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.38-h1181459_1
libffi pkgs/main/linux-64::libffi-3.4.2-h6a678d5_6
libgcc-ng pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1
libgomp pkgs/main/linux-64::libgomp-11.2.0-h1234567_1
libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1
ncurses pkgs/main/linux-64::ncurses-6.4-h6a678d5_0
openssl pkgs/main/linux-64::openssl-1.1.1t-h7f8727e_0
pip pkgs/main/linux-64::pip-22.3.1-py37h06a4308_0
python pkgs/main/linux-64::python-3.7.16-h7a1cb2a_0
readline pkgs/main/linux-64::readline-8.2-h5eee18b_0
setuptools pkgs/main/linux-64::setuptools-65.6.3-py37h06a4308_0
sqlite pkgs/main/linux-64::sqlite-3.41.1-h5eee18b_0
tk pkgs/main/linux-64::tk-8.6.12-h1ccaba5_0
wheel pkgs/main/linux-64::wheel-0.38.4-py37h06a4308_0
xz pkgs/main/linux-64::xz-5.2.10-h5eee18b_1
zlib pkgs/main/linux-64::zlib-1.2.13-h5eee18b_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate yolact
#
# To deactivate an active environment, use
#
# $ conda deactivate
- 使用-
conda activate yolact
激活yolact
环境
conda activate yolact
四、Anaconda添加清华镜像源
- 第一步:添加Anaconda的清华镜像
anaconda默认的各种包的下载源,全部在国外,下载速度慢,而且经常中断,所以需要配置国内安装的镜像,这样下载速度就很快了。
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- 第二步:设置搜索时显示通道地址
conda config --set show_channel_urls yes
注意:首次运行conda config
会产生一个anacnoda
的配置文件,这个配置文件和jupyter的配置文件一样,默认是不存在的。Windows
为的默认位置为C://Users/username/.condarc
,Linux/Mac
为~/.condarc
。
- 第三步:更新pip的源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
- 查看当前下载源
(yolact) cgm:~$ conda config --show channels
channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- defaults
添加上了上述镜像后,原先源仍然存在,文件中的-defaults
就是原来的源。
- 安装需要的依赖项
pip install cython
pip install opencv-python pillow pycocotools matplotlib
- 安装
pytorch
时需要先去查看自己的cuda
版本: (我的是cuda 11.4
)
nvcc --version
(yolact) cgm@cgm:~/yolact$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Wed_Jun__2_19:15:15_PDT_2021
Cuda compilation tools, release 11.4, V11.4.48
Build cuda_11.4.r11.4/compiler.30033411_0
五、安装pytorch v1.11.0
# CUDA 10.2
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=10.2 -c pytorch
# CUDA 11.3 用这个
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
# CPU Only
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cpuonly -c pytorch
- 安装完成后
再次运行这个命令
是这样的
(yolact) cgm@cgm:~/yolact$ conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
- 验证
pytorch cuda
可用
安装完成后,进入python
交互环境,然后输入import torch
和torch.__version__
,如下图所示:
(yolact) cgm:~/yolact/external/DCNv2$ python
Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.__version__
'1.11.0'
>>> exit()
六、选择编译DCNv2_latest
因为这个仓库支持pytorch1.11
,还在ubuntu20.04、python3.8(conda)、cuda_11.4
上进行了测试
-
下载DCNv2_latest并把文件放入
yolact/external/DCNv2文件夹
里
(其实就是把yolact/external/DCNv2文件夹
里的东西全部换成DCNv2_latest
里的内容) -
安装DCNv2_latest
cgm:~$ conda activate yolact
(yolact) cgm:~$ cd yolact/
(yolact) cgm:~/yolact$ cd external/DCNv2/
(yolact) cgm:~/yolact/external/DCNv2$ python3 setup.py build develop
running build
running build_ext
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/utils/cpp_extension.py:387: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
warnings.warn(msg.format('we could not find ninja.'))
error: [Errno 2] No such file or directory: ':/usr/local/cuda/bin/nvcc': ':/usr/local/cuda/bin/nvcc'
一个警告:
we could not find ninja.
解决办法:conda install ninja
一个错误:
No such file or directory: ':/usr/local/cuda/bin/nvcc': ':/usr/local/cuda/bin/nvcc'
解决办法:export CUDA_HOME=/usr/local/cuda-11.4
我在配置CUDA的环境变量设置的CUDA_HOME
是这样的,不知道有问题没
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
(yolact) cgm:~/yolact$ conda install ninja
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(yolact) cgm:~/yolact/external/DCNv2$ export CUDA_HOME=/usr/local/cuda-11.4
(yolact) cgm:~/yolact/external/DCNv2$ python3 setup.py build develop
running build
running build_ext
。。。。。。。。。。。。。。。省略。。。。。。。。。。。。。。。。。。。
Installed /home/cgm/yolact/external/DCNv2
Processing dependencies for DCNv2==0.1
Finished processing dependencies for DCNv2==0.1
- 使用
DCNv2
里的测试文件测试一下(其实是DCNv2_latest
仓库里的)
(yolact) cgm:~/yolact/external/DCNv2$ python testcpu.py
torch.Size([2, 64, 128, 128])
torch.Size([20, 32, 7, 7])
torch.Size([20, 32, 7, 7])
torch.Size([20, 32, 7, 7])
0.971507, 1.943014
0.971507, 1.943014
Zero offset failed
tensor([[[[-1.0135e+00, -4.6850e-01, 1.7804e+00, -6.0886e-01],
[ 7.3593e-01, 2.8503e-01, 6.1490e-01, 4.4265e-01],
[-8.8087e-01, 1.2574e+00, -1.5251e-01, 1.4350e+00],
[-3.9296e-01, -6.1919e-01, -1.0510e+00, 2.5626e-01]],
[[-1.0217e+00, 1.0652e+00, -7.6357e-01, -1.6576e+00],
[ 4.9901e-02, 4.5321e-01, -4.1713e-01, 1.7700e+00],
[-7.9118e-01, -1.5507e+00, 2.8329e-02, -7.4099e-01],
[-6.1223e-01, 9.3652e-01, -2.8428e-01, 1.6628e-01]]],
[[[ 1.1454e+00, 2.2602e-01, -4.8800e-01, 2.3064e+00],
[ 8.8013e-02, -2.7906e-01, 2.8250e-02, -6.8291e-01],
[-1.4291e-01, -1.0015e+00, -4.0506e-01, -8.8468e-01],
[-6.1278e-01, 1.3654e-01, 3.4561e-01, 1.0930e+00]],
[[ 1.0873e+00, 1.9230e-01, 1.9262e+00, -3.2653e-01],
[-1.0328e+00, 6.9613e-02, -3.1395e-01, 6.8715e-01],
[-1.6661e-03, 1.7526e+00, -4.5932e-01, 4.6319e-01],
[ 2.3197e-01, -1.1628e+00, 5.0414e-01, -3.8338e-01]]]])
tensor([[[[ 2.5804e+32, -4.6850e-01, 2.5804e+32, -6.0886e-01],
[ 7.3593e-01, 2.8503e-01, 6.1490e-01, 4.4265e-01],
[-8.8087e-01, 1.2574e+00, -1.5251e-01, 1.4350e+00],
[-3.9296e-01, -6.1919e-01, -1.0510e+00, 2.5626e-01]],
[[-1.0217e+00, 1.0652e+00, -7.6357e-01, -1.6576e+00],
[ 4.9901e-02, 4.5321e-01, -4.1713e-01, 1.7700e+00],
[-7.9118e-01, -1.5507e+00, 2.8329e-02, -7.4099e-01],
[-6.1223e-01, 9.3652e-01, -2.8428e-01, 1.6628e-01]]],
[[[ 1.1454e+00, 2.2602e-01, -4.8800e-01, 2.3064e+00],
[ 8.8013e-02, -2.7906e-01, 2.8250e-02, -6.8291e-01],
[-1.4291e-01, -1.0015e+00, -4.0506e-01, -8.8468e-01],
[-6.1278e-01, 1.3654e-01, 3.4561e-01, 1.0930e+00]],
[[ 1.0873e+00, 1.9230e-01, 1.9262e+00, -3.2653e-01],
[-1.0328e+00, 6.9613e-02, -3.1395e-01, 6.8715e-01],
[-1.6661e-03, 1.7526e+00, -4.5932e-01, 4.6319e-01],
[ 2.3197e-01, -1.1628e+00, 5.0414e-01, -3.8338e-01]]]],
grad_fn=<MulBackward0>)
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #0 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #2 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
check_gradient_dpooling: True
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #1 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #3 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #4 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
Traceback (most recent call last):
File "testcpu.py", line 265, in <module>
check_gradient_dconv()
File "testcpu.py", line 97, in check_gradient_dconv
eps=1e-3, atol=1e-4, rtol=1e-2))
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1400, in gradcheck
return _gradcheck_helper(**args)
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1417, in _gradcheck_helper
check_undefined_grad=check_undefined_grad)
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1062, in _gradcheck_real_imag
rtol, atol, check_grad_dtypes, nondet_tol)
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1114, in _slow_gradcheck
raise GradcheckError(_get_notallclose_msg(a, n, i, j, complex_indices, test_imag))
torch.autograd.gradcheck.GradcheckError: Jacobian mismatch for output 0 with respect to input 0,
numerical:tensor([[ 1.9983e+21, 1.0478e-01, 1.9941e+21, ..., 0.0000e+00,
0.0000e+00, 0.0000e+00],
[-3.9977e+21, 0.0000e+00, -1.2379e+30, ..., 2.9671e+02,
3.0040e+02, 2.9727e+02],
[ 4.0461e+21, 2.6744e+01, 6.4508e+34, ..., -2.9671e+02,
-3.0040e+02, -2.9727e+02],
...,
[ 0.0000e+00, 0.0000e+00, -6.4508e+34, ..., -8.9017e+02,
-3.0040e+02, -2.9773e+02],
[ 6.4508e+34, 0.0000e+00, 6.4508e+34, ..., 5.9346e+02,
-3.0041e+02, -2.9739e+02],
[-3.8686e+29, 0.0000e+00, 6.4508e+34, ..., 8.9017e+02,
-1.5974e-02, 5.3287e-02]])
analytical:tensor([[-0.4609, 0.1048, 0.0000, ..., 0.0000, 0.0000, 0.0000],
[ 0.0609, 0.0000, 0.0224, ..., 0.0000, 0.0000, 0.0000],
[ 0.2284, 0.2145, 0.1046, ..., 0.0000, 0.0000, 0.0000],
...,
[ 0.0000, 0.0000, 0.0000, ..., 0.0000, 0.0101, -0.4662],
[ 0.0000, 0.0000, 0.0000, ..., 0.0000, 0.0000, -0.3597],
[ 0.0000, 0.0000, 0.0000, ..., 0.0000, -0.0109, 0.0000]])
(yolact) cgm:~/yolact/external/DCNv2$ python testcuda.py
torch.Size([2, 64, 128, 128])
torch.Size([20, 32, 7, 7])
torch.Size([20, 32, 7, 7])
torch.Size([20, 32, 7, 7])
0.971507, 1.943014
0.971507, 1.943014
Zero offset failed
tensor([[[[-0.7596, -0.1410, -0.3335, 0.8734],
[ 0.3883, 0.9641, -0.4845, 0.0139],
[ 1.0427, -1.5031, -1.3956, -0.7286],
[-0.4027, 1.0158, -1.4057, 0.4795]],
[[-0.2074, 0.2585, 0.0192, 1.7720],
[ 2.3009, 1.1745, -0.7150, -0.5564],
[ 0.9626, 0.3455, 0.9791, -0.8539],
[ 0.6182, 0.0554, -1.0775, -1.2543]]],
[[[ 1.0509, -0.2816, 1.3106, 1.8552],
[ 0.3615, 0.4687, -0.0643, -0.1565],
[ 0.4575, 2.1677, 0.1354, -1.0271],
[ 1.2323, -1.2368, 0.8022, -0.3021]],
[[-0.2007, 1.0510, 0.5536, -1.3705],
[ 1.4579, -1.3516, -0.0833, -0.8850],
[-0.8864, 0.9026, 0.2035, 1.5334],
[-0.7752, 0.1500, 1.2292, -0.4139]]]], device='cuda:0')
tensor([[[[-0.7598, -0.1410, -0.3335, 0.8735],
[ 0.3884, 0.9639, -0.4846, 0.0139],
[ 1.0430, -1.5029, -1.3955, -0.7285],
[-0.4026, 1.0156, -1.4053, 0.4795]],
[[-0.2074, 0.2585, 0.0192, 1.7725],
[ 2.3008, 1.1748, -0.7148, -0.5566],
[ 0.9624, 0.3455, 0.9790, -0.8540],
[ 0.6182, 0.0554, -1.0771, -1.2539]]],
[[[ 1.0508, -0.2817, 1.3105, 1.8555],
[ 0.3616, 0.4688, -0.0643, -0.1565],
[ 0.4575, 2.1680, 0.1354, -1.0273],
[ 1.2324, -1.2363, 0.8022, -0.3022]],
[[-0.2007, 1.0508, 0.5537, -1.3701],
[ 1.4580, -1.3516, -0.0833, -0.8848],
[-0.8862, 0.9028, 0.2035, 1.5332],
[-0.7754, 0.1499, 1.2295, -0.4138]]]], device='cuda:0',
grad_fn=<MulBackward0>)
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #0 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #2 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
check_gradient_dpooling: True
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #1 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #3 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py:648: UserWarning: Input #4 requires gradient and is not a double precision floating point or complex. This check will likely fail if all the inputs are not of double precision floating point or complex.
f'Input #{idx} requires gradient and '
Traceback (most recent call last):
File "testcuda.py", line 265, in <module>
check_gradient_dconv()
File "testcuda.py", line 97, in check_gradient_dconv
eps=1e-3, atol=1e-4, rtol=1e-2))
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1400, in gradcheck
return _gradcheck_helper(**args)
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1417, in _gradcheck_helper
check_undefined_grad=check_undefined_grad)
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1062, in _gradcheck_real_imag
rtol, atol, check_grad_dtypes, nondet_tol)
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 1110, in _slow_gradcheck
analytical = _check_analytical_jacobian_attributes(tupled_inputs, o, nondet_tol, check_grad_dtypes)
File "/home/cgm/anaconda3/envs/yolact/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 548, in _check_analytical_jacobian_attributes
FAILED_NONDET_MSG)
torch.autograd.gradcheck.GradcheckError: Backward is not reentrant, i.e., running backward with same input and grad_output multiple times gives different values, although analytical gradient matches numerical gradient.The tolerance for nondeterminism was 0.0.
NOTE: If your op relies on non-deterministic operations i.e., it is listed here:
https://pytorch.org/docs/stable/generated/torch.use_deterministic_algorithms.html
this failure might be expected.
If you are adding a new operator, please file an issue and then use one of the
workarounds. The workaround depends on how your test invokes gradcheck/gradgradcheck.
If the test
- manually invokes gradcheck/gradgradcheck, then call gradcheck/gradgradcheck
with `nondet_tol=<tol>` as a keyword argument.
- is OpInfo-based (e.g., in test_ops.py), then modify the OpInfo for the test
to have `gradcheck_nondet_tol=<tol>`.
- is a Module test (e.g., in common_nn.py), then modify the corresponding
module_test entry to have `gradcheck_nondet_tol=<tol>
七、测试图片
要评估模型,请将相应的权重文件放在 ./weights 目录中
并运行以下命令之一。每个配置的名称都是文件名中数字之前的所有内容(例如,yolact_base
对应 yolact_base_54_800000.pth
)。
# 在指定图像上显示定性结果
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --image=你的图像.png
# 处理图像并将其保存到另一个文件
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --image=你输入的图像.png:输出图像.png
# 处理整个文件夹的图像
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --images=你输入图像的文件夹路径:你输出图像的文件夹路径
- 在
yolact
源码文件夹内新建文件夹weights
,将下载好的YOLACT
模型yolact_base_54_800000.pth
拷贝进去;( 模型下载地址) - 在
yolact
源码文件夹内新建文件夹images
,将你的下载好的测试的图片放入文件夹里 - 激活yolact 环境;
conda activate yolact
- 进入到
yolact
源码路径下:
cd yolact
- 运行如下代码即可:
# 在指定图像上显示定性结果
python eval.py --trained_model=weights/yolact_resnet50_54_800000.pth --score_threshold=0.15 --top_k=15 --image=images/6.jpeg
其中train_model为预训练权重;score_threshold为置信度阈值,对置信度小于0.15的物体bounding box进行滤除。top_k为保留每个类别置信度排名前15个score。image为需要测试的图片。
八、测试video
# 实时显示视频。 “--video_multiframe”将一次处理那么多帧以提高性能。
# 如果需要,使用“--display_fps”直接在帧上绘制 FPS。
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4 --video=my_video.mp4
# 实时显示网络摄像头。如果你有多个网络摄像头,请传递你想要的网络摄像头的索引而不是 0。
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4 --video=0
# 处理视频并将其保存到另一个文件。现在使用与上面相同的管道,所以速度很快!
python eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4 --video=input_video.mp4:output_video.mp4
我的实际测试:
python eval.py --trained_model=weights/yolact_resnet50_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4 --video=0
九、训练自己的数据集
这部分我暂时不需要,没做,给一些其他人的参考链接
yolact实例分割实战(含训练自己的数据集)
哔哩哔哩视频【扫盲】Yolact++实例分割网络训练
【实例分割yolact++】从头训练自己的yolact++模型
十、最后看一下pip list
(yolact) cgm:~/yolact$ pip list
Package Version Editable project location
------------------- --------- -------------------------------
actionlib 1.14.0
angles 1.9.13
arbotix-python 0.11.0
arbotix_sensors 0.11.0
base_local_planner 1.17.3
brotlipy 0.7.0
catkin 0.8.10
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 3.1.0
cryptography 38.0.2
cycler 0.11.0
Cython 0.29.33
DCNv2 0.1 /home/cgm/yolact/external/DCNv2
diagnostic-updater 1.11.0
dynamic-reconfigure 1.7.3
fonttools 4.38.0
gencpp 0.7.0
geneus 3.0.0
genlisp 0.4.18
genmsg 0.6.0
gennodejs 2.0.2
genpy 0.6.15
idna 3.4
image-geometry 1.16.2
kiwisolver 1.4.4
laser_geometry 1.6.7
matplotlib 3.5.3
message-filters 1.16.0
mkl-fft 1.1.0
mkl-random 1.1.0
mkl-service 2.3.0
numpy 1.21.6
opencv-python 4.7.0.72
packaging 23.0
Pillow 9.4.0
pip 23.0.1
pycocotools 2.0.6
pycparser 2.21
pyOpenSSL 23.1.1
pyparsing 3.0.9
PySocks 1.7.1
python-dateutil 2.8.2
requests 2.28.2
rosbag 1.16.0
rosclean 1.15.8
rosgraph 1.16.0
roslaunch 1.16.0
roslib 1.15.8
roslz4 1.16.0
rosmaster 1.16.0
rosmsg 1.16.0
rosnode 1.16.0
rosparam 1.16.0
rospy 1.16.0
rosservice 1.16.0
rostest 1.16.0
rostopic 1.16.0
rosunit 1.15.8
roswtf 1.16.0
sensor-msgs 1.13.1
setuptools 67.6.1
six 1.16.0
smclib 1.8.6
tf 1.13.2
tf2-geometry-msgs 0.7.6
tf2-py 0.7.6
tf2-ros 0.7.6
topic-tools 1.16.0
torch 1.11.0
torchaudio 0.11.0
torchvision 0.12.0
typing_extensions 4.5.0
urllib3 1.26.15
wheel 0.40.0
更多推荐
所有评论(0)