opened
zimenglan-sysu-512
username_0
## ❓ Questions and Help
hi does anyone build the benchmark into Jetson TX2?
does someone build benchmark in Jetson TX2?
issue
created
LeviViana
username_1
I'll probably be doing this in the next days. I'll share the process here.
comment
created
zimenglan-sysu-512
username_0
thanks @username_1 
look forward to.
comment
created
xxradon
username_2
@username_0 I have built benchmark on tx2,but not using pybind to register operator,I using  torch_script_custom_ops in https://pytorch.org/tutorials/advanced/torch_script_custom_ops.html .
By using pybind11 will lead some undefined symbols error.
comment
created
LeviViana
username_1
I got it running last week. I followed these two intructions:
- [PyTorch installation](https://github.com/Bfzanchetta/DLARM/blob/master/jetsontx2/pytorch_install.sh)
- [OpenCV installation]( https://github.com/jetsonhacks/buildOpenCVTX2/blob/master/buildAndPackageOpenCV.sh)
- `pip install -r requirments.txt`
- `pip install torchvision`
- `pip install matplotlib`

Moreover, I saw that during the week-end some instructions were added at the [PyTorch repo](https://github.com/pytorch/pytorch/commit/8961ad8c5ba644cb8c3d33f7e9a9536c3528eee3), but I didn't test it. One more thing to get the webcam demo running on the onboard camera, I changed [this line](https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/demo/webcam.py#L67) to:
- `cam = cv2.VideoCapture("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")`

Maybe [these examples](https://github.com/jetsonhacks/buildOpenCVTX2/tree/master/Examples) could be helpful as well.
comment
created
zimenglan-sysu-512
username_0
thanks @username_1 
i have installed pytorch from source, but i don't use jetpack4.2.
comment
created
LeviViana
username_1
I'm closing this issue, feel free to reopen if you have any further question.
comment
closed
LeviViana
username_1
issue
created
zimenglan-sysu-512
username_0
hi @username_1 and @username_2 
here is my installation:
```
## start, please enjoy...
- install cuda9 and cudnn7 (from host computer)  
- login tx2
- install python3.6 and pip3  
- install dependent libraries  
- install libraries of python3.6  
- install opencv3.4.3 from source  
- install pytorch from source  
- install torchvision  


#### install cuda9&cudnn7 from your own computer (host)
chmod +x JetPack-L4T-3.3-linux-x64_b39.run # please download it before these ops  
sudo sh JetPack-L4T-3.3-linux-x64_b39.run  


#### ssh to login in your tx2 machine
sudo nvpmodel -m 0 # maximize the gpu power  
sudo /home/nvidia/jetson_clocks.sh # maximize the cpu power   
head -n 1 /etc/nv_tegra_release # see what kind of JetPack do u install  
cat /usr/include/cudnn.h | grep CUDNN_MAJOR -A 2 # check the version of cuda and cudnn  
cat /proc/cpuinfo # see cpu info  


#### install tools
cd &&  mkdir tools/  
sudo add-apt-repository universe  
sudo apt-get update  
export LC_ALL="en_US.UTF-8"  
export LC_CTYPE="en_US.UTF-8"  
sudo dpkg-reconfigure locales  
sudo apt-get -y install tmux git ssh zssh vim htop locate  
sudo apt-get install apt-transport-https ca-certificates  
sudo apt-get update  


#### install gcc-5 && g++-5 is they do not exist
sudo apt-get update -y  
sudo apt-get upgrade -y  
sudo apt-get dist-upgrade -y  
sudo apt-get install gir1.2-packagekitglib-1.0 # =1.1.0-2 ** the key **   
sudo apt-get install build-essential software-properties-common -y  
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y  
sudo apt-get update -y  
sudo apt-get install gcc-5 g++-5  
gcc --version  
g++ --version  
cd /usr/bin/ # it will install the gcc-8&g++-8  
sudo rm gcc && sudo ln -s gcc-5 gcc  
sudo rm g++ && sudo ln -s g++-5 g++  


#### install or update cmake-3.14
cmake --version # please check the version of cmake before installing it  
cd && cd tools/  
wget https://github.com/Kitware/CMake/releases/download/v3.14.1/cmake-3.14.1.tar.gz  
tar xvf cmake-3.14.1.tar.gz && cd cmake-3.14.1  
sudo ./bootstrap && sudo make && sudo make install  
cd && cmake --version  


#### install gfortran-5 and gfortran
cd /usr/lib/python3/dist-packages/  
sudo cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so  
cd && cd tools/  
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y  
sudo apt-get update  
sudo apt-get -f install  
sudo apt-get -y install gfortran-5  
sudo apt-get -y install libblas-dev liblapack-dev libatlas-base-dev  
sudo apt-get -y install gfortran  


#### install aptitude and use it to install gfortran and scikit-build
sudo apt-get -y install aptitude  
sudo aptitude -y install gfortran-5  
sudo aptitude -y install gfortran  
sudo pip3 install scikit-build # please install pip3  


#### install python3.6
cd &&  mkdir tools/pip3 && cd tools/pip3  
sudo add-apt-repository ppa:deadsnakes/ppa -y  
sudo apt-get update  
sudo apt-get -y install python3.6 -y  
cd - && cp ~/.bashrc ~/.bashrc.bak  
echo "alias python3='/usr/bin/python3.6'" >> ~/.bashrc  
source ~/.bashrc  
python3 --version  
cd  


#### install pip3
cd && cd tools/pip3  
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate  
sudo python3.6 get-pip.py  
pip3 --version   
sudo pip3 install pip --upgrade  
cd  && pip3 --version  


#### install python3.6 dev and setuptools
cd && cd tools  
sudo apt-get -y install libexpat1=2.1.0-7 --upgrade  
sudo apt-get -y install libexpat1-dev  
sudo apt-get -y install libpython3.6-dev  
sudo apt-get -y install python3.6-dev  
sudo apt-get -y install python3-dev  
sudo apt-get -y install libhdf5-dev
sudo pip3 install -U pip setuptools  
sudo easy_install3 pip  
sudo python3.6 -m pip install -U pip  
sudo apt-get -y install python3-setuptools  
sudo apt-get -y install python3-sklearn # maybe no need  
sudo apt-get -y python3-numpy # maybe no need  
sudo apt-get -y python3-py # maybe no need  
sudo apt-get -y python3-pytest # maybe no need  


#### install jpeg-dev, libfreetype6-dev, libpng12-dev
sudo apt-get -y install libfreetype6-dev  
sudo apt-get -y install libjpeg-dev  
sudo apt-get -y install zlib1g-dev  
sudo apt-get -y install libtbb2  
sudo apt-get -y install libpng12-0=1.2.54-1ubuntu1  
sudo apt-get -y install libpng-dev  
sudo apt-get -y install libfreetype6-dev  
sudo apt-get -y install pkg-config # GTK development libraries   
sudo apt-get -y install libpng12-dev 
sudo apt-get -y install libhdf5-dev   
sudo apt-get -y install python3.6-tk # sudo apt-get -y install python3-tk


#### install libraries of python3.6
sudo pip3 install --upgrade pip  
sudo pip3 install --upgrade setuptools  
sudo pip3 install scikit-build  
sudo pip3 install numpy  
sudo python3.6 -m pip install numpy --upgrade  
sudo pip3 install pyyaml  
sudo pip3 install tqdm  
sudo easy_install packaging  
sudo pip3 install cython  
sudo pip3 install pycocotools  
sudo pip3 install yacs  
sudo easy_install-3.6 -U six  
sudo pip3 install scikit-image  
sudo pip3 install flask  
sudo pip3 install tornado  
sudo pip3 install pandas  
sudo pip3 install xlwt    
sudo pip3 install h5py  
sudo pip3 install scipy matplotlib ninja  


#### install scipy from source if pip3 can not install it
cd && cd tools/  
git clone https://github.com/scipy/scipy.git  
cd scipy  
git clean -xdf  
sudo python3.6 setup.py install --user  
cd - && python3.6 -c "import scipy; print(scipy.__version__)"   


### install matplotlib from source if pip3 can not install it
cd && cd tools/  
git clone git://github.com/matplotlib/matplotlib.git  
cd matplotlib/   
sudo apt-get build-dep python-matplotlib
cd - && python3.6 -c "import matplotlib; print(matplotlib.__version__)"  


#### install cffi
cd && cd tools/  
sudo apt-get -y install libffi-dev  
sudo pip3 install cffi  


#### install ninja from source if pip3 can not install it
cd && cd tools/  
git clone https://github.com/scikit-build/ninja-python-distributions.git  
cd ninja-python-distributions  
sudo python3.6 setup.py install # will raise an error that some package can't download and then  
cd _skbuild/linux-aarch64-3.6/cmake-build  
sudo rm v1.9.0.g5b44b.kitware.dyndep-1.jobserver-1.tar.gz  
sudo wget https://github.com/kitware/ninja/archive/v1.9.0.g5b44b.kitware.dyndep-1.jobserver-1.tar.gz --no-check-certificate  
cd -  # keep install  
sudo python3.6 setup.py install  
cd && cd tools/  
python3.6 -c "import ninja;print(ninja.__version__)"  


#### prepare libraries for opencv3.4.3
sudo apt-get install libavcodec-dev  
sudo apt-get install libavformat-dev  
sudo apt-get install libavutil-dev  
sudo apt-get install libswscale-dev  
sudo apt-get install libglew-dev  
sudo apt-get install libtiff5-dev  
sudo apt-get install libpostproc-dev  
sudo apt-get install libtbb-dev  
sudo apt-get install libv4l-dev  
sudo apt-get install v4l2ucp   
sudo apt-get install v4l-utils  
sudo apt-get install libeigen3-dev  
sudo apt-get install libglew1.6-dev  
sudo apt-get install ffmpeg 
sudo apt-get install libcairo2-dev  
sudo apt-get install libharfbuzz-dev  
sudo apt-get install libpango1.0-dev  
sudo apt-get install libgtk2.0-dev  
sudo apt-get install libjasper-dev  
sudo apt-get install libtiff-dev  
sudo apt-get install libdc1394-22-dev  
sudo apt-get install libgtkglext1  
sudo apt-get install libgtkglext1-dev  
sudo apt-get install libgstreamer1.0-dev  
sudo apt-get install libgstreamer-plugins-base1.0-dev  
sudo apt-get install libwayland-dev  
sudo apt-get install libegl1-mesa-dev  
sudo apt-get install libgles2-mesa-dev 
sudo apt-get install qtbase5-dev  
sudo apt-get install libxvidcore-dev  
sudo apt-get install libx264-dev  
sudo apt-get install qt5-default  
sudo apt-get install libdbus-1-dev  
sudo apt-get install libatspi2.0-dev  
sudo apt-get install libatk-bridge2.0-dev   
sudo vim /usr/local/cuda/include/cuda_gl_interop.h # comment line 62-68, exclude this line '#include <GL/gl.h>', see 'https://jkjung-avt.github.io/opencv3-on-tx2/' for more details  
cd /usr/lib/aarch64-linux-gnu/  
sudo ln -sf tegra/libGL.so libGL.so # fix the symbolic link of libGL.so  


#### install opencv-3.4.3
cd && cd tools/  
git clone https://github.com/opencv/opencv.git  
git clone https://github.com/opencv/opencv_extra.git # if u don't need it, please comment it  
cd opencv/  
git checkout 3.4.3  
vim cmake/OpenCVDetectPython.cmake # remove 'find_python(2.7 "${MIN_VER_PYTHON2}"' these lines and change 'find_python(3.4 "${MIN_VER_PYTHON3}"' to 'find_python(3.6 "${MIN_VER_PYTHON3}"', so that it can find python3.6  
sudo rm build/ -rf  
mkdir build/ && cd build/  
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE \
           -D PYTHON_EXECUTABLE=/usr/bin/python3.6 \
           -D OPENCV_PYTHON3_INSTALL_PATH=/usr/local/lib/python3.6/dist-packages \
           -D BUILD_OPENCV_PYTHON3=YES \
           -D CMAKE_INSTALL_PREFIX=/usr/local \
           -D WITH_CUDA=ON \
           -D CUDA_ARCH_BIN="6.2" \
           -D CUDA_ARCH_PTX="" \
           -D ENABLE_FAST_MATH=ON \
           -D CUDA_FAST_MATH=ON \
           -D WITH_CUBLAS=ON \
           -D WITH_LIBV4L=ON \
           -D WITH_GSTREAMER=ON \
           -D WITH_GSTREAMER_0_10=OFF \
           -D ENABLE_NEON=ON \
           -D BUILD_TESTS=OFF \
           -D BUILD_PERF_TESTS=OFF \
           -D BUILD_EXAMPLES=OFF \
           -D WITH_QT=ON \
           -D WITH_OPENGL=ON ..
sudo make -j4  
sudo make install  
cd ../.. 
locate cv2.so  
python3.6 -c "import cv2; print(cv2.__version__)"  


#### before installing pytorch, add env path for cudnn and python3.6
echo "export CUDNN_LIB_DIR=/usr/lib/aarch64-linux-gnu" >> ~/.bashrc  
echo "export CUDNN_INCLUDE_DIR=/usr/include" >> ~/.bashrc  
echo "PYTHONPATH=/usr/local/lib/python3.6/dist-packages" >> ~/.bashrc  
source ~/.bashrc  
echo $PYTHONPATH  


#### git clone pytorch, and do these modification
cd && cd tools/  
git clone http://github.com/pytorch/pytorch # see https://github.com/Bfzanchetta/DLARM/blob/master/jetsontx2/pytorch_install.sh for more information    
cd pytorch  
vim CMakeLists.txt # CmakeLists.txt : Change NCCL to 'Off' on line 100 or line 98  
vim tools/setup_helpers/nccl.py # nccl.py : Change 'USE_SYSTEM_NCCL' to 'False' on line 10 and  Add 'USE_NCCL = False' on line 9  
vim torch/csrc/cuda/nccl.h # nccl.h : Comment self-include on line 8 and Comment entire code from line 21 to 28  
vim torch/csrc/distributed/c10d/ddp.cpp # ddp.cpp : Comment nccl.h include on line 6 and Comment torch::cuda::nccl::reduce on line 182  


#### install pytorch
cd && sudo ./jetson_clocks.sh && sudo nvpmodel -m 0 && cd -    
git tag && git checkout v1.0.1 # if u want to install v1.0.1  
sudo pip3 install setuptools --upgrade  
sudo pip3 install -r requirements.txt  
git submodule update --init --recursive    
sudo python3.6 setup.py build_deps # old version: u can comment it  
sudo python3.6 setup.py build develop  
cd  


#### install torchvision
sudo pip3 --no-cache-dir install torchvision  


#### build maskrcnn-benchmark
cd && mkdir repos/ && cd repos/  
git clone https://github.com/facebookresearch/maskrcnn-benchmark.git  
cd maskrcnn-benchmark/  
sudo python3.6 setup.py build develop  

```
comment
created
ipa-mah
username_3
I tried benchmark on jetsontx2 but it's is very slow 1,25s/ img. 
Any idea to improve the framerate?
Thanks
comment
created
rabbitegg
username_4
hi, I also build maskrcnn-benchmark on jetson tx2. But I have problems running demo.py
`too many resources requested for launch`
Have you encountered a similar problem?
comment
created
AndreV84
username_5
getting this
`idia/.local/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/usr/include/python3.6m -c /home/nvidia/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.cu -o build/temp.linux-aarch64-3.6/home/nvidia/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_72,code=sm_72 -std=c++14
/home/nvidia/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.cu(42): error: identifier "AT_CHECK" is undefined

/home/nvidia/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.cu(68): error: identifier "AT_CHECK" is undefined

2 errors detected in the compilation of "/tmp/tmpxft_00003557_00000000-6_deform_pool_cuda.cpp1.ii".
error: command '/usr/local/cuda/bin/nvcc' failed with exit status 1
`
shall I create a separate thread?
comment