NVIDIA / retinanet-examples

Fast and accurate object detection with end-to-end GPU optimization

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Solved] Cannot Install on l4t-ml or l4t-pytorch docker images!

tahasadr opened this issue · comments

Hi
I've trained my model on PC with 1080, and branch 20.11
But when i try to install odtk on l4t-ml or l4t-pytorch (jetpack 4.6)
there are plenty of errors.
I reached 20.03 branch across some issues but this one got error on opencv!

In file included from /retinanet/csrc/engine.cpp:35:0:
    /retinanet/csrc/calibrator.h:25:10: fatal error: opencv2/opencv.hpp: No such file or directory

but opencv exists in these pathes:

/usr/include/opencv4
/usr/local/include/opencv4

any help would be appreciated !

I solved opencv issue by changing setup.py like this

from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension

setup(
    name='odtk',
    version='0.2.4',
    description='Fast and accurate single shot object detector',
    author = 'NVIDIA Corporation',
    packages=['retinanet', 'retinanet.backbones'],
    ext_modules=[CUDAExtension('retinanet._C',
        ['csrc/extensions.cpp', 'csrc/engine.cpp', 'csrc/cuda/decode.cu', 'csrc/cuda/decode_rotate.cu', 'csrc/cuda/nms.cu', 'csrc/cuda/nms_iou.cu'],
        extra_compile_args={
            'cxx': ['-std=c++14', '-O2', '-Wall'],
            'nvcc': [
                '-std=c++14', '--expt-extended-lambda', '--use_fast_math', '-Xcompiler', '-Wall',
                '-gencode=arch=compute_60,code=sm_60', '-gencode=arch=compute_61,code=sm_61',
                '-gencode=arch=compute_70,code=sm_70', '-gencode=arch=compute_72,code=sm_72',
                '-gencode=arch=compute_75,code=sm_75', '-gencode=arch=compute_75,code=compute_75'
            ],
        },include_dirs=['/usr/local/include','/usr/include','/usr/local/include/opencv4','/usr/include/opencv4'],
        libraries=['nvinfer', 'nvinfer_plugin', 'nvonnxparser','opencv_core', 'opencv_highgui', 'opencv_imgproc', 'opencv_imgcodecs'])
    ],
    cmdclass={'build_ext': BuildExtension.with_options(no_python_abi_suffix=True)},
    install_requires=[
        'torch>=1.0.0a0',
        'torchvision',
        'apex @ git+https://github.com/NVIDIA/apex',
        'pycocotools @ git+https://github.com/nvidia/cocoapi.git#subdirectory=PythonAPI',
        'pillow',
        'requests',
    ],
    entry_points = {'console_scripts': ['odtk=retinanet.main:main']}
)

but there is a new error:

/retinanet/csrc/plugins/DecodePlugin.h:72:10: error: looser throw specifier for 'virtual size_t retinanet::DecodePlugin::getSerializationSize() const'
size_t getSerializationSize() const override {

Ok, the error above is because Im using Jetpack 4.6, which has TensorRT 8.
check here for more info

Finally I was able to build to odtk:20.03 on XavierNX Using This Configuration
Jetpack 4.5.1
modified setup.py as above
modifed Dockerfile like this

FROM nvcr.io/nvidia/l4t-ml:r32.5.0-py3
COPY . retinanet/
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade ninja
RUN pip3 install --no-cache-dir -e retinanet/