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 18.04 to suxessfull running vrn Howto/run-throuth with Cuda10.1 #142

Open SandUhrGucker opened 4 years ago

SandUhrGucker commented 4 years ago
#starting from ubuntu 18.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
cd /home/bubu/Downloads/
9  ls -l

10 sudo chmod +x NVIDIA-Linux-x86_64-440.59.run 11 sudo ./NVIDIA-Linux-x86_64-440.59.run 12 sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf" 13 sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf" 14 cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf 15 sudo update-initramfs -u 16 sudo reboot

17 sudo apt-get update 19 cd Downloads/ 20 ls -l

install cuda, cudunn, nccl

21 sudo ./NVIDIA-Linux-x86_64-440.59.run 24 sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb 25 sudo apt-key add /var/cuda-repo-10-1-local-10.1.243-418.87.00/7fa2af80.pub 26 sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb 27 sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.1_amd64.deb 28 sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.1_amd64.deb 29 sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.1_amd64.deb 30 sudo dpkg -i nccl-repo-ubuntu1804-2.5.6-ga-cuda10.1_1-1_amd64.deb sudo apt-get update sudo apt-get install cuda

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

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

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

#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/usr/{local,src}
cd $HOME/usr/local
wget https://cmake.org/files/v3.17/cmake-3.17.0-rc1.tar.gz
tar -xvzf cmake-3.17.0-rc1.tar.gz
cd cmake-3.17.0-rc1
./configure --prefix=/usr/share/cmake-3.17
make
sudo make install
sudo ln -s /usr/share/cmake-3.17/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
git clone https://github.com/AaronJackson/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!  
cmake --version
sudo rm /usr/bin/cmake
sudo ln -s /usr/share/cmake-3.17/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. Do them only if needed!
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
RobinAnd commented 4 years ago

This was very helpful! Thanks a lot!

ameerusman commented 4 years ago

I am having issue in installing Openblas on doing this command: make NO_AFFINITY=1 USE_OPENMP=1 I get the error in the end:

END OF TESTS make[1]: Leaving directory '/home/admin/usr/local/OpenBLAS/ctest' make[1]: Entering directory '/home/admin/usr/local/OpenBLAS/exports' cc -O2 -DMAX_STACK_ALLOC=2048 -fopenmp -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DUSE_OPENMP -DNO_WARMUP -DMAX_CPU_NUMBER=8 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.11.dev\" -msse3 -mssse3 -msse4.1 -march=skylake-avx512 -mavx2 -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I.. -shared -o ../libopenblas_skylakexp-r0.3.11.dev.so \ -Wl,--whole-archive ../libopenblas_skylakexp-r0.3.11.dev.a -Wl,--no-whole-archive \ -Wl,-soname,libopenblas.so.0 -lm -lpthread -lgfortran -lm -lpthread -lgfortran /usr/bin/ld: cannot find -lgfortran collect2: error: ld returned 1 exit status make[1]: *** [Makefile:181: ../libopenblas_skylakexp-r0.3.11.dev.so] Error 1 make[1]: Leaving directory '/home/admin/usr/local/OpenBLAS/exports' make: *** [Makefile:116: shared] Error 2