Slighty modified from the CenterNet installation guide. Install the DCNv2_latest externally instead of within the repository. Tested on Ubuntu 20.04 with Python3.8 and PyTorch 1.13.1. NVIDIA GPU(s) is(are) needed for both training and testing.
After install Anaconda:
-
[Optional but recommended] create a new environment.
conda create -n kgn python=3.8
And activate the environment.
conda activate kgn
-
Install pytorch. For pytorch 1.13.1:
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia
Manually open
torch/nn/functional.py
and find the line withtorch.batch_norm
and replace thetorch.backends.cudnn.enabled
withFalse
. ??For the pytorch v0.4.0 and v0.4.1, disable cudnn batch normalization(Due to this issue).
# PYTORCH=/path/to/pytorch # usually ~/anaconda3/envs/CenterNet/lib/python3.6/site-packages/ # for pytorch v0.4.0 sed -i "1194s/torch\.backends\.cudnn\.enabled/False/g" ${PYTORCH}/torch/nn/functional.py # for pytorch v0.4.1 sed -i "1254s/torch\.backends\.cudnn\.enabled/False/g" ${PYTORCH}/torch/nn/functional.py
-
Clone this repo:
KGN_ROOT=/path/to/clone/kgn git clone https://github.com/ $KGN_ROOT
-
Install the requirements
pip install -r requirements.txt
-
Install and Compile Deformable Convolutional Networks V2 from DCNv2_latest.
# DCNv2=/path/to/clone/DCNv2 git clone https://github.com/jinfagang/DCNv2_latest $DCNv2 cd $DCNv2 python setup.py install --user
-
[Optional, only required if you are using extremenet or multi-scale testing] Compile NMS.
cd ./src/lib/external make