mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
Summary: This diff updates the documentation and tutorials with information about the new pulsar backend. For more information about the pulsar backend, see the release notes and the paper (https://arxiv.org/abs/2004.07484). For information on how to use the backend, see the point cloud rendering notebook and the examples in the folder docs/examples. Reviewed By: nikhilaravi Differential Revision: D24498129 fbshipit-source-id: e312b0169a72b13590df6e4db36bfe6190d742f9
150 lines
4.9 KiB
Markdown
150 lines
4.9 KiB
Markdown
# Installation
|
||
|
||
|
||
## Requirements
|
||
|
||
### Core library
|
||
|
||
The core library is written in PyTorch. Several components have underlying implementation in CUDA for improved performance. A subset of these components have CPU implementations in C++/Pytorch. It is advised to use PyTorch3D with GPU support in order to use all the features.
|
||
|
||
- Linux or macOS or Windows
|
||
- Python 3.6, 3.7 or 3.8
|
||
- PyTorch 1.4, 1.5.0, 1.5.1 or 1.6.0
|
||
- torchvision that matches the PyTorch installation. You can install them together as explained at pytorch.org to make sure of this.
|
||
- gcc & g++ ≥ 4.9
|
||
- [fvcore](https://github.com/facebookresearch/fvcore)
|
||
- If CUDA is to be used, use at least version 9.2.
|
||
- If CUDA is to be used, the CUB library must be available. Starting from CUDA 11, CUB is part of CUDA. If you're using an earlier CUDA version and are not using conda, download the CUB library from https://github.com/NVIDIA/cub/releases and unpack it to a folder of your choice. Define the environment variable CUB_HOME before building and point it to the directory that contains `CMakeLists.txt` for CUB.
|
||
|
||
The dependencies can be installed by running:
|
||
```
|
||
conda create -n pytorch3d python=3.8
|
||
conda activate pytorch3d
|
||
conda install -c pytorch pytorch=1.6.0 torchvision cudatoolkit=10.2
|
||
conda install -c conda-forge -c fvcore fvcore
|
||
conda install -c cub
|
||
```
|
||
|
||
### Tests/Linting and Demos
|
||
|
||
For developing on top of PyTorch3D or contributing, you will need to run the linter and tests. If you want to run any of the notebook tutorials as `docs/tutorials` or the examples in `docs/examples` you will also need matplotlib and OpenCV.
|
||
- scikit-image
|
||
- black
|
||
- isort
|
||
- flake8
|
||
- matplotlib
|
||
- tdqm
|
||
- jupyter
|
||
- imageio
|
||
- plotly
|
||
- opencv-python
|
||
|
||
These can be installed by running:
|
||
```
|
||
# Demos and examples
|
||
conda install jupyter
|
||
pip install scikit-image matplotlib imageio plotly opencv-python
|
||
|
||
# Tests/Linting
|
||
pip install black 'isort<5' flake8 flake8-bugbear flake8-comprehensions
|
||
```
|
||
|
||
## Installing prebuilt binaries for PyTorch3D
|
||
After installing the above dependencies, run one of the following commands:
|
||
|
||
### 1. Install with CUDA support from Anaconda Cloud, on Linux only
|
||
|
||
```
|
||
# Anaconda Cloud
|
||
conda install pytorch3d -c pytorch3d
|
||
```
|
||
|
||
Or, to install a nightly (non-official, alpha) build:
|
||
```
|
||
# Anaconda Cloud
|
||
conda install pytorch3d -c pytorch3d-nightly
|
||
```
|
||
### 2. Install from PyPI, on Linux and Mac
|
||
This works with pytorch 1.6.0 only.
|
||
```
|
||
pip install pytorch3d
|
||
```
|
||
On Linux this has support for CUDA 10.1. On Mac this is CPU-only.
|
||
|
||
## Building / installing from source.
|
||
CUDA support will be included if CUDA is available in pytorch or if the environment variable
|
||
`FORCE_CUDA` is set to `1`.
|
||
|
||
### 1. Install from GitHub
|
||
```
|
||
pip install 'git+https://github.com/facebookresearch/pytorch3d.git'
|
||
```
|
||
To install using the code of the released version instead of from the main branch, use the following instead.
|
||
```
|
||
pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'
|
||
```
|
||
|
||
For CUDA builds with versions earlier than CUDA 11, set `CUB_HOME` before building as described above.
|
||
|
||
**Install from Github on macOS:**
|
||
Some environment variables should be provided, like this.
|
||
```
|
||
MACOSX_DEPLOYMENT_TARGET=10.14 CC=clang CXX=clang++ pip install 'git+https://github.com/facebookresearch/pytorch3d.git'
|
||
```
|
||
|
||
### 2. Install from a local clone
|
||
```
|
||
git clone https://github.com/facebookresearch/pytorch3d.git
|
||
cd pytorch3d && pip install -e .
|
||
```
|
||
To rebuild after installing from a local clone run, `rm -rf build/ **/*.so` then `pip install -e .`. You often need to rebuild pytorch3d after reinstalling PyTorch. For CUDA builds with versions earlier than CUDA 11, set `CUB_HOME` before building as described above.
|
||
|
||
**Install from local clone on macOS:**
|
||
```
|
||
MACOSX_DEPLOYMENT_TARGET=10.14 CC=clang CXX=clang++ pip install -e .
|
||
```
|
||
|
||
**Install from local clone on Windows:**
|
||
|
||
If you are using pre-compiled pytorch 1.4 and torchvision 0.5, you should make the following changes to the pytorch source code to successfully compile with Visual Studio 2019 (MSVC 19.16.27034) and CUDA 10.1.
|
||
|
||
Change python/Lib/site-packages/torch/include/csrc/jit/script/module.h
|
||
|
||
L466, 476, 493, 506, 536
|
||
```
|
||
-static constexpr *
|
||
+static const *
|
||
```
|
||
Change python/Lib/site-packages/torch/include/csrc/jit/argument_spec.h
|
||
|
||
L190
|
||
```
|
||
-static constexpr size_t DEPTH_LIMIT = 128;
|
||
+static const size_t DEPTH_LIMIT = 128;
|
||
```
|
||
|
||
Change python/Lib/site-packages/torch/include/pybind11/cast.h
|
||
|
||
L1449
|
||
```
|
||
-explicit operator type&() { return *(this->value); }
|
||
+explicit operator type& () { return *((type*)(this->value)); }
|
||
```
|
||
|
||
After patching, you can go to "x64 Native Tools Command Prompt for VS 2019" to compile and install
|
||
```
|
||
cd pytorch3d
|
||
python3 setup.py install
|
||
```
|
||
After installing, verify whether all unit tests have passed
|
||
```
|
||
cd tests
|
||
python3 -m unittest discover -p *.py
|
||
```
|
||
|
||
# FAQ
|
||
|
||
### Can I use Docker?
|
||
|
||
We don't provide a docker file but see [#113](https://github.com/facebookresearch/pytorch3d/issues/113) for a docker file shared by a user (NOTE: this has not been tested by the PyTorch3D team).
|