Skip to content

Commit 5fe240a

Browse files
author
Koch
committed
fix: mitigate include and library path issues under Windows in setup.py
1 parent 6733f0e commit 5fe240a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ When running in a docker container without nvidia driver, PyTorch needs to evalu
6464
export TORCH_CUDA_ARCH_LIST = "6.0 6.1 7.2+PTX 7.5+PTX"
6565
```
6666

67+
### Windows
68+
69+
If you are installing this on Windows specifically, **you will need to point the setup to your Visual Studio installation** for some neccessary libraries and header files.
70+
To do this, add the include and library paths of your installation to the path lists in setup.py as described in the respective comments in the code.
71+
6772
If you are running into any installation problems, please create an [issue](https://github.com/rusty1s/pytorch_scatter/issues).
6873
Be sure to import `torch` first before using this package to resolve symbols the dynamic linker must see.
6974

setup.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,19 @@
77
import torch
88
from torch.utils.cpp_extension import CppExtension, CUDAExtension, CUDA_HOME
99

10+
11+
# Windows users: Edit both of these to contain your Visual Studio include path, i.e.
12+
# cxx_extra_compile_args = ['-I{VISUAL_STUDIO_DIR}\\include']
13+
# nvcc_extra_compile_args = ['-arch=sm_35', '--expt-relaxed-constexpr', '-I{VISUAL_STUDIO_DIR}\\include']
1014
cxx_extra_compile_args = []
1115
nvcc_extra_compile_args = ['-arch=sm_35', '--expt-relaxed-constexpr']
16+
17+
# Windows users: Edit both of these to contain your Visual Studio library path, i.e.
18+
# cxx_extra_link_args = ['/LIBPATH:{VISUAL_STUDIO_DIR}\\lib\\{x86|x64}']
19+
# nvcc_extra_link_args = ['/LIBPATH:{VISUAL_STUDIO_DIR}\\lib\\{x86|x64}']
20+
cxx_extra_link_args = []
21+
nvcc_extra_link_args = []
22+
1223
if platform.system() != 'Windows':
1324
cxx_extra_compile_args += ['-Wno-unused-variable']
1425
TORCH_MAJOR = int(torch.__version__.split('.')[0])
@@ -23,7 +34,8 @@
2334
ext_modules += [
2435
CppExtension(
2536
f'torch_scatter.{ext}_cpu', [f'cpu/{ext}.cpp'],
26-
extra_compile_args=cxx_extra_compile_args) for ext in exts
37+
extra_compile_args=cxx_extra_compile_args,
38+
extra_link_args=cxx_extra_link_args) for ext in exts
2739
]
2840

2941
if CUDA_HOME is not None and '--cpu' not in argv:
@@ -35,7 +47,8 @@
3547
extra_compile_args={
3648
'cxx': cxx_extra_compile_args,
3749
'nvcc': nvcc_extra_compile_args,
38-
}) for ext in exts
50+
},
51+
extra_link_args=nvcc_extra_link_args) for ext in exts
3952
]
4053

4154
__version__ = '1.5.0'

0 commit comments

Comments
 (0)