AaronJackson / vrn

:man: Code for "Large Pose 3D Face Reconstruction from a Single Image via Direct Volumetric CNN Regression"
http://aaronsplace.co.uk/papers/jackson2017recon/
MIT License
4.51k stars 747 forks source link

Maybe Helpful: Ubuntu 14.04 to suxessfull running vrn Howto/run-throuth with Cuda 7.5 #141

Open SandUhrGucker opened 4 years ago

SandUhrGucker commented 4 years ago

Just to help others:

Hi @all. After a Week in the reuirements/depencies Hell I figured out how to run this vrn on a fresh installed Ubuntu 14.04. I also tried Centos 7 and Ubuntu 18.04 with no Luck. This guide avoid segfaults, missing functionality and broken Pipes. However its not a super-sexy clean code or howto - but at the end it runs.

#starting from ubuntu 14.04 desktop ISO
sudo apt-get update && sudo apt-get -y install ssh
sudo apt-get -y install nano mc build-essential libreadline-dev g++ gcc git

# nvidia driver
sudo apt-get -y install nvidia-352 nvidia-modprobe
sudo reboot

--

#check GPU driver install ok
lsmod |egrep "nou|nvid"

#install cuda 7.5 (already tried 8/9/10 _without_ Luck)
cd ~
wget http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run
chmod +x cuda_7.5.18_linux.run
./cuda_7.5.18_linux.run --extract=$HOME
sudo ./cuda-linux64-rel-7.5.18-19867135.run -noprompt
sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/ld.so.conf.d/cuda.conf"
sudo ldconfig

#install cudunn 5.1
wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64/libcudnn5_5.1.10-1+cuda7.5_amd64.deb
sudo dpkg -i libcudnn5_5.1.10-1+cuda7.5_amd64.deb
wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64/libcudnn5-dev_5.1.10-1+cuda7.5_amd64.deb
sudo dpkg -i libcudnn5-dev_5.1.10-1+cuda7.5_amd64.deb

#install deps
sudo apt -y install libgoogle-glog-dev libboost-all-dev

#and dirty hotfixes:
sudo apt-get install libmatio2
sudo ln -s /usr/lib/x86_64-linux-gnu/libmatio.so.2 /usr/local/lib/libmatio.so.2

#install python stuff
sudo apt-get install -y curl
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
sudo ln -s /home/bubu/.local/bin/pip /usr/bin/pip
pip -V

#cmake >3 needed!
mkdir -p $HOME/Work/usr/{local,src}
cd $HOME/Work/usr/local
wget https://cmake.org/files/v3.5/cmake-3.5.0-rc1.tar.gz
tar -xvzf cmake-3.5.0-rc1.tar.gz
cd cmake-3.5.0-rc1/
./configure --prefix=/usr/share/cmake-3.5
make
sudo make install
sudo ln -s /usr/share/cmake-3.5/bin/cmake /usr/bin/cmake
cmake --version

#add python pip modules
python -m pip install --user dlib 
python -m pip install --user matplotlib  
python -m pip install --user numpy 
python -m pip install --user visvis 
python -m pip install --user imageio
python -m pip install --upgrade --user pillow   
python -m pip install --upgrade --user scipy
python -m pip install --upgrade --user PyMCubes
python -m pip install --upgrade --user sklearn

#openblas befor torch just for proper compiling of torch and fb
mkdir -p $HOME/usr/{local,src}
cd $HOME/usr/local
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make NO_AFFINITY=1 USE_OPENMP=1
sudo make install
CMAKE_LIBRARY_PATH=/opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH

# Install the Torch distribution.
mkdir -p $HOME/usr/{local,src}
cd $HOME/usr/local
git clone https://github.com/torch/distro.git
mv distro torch
cd torch
sudo ./install-deps
./install.sh
source $HOME/usr/local/torch/install/bin/torch-activate

# Install THPP and fb.python for the face alignment code
cd $HOME/usr/src
git clone https://github.com/1adrianb/thpp.git
cd thpp/thpp
THPP_NOFB=1 ./build.sh

# Install fb.python.
cd $HOME/usr/src
git clone https://github.com/facebook/fblualib.git
cd fblualib/fblualib/python
luarocks make rockspec/*

#here somtimes crude action: if cmake symlink to new version is lost at this point, recreate it:
sudo rm /usr/bin/cmake
sudo ln -s /usr/share/cmake-3.5/bin/cmake /usr/bin/cmake

#add lua rocks  
luarocks install --server=https://luarocks.org/dev matio
luarocks install --deps-mode=all --local npy4th

#vrn
cd $HOME/usr/local
git clone --recursive https://github.com/AaronJackson/vrn.git
cd vrn/
./download.sh
./run.sh

#maybe some alternatives are required:
set Torch_DIR /home/bubu/usr/local/torch/install
sudo apt-get install lua5.1
TORCH_LUA_VERSION=LUA51 ./install.sh
source /home/bubu/Work/usr/local/torch/install/bin/torch-activate
source ~/.bashrc
Torch_DIR=/home/bubu/usr/local/torch/install THPP_NOFB=1 sudo ./build.sh
wget https://github.com/google/googletest/archive/release-1.7.0.zip

# some handcraft needed:
nano face-alignment/utils.lua
    REMOVE LINE: from mpl_toolkits.mplot3d import Axes3D
    REMOVE LINE: import matplotlib.pyplot as plt
    REMOVE LINE: import matplotlib.patches as patches
nano face-alignment/facedetection_dlib.lua
    REPLACE LINE: local detections = py.reval('[np.asarray([d.left(), d.top(), d.right(), d.bottom()]) for i, d in enumerate(dets)]',{dets=dets})                     
    BY LINE: local detections = py.reval('[np.asarray([d.left(), d.top(), d.right(), d.bottom()],dtype=float) for i, d in enumerate(dets)]',{dets=dets})
./run.sh

#It should run fine now and show you a result. if you run it in a ssh session like I do, you may want to convert a raw file to alias wavefront obj-file:
python raw2obj.py --volume output/asj.raw --image examples/scaled/asj.jpg --obj asj.obj
AaronJackson commented 4 years ago

Thanks, that should be helpful to some people! I'll leave this open so people can find it more easly.

Altally commented 2 years ago

O python 2 foi descontinuado, alguma solução? O pip não faz o download do dlib e dos outros

Altally commented 2 years ago

what versions of pip modules?