Skip to content

Commit 44ff79d

Browse files
peterjc123facebook-github-bot
authored andcommitted
Automatically set BUILD_SPLIT_CUDA for cpp exts (pytorch#52503)
Summary: Fixes pytorch/vision#3418 (comment) Pull Request resolved: pytorch#52503 Reviewed By: malfet Differential Revision: D26546857 Pulled By: janeyx99 fbshipit-source-id: a100b408e7cd28695145a1dda7f2fa081bb7f21f
1 parent b6ed051 commit 44ff79d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

torch/utils/cpp_extension.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,21 @@
2222
from setuptools.command.build_ext import build_ext
2323
from pkg_resources import packaging # type: ignore
2424

25-
BUILD_SPLIT_CUDA = os.getenv('BUILD_SPLIT_CUDA')
2625
IS_WINDOWS = sys.platform == 'win32'
2726
LIB_EXT = '.pyd' if IS_WINDOWS else '.so'
2827
EXEC_EXT = '.exe' if IS_WINDOWS else ''
28+
CLIB_PREFIX = '' if IS_WINDOWS else 'lib'
29+
CLIB_EXT = '.dll' if IS_WINDOWS else '.so'
2930
SHARED_FLAG = '/DLL' if IS_WINDOWS else '-shared'
3031

3132
_HERE = os.path.abspath(__file__)
3233
_TORCH_PATH = os.path.dirname(os.path.dirname(_HERE))
3334
TORCH_LIB_PATH = os.path.join(_TORCH_PATH, 'lib')
3435

36+
37+
BUILD_SPLIT_CUDA = os.getenv('BUILD_SPLIT_CUDA') or (os.path.exists(os.path.join(
38+
TORCH_LIB_PATH, f'{CLIB_PREFIX}torch_cuda_cu{CLIB_EXT}')) and os.path.exists(os.path.join(TORCH_LIB_PATH, f'{CLIB_PREFIX}torch_cuda_cpp{CLIB_EXT}')))
39+
3540
# Taken directly from python stdlib < 3.9
3641
# See https://github.com/pytorch/pytorch/issues/48617
3742
def _nt_quote_args(args: Optional[List[str]]) -> List[str]:

0 commit comments

Comments
 (0)