Skip to content

Commit

Permalink
[Feature] Install mmhuman3d without torch (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
yl-1993 authored Sep 14, 2022
1 parent fe9cc4c commit 24dba46
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from setuptools import find_packages, setup

import torch
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
try:
import torch
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
cmd_class = {'build_ext': BuildExtension}
except ModuleNotFoundError:
cmd_class = {}
print('Skip building ext ops due to the absence of torch.')


def readme():
Expand All @@ -19,14 +24,17 @@ def get_version():

def get_extensions():
extensions = []
if torch.cuda.is_available():
ext_ops = CUDAExtension(
'mmhuman3d.core.renderer.mpr_renderer.cuda.rasterizer', # noqa: E501
[
'mmhuman3d/core/renderer/mpr_renderer/cuda/rasterizer.cpp', # noqa: E501
'mmhuman3d/core/renderer/mpr_renderer/cuda/rasterizer_kernel.cu', # noqa: E501
])
extensions.append(ext_ops)
try:
if torch.cuda.is_available():
ext_ops = CUDAExtension(
'mmhuman3d.core.renderer.mpr_renderer.cuda.rasterizer', # noqa: E501
[
'mmhuman3d/core/renderer/mpr_renderer/cuda/rasterizer.cpp', # noqa: E501
'mmhuman3d/core/renderer/mpr_renderer/cuda/rasterizer_kernel.cu', # noqa: E501
])
extensions.append(ext_ops)
except Exception as e:
print(f'Skip building ext ops: {e}')
return extensions


Expand Down Expand Up @@ -109,7 +117,7 @@ def gen_packages_items():
setup(
name='mmhuman3d',
version=get_version(),
description='OpenMMLab 3D Human Toolbox and Benchmark',
description='OpenMMLab 3D Human Parametric Model Toolbox and Benchmark',
long_description=readme(),
long_description_content_type='text/markdown',
author='OpenMMLab',
Expand All @@ -118,7 +126,7 @@ def gen_packages_items():
url='https://github.com/open-mmlab/mmhuman3d',
packages=find_packages(exclude=('configs', 'tools', 'demo')),
ext_modules=get_extensions(),
cmdclass={'build_ext': BuildExtension},
cmdclass=cmd_class,
include_package_data=True,
classifiers=[
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit 24dba46

Please sign in to comment.