# DeepTAM Knowledgebase
A bit of a knowledge base for important stuff and errors arround DeepTAM which you might encounter or at least that I encountered.
https://github.com/lmb-freiburg/deeptam
Feel free to pm me if you found a solution for another problem you had and I'll add it to this list.
https://github.com/MrMinemeet/
## Important Information
### ADTF
DeepTAM and ADTF don't get along with each other that well, as ADTF uses a special place for Cuda which Tensorflow doesn't like
Also some other stuff
### Other stuff that is important
* Restart your system from time to time when trying to get DeepTAM running
## Installation
```
conda create -y -n deeptam python=3.5 conda activate deeptam
conda install -y pip boost cython conda-build
wget http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz
mkdir Eigen
tar -xf 3.3.7.tar.gz -C Eigen --strip-components=1
ln -s $(dirname $(dirname $(which python)))/lib/libboost_python35.so.1.67.0 $(dirname $(dirname $(which python)))/lib/libboost_python-py35.so
pip install --global-option=build_ext --global-option="-I$(pwd)/Eigen/" minieigen
pip install tensorflow-gpu==1.4.0 scikit-image
```
# setup libraries and cmake
```
source /system/apps/biosoft/cuda-8.0/bashrc
source /system/apps/biosoft/cudnn-6.0_cuda8.0/bashrc
source /system/apps/biosoft/cmake-3.13.4/bashrc
```
# build and register lmbspecialops
```
git clone -b deeptam https://github.com/lmb-freiburg/lmbspecialops.git
LMBSPECIALOPS_DIR=$PWD/lmbspecialops
cd $LMBSPECIALOPS_DIR
mkdir build
cd build
cmake ..
make -j 8
conda-develop $LMBSPECIALOPS_DIR/python
checkout deeptam and download data and weights
cd ../..
git clone https://github.com/lmb-freiburg/deeptam.git
DEEPTAM_DIR=$PWD/deeptam
conda-develop $DEEPTAM_DIR/tracking/python
conda-develop $DEEPTAM_DIR/mapping/python
cd $DEEPTAM_DIR/tracking/data
wget "https://vision.in.tum.de/rgbd/dataset/freiburg1/rgbd_dataset_freiburg1_desk.tgz"
tar -xvf "rgbd_dataset_freiburg1_desk.tgz"
cd $DEEPTAM_DIR/tracking/weights
wget --no-check-certificate https://lmb.informatik.uni-freiburg.de/people/zhouh/deeptam/deeptam_tracker_weights.tgz
tar -xvf deeptam_tracker_weights.tgz
cd $DEEPTAM_DIR/tracking/examples
```
## Errors
### Eigen/Core not found
#### Error Message
```
fatal error: Eigen/Dense: No such file or directory
compilation terminated.
```
#### Solution
* `sudo apt-get install libeigen3-dev`
* `sudo apt install python3-minieigen ` after that with pip3 again
### Boost/Python.hpp
#### Error Message
```
fatal error: Boost/Python.hpp: No such file or directory
compilation terminated.
```
#### Solution
```
sudo apt-get install libboost-all-dev
```
### startsWith(...)
#### Error Message
```
data has no method called startsWith()
```
#### Solution
comment the functions out
### `libcublas.so` not found
#### Error Message
```
fatal error: libcublas.so.8.0: No such file or directory
```
#### Solution
cmake needs a version that is installed
```
sudo apt install nvidia-cuda-toolkit
```
### GCC versions later than 6 not supported
#### Error Message
```
error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
```
##### Solution
Start cmake with a parameter to use older version that is installed(install an older if not present)
I tested it on 4.8 and it worked. Versjk 5.5 was buggy and I'd have had to compile 5.4 on my own.
`cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" ..`
### Tensorflow not found
#### Error Message
```
Module Tensorflow not found
```
#### Solution
* reinstall Tensorflow & Tensorflow-GPU
* make environment with pyhton3 `mkvirtualenv -p /usr/bin/python3.6 --clear DeepTAM`
### Wrong CMAKE version when compiling `lmbspecialops`
#### Error Message
```
Traceback (most recent call last):
File "example_basic.py", line 102, in <module>
main()
File "example_basic.py", line 72, in main
tracker_core = TrackerCore(tracking_module_path,checkpoint,intrinsics)
File "/home/aadc/deeptam/tracking/python/deeptam_tracker/tracker.py", line 231, in __init__
self._tracking_mod = load_myNetworks_module_noname(self._tracking_module)
File "/home/aadc/deeptam/tracking/python/deeptam_tracker/utils/helpers.py", line 44, in load_myNetworks_module_noname
return load_myNetworks_module(module_name, path_to_myNetworks)
File "/home/aadc/deeptam/tracking/python/deeptam_tracker/utils/helpers.py", line 32, in load_myNetworks_module
return importlib.import_module('.'+myNetworks_name, module_name)
File "/home/aadc/.virtualenvs/DeepTAM/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "../python/deeptam_tracker/models/networks.py", line 2, in <module>
from .blocks import *
File "../python/deeptam_tracker/models/blocks.py", line 1, in <module>
from .helpers import *
File "../python/deeptam_tracker/models/helpers.py", line 1, in <module>
import lmbspecialops as sops
File "/home/aadc/lmbspecialops/python/lmbspecialops.py", line 27, in <module>
lmbspecialopslib = tf.load_op_library(_lib_path)
File "/home/aadc/.virtualenvs/DeepTAM/lib/python3.5/site-packages/tensorflow/python/framework/load_library.py", line 61, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: /home/aadc/lmbspecialops/build/lib/lmbspecialops.so: undefined symbol: _ZTIN10tensorflow8OpKernelE
W0703 13:59:34.039927 140179251631872 deprecation_wrapper.py:119] From /home/aadc/deeptam/tracking/python/deeptam_tracker/tracker.py:242: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.
```
#### Solution
`https://github.com/lmb-freiburg/demon/issues/26`
`https://github.com/lmb-freiburg/lmbspecialops/issues/3`
### there was an error in verifying the lgenfe output!
#### Error Message
```
Error: Internal Compiler Error (codegen): "there was an error in verifying the lgenfe output!"
```
#### Solution
run make command with only one thread
`make -j1`
and try another gcc version in the cmake argument
### Undefinded Symbol
#### Error Message
```
tensorflow.python.framework.errors_impl.NotFoundError: /home/adas/DeepTAM/lmbspecialops/build/lib/lmbspecialops.so: undefined symbol: _ZTIN10tensorflow8OpKernelE
```
#### Solution
not a good one found yet, just try intalling it from beginning again.
Sry but that but it helped for me
### math_function.hpp not found
#### Error Message
```
/home/adas/.virtualenvs/DeepTAM/lib/python3.6/site-packages/tensorflow/include/unsupported/Eigen/CXX11/../../../Eigen/Core:59:34: fatal error: math_functions.hpp: No such file or directory
#include <math_functions.hpp>
```
#### Solution
For cuda 9.1 replace math_functions.hpp with cuda_runtime.h
This change should happen in a `Core` file which is in your `.virtualenv` folder
```
- #include <math_functions.hpp>
+ #include <cuda_runtime.h>
```
### libcublas.so.8.0 cannot open shared object
#### Error Message
```
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
```
#### Solution
Install the right version of Cuda Toolkit 8.0 for your system from this nvidia website
https://developer.nvidia.com/cuda-80-ga2-download-archive
>[Credits](https://stackoverflow.com/questions/47200662/importerror-libcublas-so-8-0-cannot-open-shared-object-file-no-such-file-or-d#47200772)
### Cuda Toolkit 8.0 -> `InstallUtils.pm`
#### Error Message
In log:
```
Can't locate InstallUtils.pm in @INC (you may need to install the InstallUtils module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at ./install-sdk-linux.pl line 6.
```
### Solution
* unpack `.run` file using the command: `sudo sh ./cuda*.run --tar mxvf`
* copy unpacked file `InstallUtils.pm` to `/usr/lib/x86_64-linux-gnu/perl-base`
* enter command in terminal: `export $PERL5LIB`
>[Credits](https://askubuntu.com/a/1087842/978055)
### Conv2DCustomBackpropInputOp only supports NHWC
#### Error Message
```
InvalidArgumentError (see above for traceback): Conv2DCustomBackpropInputOp only supports NHWC.
[[Node: net_F1/flowdepth/upsample_flow3to2/upconv/conv2d_transpose = Conv2DBackpropInput[T=DT_FLOAT, data_format="NCHW", padding="SAME", strides=[1, 1, 2, 2], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](net_F1/flowdepth/upsample_flow3to2/upconv/stack, net_F1/flowdepth/upsample_flow3to2/upconv/kernel/read, net_F1/flowdepth/predict_flow3/conv2/BiasAdd)]]
```
#### Solution
Something with TF and GPU not getting detected, no solution found yet
# Other important stuff
install Cuda 10.0
Tensorflow(Normal and GPU) 1.14.0