Because installing DensePose is hard, I provided a simple installation guid based on DensePose Installation and the provided Dockerfile.
Requirements:
Notes:
Installing a fresh Ubuntu 16.04
sudo apt-get update
sudo apt-get upgrade
reboot
We need to have linux kernel 4.4.0 since it's the only kernel that is supported for CUDA 9.0 and ubuntu repositories only provide linux source for that kernel. For Ubuntu 16.04 LTS on x86-64, both the HWE kernel (4.13.x for 16.04.4) and the server LTS kernel (4.4.x) are supported in CUDA 9.2. Visit https://wiki.ubuntu.com/Kernel/Support for more information.
sudo apt-get install build-essential
sudo apt-get install linux-image-extra-virtual
sudo apt-get install linux-source
reboot
make sure you are booting into the right kernel version ( 4.4.0 ). since we loaded kernel 4.4.0 we should see the output of uname something like this:
uname -r
4.4.0-128-generic
then we should install the kernel headers
sudo apt-get source linux-image-$(uname -r)
sudo apt-get install linux-headers-$(uname -r)
Downloading cuda 9.0 runfile
Download cudnn7 ( possibly 7.1 )
install cuda 9.0:
Create a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents
blacklist nouveau
options nouveau modeset=0
Regenerate the kernel initramfs:
sudo update-initramfs -u
reboot to runlevel 3 adding character 3 to the end of the grub bootloader at boot time will get you to the runlevel 3
go to you cuda directory
sudo sh ./cuda-installer
installing cudnn 7 using nvidia documentation
tar -xzvf cudnn-9.0-linux-x64-v7.tgz
Copy the following files into the CUDA Toolkit directory.
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
Next we have to download Nvidia NCCL for ubuntu
We should also download anaconda to install caffe2
chmod +x Anaconda2-5.2.0-Linux-x86_64.sh
./Anaconda2-5.2.0-Linux-x86_64.sh
We assume that anaconda is installed in our home directory and the path looks like this:
/home/terra/anaconda2
adding the path to our environment path
export PATH="/home/terra/anaconda2/bin${PATH:+:${PATH}}"
export PATH="/usr/local/cuda/bin${PATH:+:${PATH}}"
export LD_LIBRARY_PATH=/usr/local/cuda/lib64\
${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Installing caffe2
conda install -c caffe2 caffe2-cuda9.0-cudnn7
python2 -c 'from caffe2.python import workspace; print (workspace.NumCudaDevices())'
Install the COCO API:
# COCOAPI=/path/to/clone/cocoapi
git clone https://github.com/cocodataset/cocoapi.git $COCOAPI
cd $COCOAPI/PythonAPI
# Install into global site-packages
make install
# Alternatively, if you do not have permissions or prefer
# not to install the COCO API into global site-packages
python2 setup.py install --user
Note that instructions like # COCOAPI=/path/to/install/cocoapi
indicate that you should pick a path where you'd like to have the software cloned and then set an environment variable (COCOAPI
in this case) accordingly.
Finally Installing Densepose
Clone the Densepose repository:
# DENSEPOSE=/path/to/clone/densepose
git clone https://github.com/facebookresearch/densepose $DENSEPOSE
Install Python dependencies:
pip install -r $DENSEPOSE/requirements.txt
Set up Python modules:
cd $DENSEPOSE && make
Check that Detectron tests pass (e.g. for SpatialNarrowAsOp test
):
python2 $DENSEPOSE/detectron/tests/test_spatial_narrow_as_op.py
Build the custom operators library:
cd $DENSEPOSE && make ops
Check that the custom operator tests pass:
python2 $DENSEPOSE/detectron/tests/test_zero_even_op.py
Get necessary files to run, train and evaluate DensePose.
cd $DENSEPOSE/DensePoseData
bash get_densepose_uv.sh
For training, download the DensePose-COCO dataset:
bash get_DensePose_COCO.sh
For evaluation, get the necessary files:
bash get_eval_data.sh
Create a symlink for the COCO dataset in your datasets/data
folder.
ln -s /path/to/coco $DENSEPOSE/detectron/datasets/data/coco
Create symlinks for the DensePose-COCO annotations
ln -s $DENSEPOSE/DensePoseData/DensePose_COCO/densepose_coco_2014_minival.json $DENSEPOSE/detectron/datasets/data/coco/annotations/
ln -s $DENSEPOSE/DensePoseData/DensePose_COCO/densepose_coco_2014_train.json $DENSEPOSE/detectron/datasets/data/coco/annotations/
ln -s $DENSEPOSE/DensePoseData/DensePose_COCO/densepose_coco_2014_valminusminival.json $DENSEPOSE/detectron/datasets/data/coco/annotations/
Your local COCO dataset copy at /path/to/coco
should have the following directory structure:
coco
|_ coco_train2014
| |_ <im-1-name>.jpg
| |_ ...
| |_ <im-N-name>.jpg
|_ coco_val2014
|_ ...
|_ annotations
|_ instances_train2014.json
|_ ...
Feel free to open an issue if you find anything that needs to be improved. I will try to keep this guide updated.