Skip to content

Commit 975beec

Browse files
authored
Merge pull request #1876 from swahtz/feature/fvdb
fVDB code format updates
2 parents c99b17c + c9aee59 commit 975beec

File tree

193 files changed

+32114
-25949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+32114
-25949
lines changed

fvdb/Dockerfile

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,17 @@
1-
ARG CUDA_VERSION=12.1.1
2-
ARG CUDNN_VERSION=8
1+
FROM nvcr.io/nvidia/pytorch:24.04-py3
32

4-
FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VERSION}-devel-ubuntu20.04
5-
6-
ENV PATH /usr/local/cuda/bin:$PATH
7-
ENV LD_LIBRARY_PATH /usr/lib64:/usr/local/cuda/lib64:/usr/local/cuda/lib:${LD_LIBRARY_PATH}
8-
9-
# # nvidia-container-runtime
10-
ENV NVIDIA_VISIBLE_DEVICES all
11-
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,graphics
12-
13-
RUN echo "Acquire { https::Verify-Peer false }" > /etc/apt/apt.conf.d/99verify-peer.conf \
14-
&& if [ -f /etc/apt/sources.list.d/cuda.list ]; then \
15-
rm /etc/apt/sources.list.d/cuda.list; \
16-
fi \
17-
&& if [ -f /etc/apt/sources.list.d/nvidia-ml.list ]; then \
18-
rm /etc/apt/sources.list.d/nvidia-ml.list; \
19-
fi \
20-
&& apt-get update \
21-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated ca-certificates \
22-
&& rm /etc/apt/apt.conf.d/99verify-peer.conf \
23-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
24-
wget \
25-
rsync \
26-
vim \
27-
git \
28-
curl \
29-
ninja-build \
30-
cmake \
31-
build-essential \
32-
xauth \
33-
openssh-server \
34-
&& apt-get clean \
35-
&& rm -rf /var/lib/apt/lists/*
36-
37-
RUN curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
38-
bash ~/miniconda.sh -b -p /opt/conda && \
39-
rm ~/miniconda.sh
40-
41-
ENV PATH /opt/conda/bin:$PATH
42-
ENV TORCH_CUDA_ARCH_LIST "6.1;7.0;7.5;8.0;8.6+PTX"
3+
ARG MODE=production
4+
RUN echo "Building fVDB container in $MODE mode"
435

446
# used for cross-compilation in docker build
457
ENV FORCE_CUDA=1
468

479
WORKDIR /fvdb
48-
COPY env/test_environment.yml .
49-
50-
RUN /opt/conda/bin/conda env create -f test_environment.yml \
51-
&& /opt/conda/bin/conda clean -ya \
52-
&& /opt/conda/bin/conda init bash
10+
COPY . .
11+
RUN pip install --no-cache-dir -r env/build_requirements.txt
12+
13+
RUN if [ "$MODE" = "production" ]; then \
14+
MAX_JOBS=$(free -g | awk '/^Mem:/{jobs=int($4/2.5); if(jobs<1) jobs=1; print jobs}') \
15+
TORCH_CUDA_ARCH_LIST="6.1;7.0;7.5;8.0;8.6+PTX" \
16+
python setup.py install; \
17+
fi

fvdb/README.md

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,62 @@ conda activate fvdb_learn
4646

4747

4848
## Building *f*VDB from Source
49-
*f*VDB is a Python library implemented as a C++ Pytorch extension.
49+
50+
### Environment Management
51+
ƒVDB is a Python library implemented as a C++ Pytorch extension. Of course you can build ƒVDB in whatever environment suits you, but we provide two paths to constructing reliable environments for building and running ƒVDB: using [docker](#setting-up-a-docker-container) and using [conda](#setting-up-a-conda-environment).
52+
53+
`conda` tends to be more flexible since reconfiguring toolchains and modules to suit your larger project can be dynamic, but at the same time this can be a more brittle experience compared to using a virtualized `docker` container. Using `conda` is generally recommended for development and testing, while using `docker` is recommended for CI/CD and deployment.
54+
55+
#### Setting up a Docker Container
56+
57+
Running a docker container is a great way to ensure that you have a consistent environment for building and running ƒVDB.
58+
59+
Our provided [`Dockerfile`](Dockerfile) has two modes for building the image: `dev` and `production`. `production` constructs an image capable of building ƒVDB, builds and installs the ƒVDB libraries and is read for you to start running python code that uses the `fvdb` module. `dev` mode constructs an image which is ready to build ƒVDB but does not build the ƒVDB libraries.
60+
61+
Building the docker image in `production` mode is the default and is as simple as running the following command from the root of this repository:
62+
```shell
63+
# Build the docker image in production mode
64+
docker build -t fvdb/prod .
65+
```
66+
67+
Building the docker mage in `dev` mode is done by setting the `BUILD_MODE` argument to `dev`:
68+
```shell
69+
# Build the docker image in dev mode
70+
docker build --build-arg MODE=dev -t fvdb/dev .
71+
```
72+
73+
Running the docker container is done with the following command:
74+
```shell
75+
# Run an interactive bash shell (or replace with your command)
76+
docker run -it --gpus all --rm \
77+
fvdb/dev:latest \
78+
/bin/bash
79+
```
80+
81+
82+
#### Setting up a Conda Environment
83+
84+
In order to get resolved package versions in your conda environment consistent with our testing, it is necessary to configure your `.condarc` since not all package resolving behaviour can be controlled with an `environment.yml` file. We recommend using `strict` channel priority in your conda configuration. This can be done by running the following command:
85+
86+
```shell
87+
conda config --set channel_priority strict
88+
```
89+
90+
Further, it is recommend to not mix the `defaults` and `conda-forge` package channels when resolving environments. We have generally used `conda-forge` as the primary channel for our dependencies. You can remove the `defaults` channel and add `conda-forge` with the following command:
91+
92+
```shell
93+
conda config --remove channels defaults
94+
conda config --add channels conda-forge
95+
```
96+
97+
With these changes, it is recommended that your `.condarc` file looks like the following:
98+
99+
```yaml
100+
channel_priority: strict
101+
channels:
102+
- conda-forge
103+
```
104+
50105
51106
**(Optional) Install libMamba for a huge quality of life improvement when using Conda**
52107
```
@@ -55,7 +110,6 @@ conda install -n base conda-libmamba-solver
55110
conda config --set solver libmamba
56111
```
57112

58-
### Conda Environment
59113

60114
Next, create the `fvdb` conda environment by running the following command from the root of this repository, and then grabbing a ☕:
61115
```shell
@@ -106,22 +160,6 @@ sphinx-build -E -a docs/ build/sphinx
106160
open build/sphinx/index.html
107161
```
108162

109-
### Docker Image
110-
111-
To build and test *f*VDB, we have the dockerfile available:
112-
```shell
113-
# Build fvdb
114-
docker build . -t fvdb-dev
115-
# Run fvdb (or replace with your command)
116-
docker run -it --gpus all --rm \
117-
--user $(id -u):$(id -g) \
118-
--mount type=bind,source="$HOME/.ssh",target=/root/.ssh \
119-
--mount type=bind,source="$(pwd)",target=/fvdb \
120-
fvdb-dev:latest \
121-
conda run -n fvdb_test --no-capture-output python setup.py develop
122-
```
123-
124-
125163

126164

127165
## Usage Examples

fvdb/docs/conf.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,23 @@
99

1010
import os
1111
import sys
12-
sys.path.insert(0, os.path.abspath('..'))
12+
13+
sys.path.insert(0, os.path.abspath(".."))
1314

1415

1516
# -- Project information -----------------------------------------------------
1617

17-
project = 'fVDB'
18-
copyright = '2023, NVIDIA Corporation'
19-
author = 'NVIDIA Corporation'
18+
project = "fVDB"
19+
copyright = "2023, NVIDIA Corporation"
20+
author = "NVIDIA Corporation"
2021

2122

2223
# -- General configuration ---------------------------------------------------
2324

2425
# Add any Sphinx extension module names here, as strings. They can be
2526
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2627
# ones.
27-
extensions = [
28-
'sphinx.ext.autodoc',
29-
'sphinx.ext.viewcode',
30-
'sphinx.ext.napoleon',
31-
'myst_parser'
32-
]
28+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.napoleon", "myst_parser"]
3329

3430
myst_enable_extensions = [
3531
"amsmath",
@@ -49,28 +45,26 @@
4945
]
5046

5147
# Fix return-type in google-style docstrings
52-
napoleon_custom_sections = [('Returns', 'params_style')]
48+
napoleon_custom_sections = [("Returns", "params_style")]
5349

5450
# Add any paths that contain templates here, relative to this directory.
55-
templates_path = ['_templates']
51+
templates_path = ["_templates"]
5652

57-
source_suffix = ['.rst', '.md']
53+
source_suffix = [".rst", ".md"]
5854

5955
# List of patterns, relative to source directory, that match files and
6056
# directories to ignore when looking for source files.
6157
# This pattern also affects html_static_path and html_extra_path.
62-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
58+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
6359

64-
autodoc_default_options = {
65-
'undoc-members': 'forward, extra_repr'
66-
}
60+
autodoc_default_options = {"undoc-members": "forward, extra_repr"}
6761

6862
# -- Options for HTML output -------------------------------------------------
6963

7064
# The theme to use for HTML and HTML Help pages. See the documentation for
7165
# a list of builtin themes.
7266
#
73-
html_theme = 'sphinx_rtd_theme'
67+
html_theme = "sphinx_rtd_theme"
7468

7569
# Add any paths that contain custom static files (such as style sheets) here,
7670
# relative to this directory. They are copied after the builtin static files,
@@ -80,6 +74,7 @@
8074

8175
# -- Custom hooks ------------------------------------------------------------
8276

77+
8378
def process_signature(app, what, name, obj, options, signature, return_annotation):
8479
if signature is not None:
8580
signature = signature.replace("._Cpp", "")
@@ -91,5 +86,6 @@ def process_signature(app, what, name, obj, options, signature, return_annotatio
9186

9287
return signature, return_annotation
9388

89+
9490
def setup(app):
9591
app.connect("autodoc-process-signature", process_signature)

fvdb/env/build_environment.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: fvdb_build
22
channels:
3-
- nvidia/label/cuda-12.1.0
43
- pytorch
4+
- nvidia
5+
- conda-forge
56
dependencies:
67
- python=3.10
78
- pytorch::pytorch=2.2
@@ -11,14 +12,14 @@ dependencies:
1112
- ca-certificates
1213
- certifi
1314
- openssl
14-
- nvidia/label/cuda-12.1.0::cuda
15-
- nvidia/label/cuda-12.1.0::cuda-tools
16-
- nvidia/label/cuda-12.1.0::cuda-nvcc
17-
- nvidia/label/cuda-12.1.0::cuda-cccl
18-
- nvidia/label/cuda-12.1.0::cuda-libraries-static
15+
- cuda-toolkit=12.1
16+
- cuda-compiler=12.1
17+
- cuda-nvcc=12.1
18+
- cuda-cccl=12.1
19+
- cuda-libraries-static=12.1
1920
- gcc_linux-64=11
2021
- gxx_linux-64=11
21-
- setuptools
22+
- setuptools>=68.2.2
2223
- cmake
2324
- make
2425
- ninja

fvdb/env/learn_environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies:
2828
- pytest-benchmark
2929
- polyscope
3030
- numpy<2
31+
- pyrender
3132
- pip:
3233
- point-cloud-utils
3334
- linkify-it-py

fvdb/env/test_environment.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
name: fvdb_test
22
channels:
33
- pyg
4-
- nvidia/label/cuda-12.1.0
54
- pytorch
5+
- nvidia
6+
- conda-forge
67
dependencies:
78
- python=3.10
89
- pytorch::pytorch=2.2
910
- pytorch::pytorch-cuda=12.1
1011
- tensorboard
11-
- pip
12+
- pip>=23.3.1
1213
- git
1314
- gitpython
1415
- ca-certificates
1516
- certifi
1617
- openssl
17-
- nvidia/label/cuda-12.1.0::cuda
18-
- nvidia/label/cuda-12.1.0::cuda-tools
19-
- nvidia/label/cuda-12.1.0::cuda-nvcc
20-
- nvidia/label/cuda-12.1.0::cuda-cccl
21-
- nvidia/label/cuda-12.1.0::cuda-libraries-static
18+
- cuda-toolkit=12.1
19+
- cuda-compiler=12.1
20+
- cuda-nvcc=12.1
21+
- cuda-cccl=12.1
22+
- cuda-libraries-static=12.1
2223
- parameterized
2324
- gcc_linux-64=11
2425
- gxx_linux-64=11
25-
- setuptools
26+
- setuptools>=68.2.2
2627
- cmake
2728
- make
2829
- ninja

0 commit comments

Comments
 (0)