Commit ffdcdc2c authored by Zach Teed's avatar Zach Teed
Browse files

updated build instructions

parent a4d9cfff
...@@ -23,38 +23,47 @@ Zachary Teed and Jia Deng, CVPR 2021 ...@@ -23,38 +23,47 @@ Zachary Teed and Jia Deng, CVPR 2021
## Installation ## Installation
### Requirements: ### Installing (from source):
* Cuda >= 10.1 (with nvcc compiler)
* PyTorch >= 1.8
We recommend installing within a virtual enviornment. Make sure you clone using the `--recursive` flag. If you are using Anaconda, the following command can be used to install all dependencies Requires torch >= 2 and CUDA >= 11. Tested up to torch==2.7 and CUDA 12. Make sure PyTorch and CUDA major versions match.
```
```bash
git clone --recursive https://github.com/princeton-vl/lietorch.git git clone --recursive https://github.com/princeton-vl/lietorch.git
cd lietorch cd lietorch
conda create -n lie_env python3 -m venv .venv
conda activate lie_env source .venv/bin/activate
conda install scipy pyyaml pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
```
To run the examples, you will need OpenCV and Open3D. Depending on your operating system, OpenCV and Open3D can either be installed with pip or may need to be built from source # install requirements
``` pip install torch torchvision torchaudio wheel
pip install opencv-python open3d
# optional: specify GPU architectures
# https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
export TORCH_CUDA_ARCH_LIST="7.5;8.6;8.9;9.0"
# install lietorch
pip install -e .
``` ```
### Installing (from source) ### Installing (with pip)
```bash
# optional: specify GPU architectures
export TORCH_CUDA_ARCH_LIST="7.5;8.6;8.9;9.0"
Clone the repo using the `--recursive` flag and install using `setup.py` (may take up to 10 minutes) pip install git+https://github.com/princeton-vl/lietorch.git
``` ```
git clone --recursive https://github.com/princeton-vl/lietorch.git
python setup.py install
./run_tests.sh To run the examples, you will need these additional libraries
```bash
pip install opencv-python open3d scipy pyyaml
``` ```
### Installing (pip) ### Running Tests
You can install the library directly using pip
After building, you can run the tests
```bash ```bash
pip install git+https://github.com/princeton-vl/lietorch.git ./run_tests.sh
``` ```
...@@ -77,7 +86,7 @@ Each group supports the following differentiable operations: ...@@ -77,7 +86,7 @@ Each group supports the following differentiable operations:
| exp | g -> G | exponential map | | exp | g -> G | exponential map |
| log | G -> g | logarithm map | | log | G -> g | logarithm map |
| inv | G -> G | group inverse | | inv | G -> G | group inverse |
| mul | G x G -> G | group multiplication | | mul | G x G -> G | group multiplication |
| adj | G x g -> g | adjoint | | adj | G x g -> g | adjoint |
| adjT | G x g*-> g* | dual adjoint | | adjT | G x g*-> g* | dual adjoint |
| act | G x R^3 -> R^3 | action on point (set) | | act | G x R^3 -> R^3 | action on point (set) |
......
...@@ -2,7 +2,7 @@ import torch ...@@ -2,7 +2,7 @@ import torch
import numpy as np import numpy as np
# group operations implemented in cuda # group operations implemented in cuda
from .group_ops import Exp, Log, Inv, Mul, Adj, AdjT, Jinv, Act3, Act4, ToMatrix, ToVec, FromVec from .group_ops import Exp, Log, Inv, Mul, Adj, AdjT, Jinv, Act3, Act4, ToVec, FromVec
from .broadcasting import broadcast_inputs from .broadcasting import broadcast_inputs
...@@ -179,9 +179,9 @@ class LieGroup: ...@@ -179,9 +179,9 @@ class LieGroup:
def matrix(self): def matrix(self):
""" convert element to 4x4 matrix """ """ convert element to 4x4 matrix """
I = torch.eye(4, dtype=self.dtype, device=self.device) Id = torch.eye(4, dtype=self.dtype, device=self.device)
I = I.view([1] * (len(self.data.shape) - 1) + [4, 4]) Id = Id.view([1] * (len(self.data.shape) - 1) + [4, 4])
return self.__class__(self.data[...,None,:]).act(I).transpose(-1,-2) return self.__class__(self.data[...,None,:]).act(Id).transpose(-1,-2)
def translation(self): def translation(self):
""" extract translation component """ """ extract translation component """
...@@ -220,12 +220,12 @@ class LieGroup: ...@@ -220,12 +220,12 @@ class LieGroup:
def cuda(self): def cuda(self):
return self.__class__(self.data.cuda()) return self.__class__(self.data.cuda())
def float(self, device): def float(self):
return self.__class__(self.data.float()) return self.__class__(self.data.float())
def double(self, device): def double(self):
return self.__class__(self.data.double()) return self.__class__(self.data.double())
def unbind(self, dim=0): def unbind(self, dim=0):
return [self.__class__(x) for x in self.data.unbind(dim=dim)] return [self.__class__(x) for x in self.data.unbind(dim=dim)]
......
from setuptools import setup from setuptools import setup
import os
from torch.utils.cpp_extension import BuildExtension, CUDAExtension from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import os.path as osp ROOT = os.path.dirname(os.path.abspath(__file__))
ROOT = osp.dirname(osp.abspath(__file__))
setup( setup(
name='lietorch', name="lietorch",
version='0.2', version="0.3",
description='Lie Groups for PyTorch', description="Lie Groups for PyTorch",
author='teedrz', author="Zachary Teed",
packages=['lietorch'], packages=["lietorch"],
ext_modules=[ ext_modules=[
CUDAExtension('lietorch_backends', CUDAExtension("lietorch_backends",
include_dirs=[ include_dirs=[
osp.join(ROOT, 'lietorch/include'), os.path.join(ROOT, "lietorch/include"),
osp.join(ROOT, 'eigen')], os.path.join(ROOT, "eigen")],
sources=[ sources=[
'lietorch/src/lietorch.cpp', "lietorch/src/lietorch.cpp",
'lietorch/src/lietorch_gpu.cu', "lietorch/src/lietorch_gpu.cu",
'lietorch/src/lietorch_cpu.cpp'], "lietorch/src/lietorch_cpu.cpp"],
extra_compile_args={ extra_compile_args={
'cxx': ['-O2'], "cxx": ["-O2"],
'nvcc': ['-O2', "nvcc": ["-O2"],
'-gencode=arch=compute_60,code=sm_60',
'-gencode=arch=compute_61,code=sm_61',
'-gencode=arch=compute_70,code=sm_70',
'-gencode=arch=compute_75,code=sm_75',
'-gencode=arch=compute_75,code=compute_75',
]
}), }),
CUDAExtension('lietorch_extras', CUDAExtension("lietorch_extras",
sources=[ sources=[
'lietorch/extras/altcorr_kernel.cu', "lietorch/extras/altcorr_kernel.cu",
'lietorch/extras/corr_index_kernel.cu', "lietorch/extras/corr_index_kernel.cu",
'lietorch/extras/se3_builder.cu', "lietorch/extras/se3_builder.cu",
'lietorch/extras/se3_inplace_builder.cu', "lietorch/extras/se3_inplace_builder.cu",
'lietorch/extras/se3_solver.cu', "lietorch/extras/se3_solver.cu",
'lietorch/extras/extras.cpp', "lietorch/extras/extras.cpp",
], ],
extra_compile_args={ extra_compile_args={
'cxx': ['-O2'], "cxx": ["-O2"],
'nvcc': ['-O2', "nvcc": ["-O2"],
'-gencode=arch=compute_60,code=sm_60',
'-gencode=arch=compute_61,code=sm_61',
'-gencode=arch=compute_70,code=sm_70',
'-gencode=arch=compute_75,code=sm_75',
'-gencode=arch=compute_75,code=compute_75',
]
}), }),
], ],
cmdclass={ 'build_ext': BuildExtension } cmdclass={ "build_ext": BuildExtension }
) )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment