mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Lazily load libcuda libnvrtc from c++ (#17317)
Summary: Fixes https://github.com/pytorch/pytorch/issues/16860 Pull Request resolved: https://github.com/pytorch/pytorch/pull/17317 Differential Revision: D14157877 Pulled By: zdevito fbshipit-source-id: c37aec2d77c2e637d4fc6ceffe2bd32901c70317
This commit is contained in:
committed by
Facebook Github Bot
parent
81b43202ae
commit
356a94b64e
25
setup.py
25
setup.py
@ -638,31 +638,6 @@ if not IS_WINDOWS:
|
||||
)
|
||||
extensions.append(DL)
|
||||
|
||||
|
||||
if USE_CUDA:
|
||||
thnvrtc_link_flags = extra_link_args + [make_relative_rpath('lib')]
|
||||
if IS_LINUX:
|
||||
thnvrtc_link_flags = thnvrtc_link_flags + ['-Wl,--no-as-needed']
|
||||
# these have to be specified as -lcuda in link_flags because they
|
||||
# have to come right after the `no-as-needed` option
|
||||
if IS_WINDOWS:
|
||||
thnvrtc_link_flags += ['cuda.lib', 'nvrtc.lib']
|
||||
else:
|
||||
thnvrtc_link_flags += ['-lcuda', '-lnvrtc']
|
||||
cuda_stub_path = [cuda_lib_path + '/stubs']
|
||||
if IS_DARWIN:
|
||||
# on macOS this is where the CUDA stub is installed according to the manual
|
||||
cuda_stub_path = ["/usr/local/cuda/lib"]
|
||||
THNVRTC = Extension("torch._nvrtc",
|
||||
sources=['torch/csrc/nvrtc.cpp'],
|
||||
language='c++',
|
||||
extra_compile_args=main_compile_args + extra_compile_args,
|
||||
include_dirs=[cwd],
|
||||
library_dirs=library_dirs + cuda_stub_path,
|
||||
extra_link_args=thnvrtc_link_flags,
|
||||
)
|
||||
extensions.append(THNVRTC)
|
||||
|
||||
# These extensions are built by cmake and copied manually in build_extensions()
|
||||
# inside the build_ext implementaiton
|
||||
extensions.append(
|
||||
|
Reference in New Issue
Block a user