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
## Installation
### Requirements:
* Cuda >= 10.1 (with nvcc compiler)
* PyTorch >= 1.8
### Installing (from source):
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
cd lietorch
conda create -n lie_env
conda activate lie_env
conda install scipy pyyaml pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
```
python3 -m venv .venv
source .venv/bin/activate
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
```
pip install opencv-python open3d
# install requirements
pip install torch torchvision torchaudio wheel
# 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)
You can install the library directly using pip
### Running Tests
After building, you can run the tests
```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:
| exp | g -> G | exponential map |
| log | G -> g | logarithm map |
| 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 |
| adjT | G x g*-> g* | dual adjoint |
| act | G x R^3 -> R^3 | action on point (set) |
......
......@@ -2,7 +2,7 @@ import torch
import numpy as np
# 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
......@@ -179,9 +179,9 @@ class LieGroup:
def matrix(self):
""" convert element to 4x4 matrix """
I = torch.eye(4, dtype=self.dtype, device=self.device)
I = I.view([1] * (len(self.data.shape) - 1) + [4, 4])
return self.__class__(self.data[...,None,:]).act(I).transpose(-1,-2)
Id = torch.eye(4, dtype=self.dtype, device=self.device)
Id = Id.view([1] * (len(self.data.shape) - 1) + [4, 4])
return self.__class__(self.data[...,None,:]).act(Id).transpose(-1,-2)
def translation(self):
""" extract translation component """
......@@ -220,12 +220,12 @@ class LieGroup:
def cuda(self):
return self.__class__(self.data.cuda())
def float(self, device):
def float(self):
return self.__class__(self.data.float())
def double(self, device):
def double(self):
return self.__class__(self.data.double())
def unbind(self, dim=0):
return [self.__class__(x) for x in self.data.unbind(dim=dim)]
......
from setuptools import setup
import os
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import os.path as osp
ROOT = osp.dirname(osp.abspath(__file__))
ROOT = os.path.dirname(os.path.abspath(__file__))
setup(
name='lietorch',
version='0.2',
description='Lie Groups for PyTorch',
author='teedrz',
packages=['lietorch'],
name="lietorch",
version="0.3",
description="Lie Groups for PyTorch",
author="Zachary Teed",
packages=["lietorch"],
ext_modules=[
CUDAExtension('lietorch_backends',
CUDAExtension("lietorch_backends",
include_dirs=[
osp.join(ROOT, 'lietorch/include'),
osp.join(ROOT, 'eigen')],
os.path.join(ROOT, "lietorch/include"),
os.path.join(ROOT, "eigen")],
sources=[
'lietorch/src/lietorch.cpp',
'lietorch/src/lietorch_gpu.cu',
'lietorch/src/lietorch_cpu.cpp'],
"lietorch/src/lietorch.cpp",
"lietorch/src/lietorch_gpu.cu",
"lietorch/src/lietorch_cpu.cpp"],
extra_compile_args={
'cxx': ['-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',
]
"cxx": ["-O2"],
"nvcc": ["-O2"],
}),
CUDAExtension('lietorch_extras',
CUDAExtension("lietorch_extras",
sources=[
'lietorch/extras/altcorr_kernel.cu',
'lietorch/extras/corr_index_kernel.cu',
'lietorch/extras/se3_builder.cu',
'lietorch/extras/se3_inplace_builder.cu',
'lietorch/extras/se3_solver.cu',
'lietorch/extras/extras.cpp',
"lietorch/extras/altcorr_kernel.cu",
"lietorch/extras/corr_index_kernel.cu",
"lietorch/extras/se3_builder.cu",
"lietorch/extras/se3_inplace_builder.cu",
"lietorch/extras/se3_solver.cu",
"lietorch/extras/extras.cpp",
],
extra_compile_args={
'cxx': ['-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',
]
"cxx": ["-O2"],
"nvcc": ["-O2"],
}),
],
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