|
| 1 | +FROM nvidia/cuda:11.6.2-devel-ubuntu20.04 |
| 2 | + |
| 3 | +# Set environment variables |
| 4 | +ENV NVENCODE_CFLAGS "-I/usr/local/cuda/include" |
| 5 | +ENV CV_VERSION=4.2.0 |
| 6 | +ENV DEBIAN_FRONTEND=noninteractive |
| 7 | + |
| 8 | +# Get all dependencies |
| 9 | +RUN apt-get update && apt-get install -y \ |
| 10 | + git zip unzip libssl-dev libcairo2-dev lsb-release libgoogle-glog-dev libgflags-dev libatlas-base-dev libeigen3-dev software-properties-common \ |
| 11 | + build-essential cmake pkg-config libapr1-dev autoconf automake libtool curl libc6 libboost-all-dev debconf libomp5 libstdc++6 \ |
| 12 | + libqt5core5a libqt5xml5 libqt5gui5 libqt5widgets5 libqt5concurrent5 libqt5opengl5 libcap2 libusb-1.0-0 libatk-adaptor neovim \ |
| 13 | + python3-pip python3-tornado python3-dev python3-numpy python3-virtualenv libpcl-dev libgoogle-glog-dev libgflags-dev libatlas-base-dev \ |
| 14 | + libsuitesparse-dev python3-pcl pcl-tools libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libtbb2 libtbb-dev libjpeg-dev \ |
| 15 | + libpng-dev libtiff-dev libdc1394-22-dev xfce4-terminal &&\ |
| 16 | + rm -rf /var/lib/apt/lists/* |
| 17 | + |
| 18 | +# OpenCV with CUDA support |
| 19 | +WORKDIR /opencv |
| 20 | +RUN git clone https://github.com/opencv/opencv.git -b $CV_VERSION &&\ |
| 21 | + git clone https://github.com/opencv/opencv_contrib.git -b $CV_VERSION |
| 22 | + |
| 23 | +# While using OpenCV 4.2.0 we have to apply some fixes to ensure that CUDA is fully supported, thanks @https://github.com/gismo07 for this fix |
| 24 | +RUN mkdir opencvfix && cd opencvfix &&\ |
| 25 | + git clone https://github.com/opencv/opencv.git -b 4.5.2 &&\ |
| 26 | + cd opencv/cmake &&\ |
| 27 | + cp -r FindCUDA /opencv/opencv/cmake/ &&\ |
| 28 | + cp FindCUDA.cmake /opencv/opencv/cmake/ &&\ |
| 29 | + cp FindCUDNN.cmake /opencv/opencv/cmake/ &&\ |
| 30 | + cp OpenCVDetectCUDA.cmake /opencv/opencv/cmake/ |
| 31 | + |
| 32 | +WORKDIR /opencv/opencv/build |
| 33 | + |
| 34 | +RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \ |
| 35 | +-D CMAKE_INSTALL_PREFIX=/usr/local \ |
| 36 | +-D OPENCV_GENERATE_PKGCONFIG=ON \ |
| 37 | +-D BUILD_EXAMPLES=OFF \ |
| 38 | +-D INSTALL_PYTHON_EXAMPLES=OFF \ |
| 39 | +-D INSTALL_C_EXAMPLES=OFF \ |
| 40 | +-D PYTHON_EXECUTABLE=$(which python2) \ |
| 41 | +-D PYTHON3_EXECUTABLE=$(which python3) \ |
| 42 | +-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ |
| 43 | +-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \ |
| 44 | +-D BUILD_opencv_python2=ON \ |
| 45 | +-D BUILD_opencv_python3=ON \ |
| 46 | +-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ \ |
| 47 | +-D WITH_GSTREAMER=ON \ |
| 48 | +-D WITH_CUDA=ON \ |
| 49 | +-D ENABLE_PRECOMPILED_HEADERS=OFF \ |
| 50 | +.. &&\ |
| 51 | +make -j$(nproc) &&\ |
| 52 | +make install &&\ |
| 53 | +ldconfig &&\ |
| 54 | +rm -rf /opencv |
| 55 | + |
| 56 | +WORKDIR / |
| 57 | +ENV OpenCV_DIR=/usr/share/OpenCV |
| 58 | + |
| 59 | + |
| 60 | +# PyTorch for CUDA 11.6 |
| 61 | +RUN pip3 install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116 |
| 62 | +ENV TORCH_CUDA_ARCH_LIST="3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX" |
| 63 | + |
| 64 | +# OpenPCDet |
| 65 | +RUN pip3 install numpy==1.23.0 llvmlite numba tensorboardX easydict pyyaml scikit-image tqdm SharedArray open3d mayavi av2 kornia pyquaternion |
| 66 | +RUN pip3 install spconv-cu116 |
| 67 | + |
| 68 | +RUN git clone https://github.com/open-mmlab/OpenPCDet.git |
| 69 | + |
| 70 | +WORKDIR OpenPCDet |
| 71 | + |
| 72 | +RUN python3 setup.py develop |
| 73 | + |
| 74 | +WORKDIR / |
| 75 | + |
| 76 | +ENV NVIDIA_VISIBLE_DEVICES="all" \ |
| 77 | + OpenCV_DIR=/usr/share/OpenCV \ |
| 78 | + NVIDIA_DRIVER_CAPABILITIES="video,compute,utility,graphics" \ |
| 79 | + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:/usr/local/lib \ |
| 80 | + QT_GRAPHICSSYSTEM="native" |
| 81 | + |
| 82 | +# Build instructions: docker build -f minimal.Dockerfile -t openpcdet:cuda11 . |
| 83 | +# Start instructions: xhost local:root && docker run -it --rm -e SDL_VIDEODRIVER=x11 -e DISPLAY=$DISPLAY --env='DISPLAY' --gpus all --ipc host --privileged --network host -p 8080:8081 -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v file_locations:/storage -v /weights:/weights openpcdet:cuda11 xfce4-terminal --title=openPCDet |
0 commit comments