-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
485 changed files
with
243 additions
and
143,884 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
export ROOT_PATH=$1 | ||
mkdir -p $ROOT_PATH/ceres | ||
cd $ROOT_PATH/ceres | ||
wget http:https://ceres-solver.org/ceres-solver-1.14.0.tar.gz | ||
tar xvzf ceres-solver-1.14.0.tar.gz | ||
cd ceres-solver-1.14.0 | ||
sed -i 's/\(^option(BUILD_SHARED_LIBS.*\)OFF/\1ON/' CMakeLists.txt | ||
rm -rf build | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make -j8 | ||
sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
FROM nvidia/cuda:10.2-devel-ubuntu16.04 | ||
# NOTE: build this image from dir above Dockerfile location | ||
# USE BASH | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
## modify below | ||
ARG username=pvnet | ||
ARG groupid=1000 | ||
ARG userid=1000 | ||
## end modify | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
cmake \ | ||
git \ | ||
curl \ | ||
wget \ | ||
vim \ | ||
ca-certificates \ | ||
python-qt4 \ | ||
libjpeg-dev \ | ||
zip \ | ||
unzip \ | ||
sudo \ | ||
libpng-dev \ | ||
libeigen3-dev \ | ||
libgoogle-glog-dev=0.3.4-0.1 \ | ||
libsuitesparse-dev=1:4.4.6-1 \ | ||
libatlas-base-dev=3.10.2-9 &&\ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64 | ||
ENV PYTHON_VERSION=3.6.7 | ||
|
||
RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ | ||
chmod +x ~/miniconda.sh && \ | ||
~/miniconda.sh -b -p /opt/conda && \ | ||
rm ~/miniconda.sh && \ | ||
/opt/conda/bin/conda install conda-build | ||
|
||
ENV PATH=$PATH:/opt/conda/bin/ | ||
|
||
RUN adduser --disabled-password --gecos '' $username \ | ||
&& adduser $username sudo \ | ||
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
USER $username | ||
|
||
# clone the repo and build ceres from source | ||
RUN cd /home/$username \ | ||
&& git clone https://github.com/jwdinius/pvnet.git \ | ||
&& cd pvnet \ | ||
&& chmod a+rwx build_ceres_for_docker.sh \ | ||
&& ./build_ceres_for_docker.sh /home/$username | ||
|
||
# Create Enviroment | ||
RUN cd /home/$username/pvnet \ | ||
&& conda env create -f environment.yml | ||
|
||
# follow remainder of steps in README | ||
RUN source activate pvnet \ | ||
&& cd /home/$username/pvnet/lib/ransac_voting_gpu_layer \ | ||
&& python setup.py build_ext --inplace | ||
RUN source activate pvnet \ | ||
&& cd /home/$username/pvnet/lib/utils/extend_utils \ | ||
&& python build_extend_utils_cffi_for_docker.py | ||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/$username/pvnet/lib/utils/extend_utils/lib | ||
|
||
WORKDIR /home/$username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"runtimes": { | ||
"nvidia": { | ||
"path": "nvidia-container-runtime", | ||
"runtimeArgs": [] | ||
} | ||
}, | ||
"default-runtime": "nvidia", | ||
"bridge": "none", | ||
"storage-driver": "devicemapper", | ||
"storage-opts": [ | ||
"dm.basesize=20G" | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
## How to run `tools/demo.py` from docker | ||
|
||
_Steps verified on Ubuntu 18.04, Cuda 10.2 with a GTX1080 Ti card, and docker 19.03.2 installed on the host machine_ | ||
|
||
### Install docker | ||
|
||
[From the docker site](https://docs.docker.com/install/linux/docker-ce/ubuntu/) | ||
|
||
### Install nvidia-docker2 | ||
|
||
[Good How-To on medium](https://medium.com/@sh.tsang/docker-tutorial-5-nvidia-docker-2-0-installation-in-ubuntu-18-04-cb80f17cac65) | ||
|
||
### Expand image size and set default runtime | ||
|
||
The docker image created by `Dockerfile` is quite large, ~10GB, which means you may need to up the max image size allowed for docker. Check [this link](https://guide.blazemeter.com/hc/en-us/articles/115003812129-Overcoming-Container-Storage-Limitation-Overcoming-Container-Storage-Limitation) for more info. I have tried to streamline the insights from the article and to give the user what they need from it. | ||
|
||
Copy [daemon.json](./daemon.json) to your `/etc/docker/daemon.json`. Stop/start docker: | ||
|
||
``` | ||
sudo systemctl stop docker | ||
# sudo rm -rf /var/lib/docker/* ## IF YOU HAVE IMAGES, SAVE THEM IN A TARBALL ARCHIVE AND RESTORE AFTER DOING THIS | ||
sudo systemctl start docker | ||
``` | ||
|
||
_Note: you may or may not need to do the middle step. If you have previously-built images, you will need to remove them before restarting docker for the updated max image size to take effect._ | ||
|
||
You can run `docker info` to verify the desired change took place: Look for the line in the output: | ||
|
||
``` | ||
... | ||
Storage Driver: devicemapper | ||
... some lines here ... | ||
Base Device Size: 21.47GB | ||
... more lines follow ... | ||
``` | ||
|
||
### Build the `pvnet` image | ||
|
||
``` | ||
$ cd {path-to-pvnet}/docker | ||
$ docker build --network=host -t pvnet-nvidia . | ||
``` | ||
|
||
This will take awhile... | ||
|
||
### Run the demo | ||
|
||
#### Download the pre-trained model | ||
|
||
Follow the steps from the [README](../README.md). Note that the [`launch-docker.sh`](./launch-docker.sh) script handles mounting the pre-trained model's location on the host _inside_ of the running container instance that the script launches. | ||
|
||
#### Launch the container | ||
|
||
``` | ||
$[host] cd {path-to-pvnet} | ||
$[host] ./docker/launch-docker.sh | ||
$[container] source activate pvnet | ||
$[container] cd /home/pvnet/pvnet | ||
$[container] python tools/demo.py | ||
``` | ||
|
||
You should see the desired figure pop-up: | ||
|
||
<p align="center"> | ||
<img src="./demo_success.png"> | ||
</p> | ||
|
||
And that's it! Once you exit the container, it will automatically be deleted and it's resources released. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# NOTE: run this from pvnet root | ||
docker run -it --rm \ | ||
-v $(pwd)/data:/home/pvnet/pvnet/data \ | ||
-v /tmp/.X11-unix:/tmp/.X11-unix \ | ||
-e DISPLAY=$DISPLAY \ | ||
--name pvnet-nvidia-c \ | ||
--net host \ | ||
--privileged \ | ||
--runtime=nvidia \ | ||
pvnet-nvidia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: pvnet | ||
channels: | ||
- conda-forge | ||
- pytorch | ||
- fastai | ||
dependencies: | ||
- python==3.6.7 | ||
- pytorch==1.1.0 | ||
- torchvision | ||
- fastprogress | ||
- fastai | ||
- jupyter | ||
- scipy==1.2.1 | ||
- matplotlib==3.0.2 | ||
- transforms3d==0.3.1 | ||
- setuptools==39.1.0 | ||
- cffi==1.11.5 | ||
- numpy==1.14.3 | ||
- cython==0.29.14 | ||
- tensorboardx | ||
- pip | ||
- pip: | ||
- plyfile==0.6 | ||
- opencv_contrib_python==3.4.2.16 | ||
- lmdb==0.94 | ||
- glumpy==1.0.6 | ||
- scikit_image==0.13.1 | ||
- easydict==1.7 |
41 changes: 41 additions & 0 deletions
41
lib/utils/extend_utils/build_extend_utils_cffi_for_docker.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
|
||
ceres_include='/usr/local/include' # contains Ceres/ceres.h | ||
ceres_library='/usr/local/lib/libceres.so' | ||
eigen_include='/usr/include/eigen3' # contains Eigen/Core | ||
glog_library='/usr/lib/x86_64-linux-gnu/libglog.so' | ||
cuda_include='/usr/local/cuda-10.2/include' | ||
cudart = '/usr/local/cuda-10.2/lib64/libcudart.so' | ||
|
||
os.system('gcc -shared src/mesh_rasterization.cpp -c -o src/mesh_rasterization.cpp.o -fopenmp -fPIC -O2 -std=c++11') | ||
os.system('gcc -shared src/farthest_point_sampling.cpp -c -o src/farthest_point_sampling.cpp.o -fopenmp -fPIC -O2 -std=c++11') | ||
os.system('gcc -shared src/uncertainty_pnp.cpp -c -o src/uncertainty_pnp.cpp.o -fopenmp -fPIC -O2 -std=c++11 -I {} -I {}'. | ||
format(ceres_include,eigen_include)) | ||
os.system('nvcc src/nearest_neighborhood.cu -c -o src/nearest_neighborhood.cu.o -x cu -Xcompiler -fPIC -O2 -arch=sm_52 -I {} -D_FORCE_INLINES'. | ||
format(cuda_include)) | ||
|
||
from cffi import FFI | ||
ffibuilder = FFI() | ||
|
||
|
||
# cdef() expects a string listing the C types, functions and | ||
# globals needed from Python. The string follows the C syntax. | ||
with open(os.path.join(os.path.dirname(__file__), "src/utils_python_binding.h")) as f: | ||
ffibuilder.cdef(f.read()) | ||
|
||
ffibuilder.set_source("_extend_utils", | ||
""" | ||
#include "src/utils_python_binding.h" // the C header of the library | ||
""", | ||
extra_objects=['src/mesh_rasterization.cpp.o','src/farthest_point_sampling.cpp.o', | ||
'src/uncertainty_pnp.cpp.o','src/nearest_neighborhood.cu.o', | ||
# 'src/post_process.cpp.o', | ||
ceres_library, glog_library, | ||
cudart], | ||
libraries=['stdc++'] | ||
) | ||
|
||
if __name__ == "__main__": | ||
ffibuilder.compile(verbose=True) | ||
os.system("rm src/*.o") | ||
os.system("rm *.o") |
Oops, something went wrong.