Pytorch_geometric: Windows

Created on 10 Oct 2019  Â·  1Comment  Â·  Source: rusty1s/pytorch_geometric

📚 Installation

Already refer to three posts at https://github.com/rusty1s/pytorch_geometric/issues/633,
https://github.com/rusty1s/pytorch_geometric/issues/599, and https://github.com/rusty1s/pytorch_geometric/issues/157, but none of the solutions work.

I Install Microsoft Visual Studio 2017 with Visual C++ Build Tools core features, Visual C++ 2017 Redistributable Update, VC++ 2017 version 15.9 v14.16 latest v141 tools, Windows 10 SDK (10.0.17763.0), Visual C++ tools for CMake, C++/CLI support, VC++ 2015.3 v14.00 (v140) toolset for desktop, LLVM Compiler Toolchain, Testing tools core features - Build Tools. I also install Visual Studio Build Tools 2017 and Windows Software Development Kit - Windows 10.0.26624.
Also, I also add paths based on readme

However, it seems still having compile issues.

Environment

  • OS: Windows 10
  • Python version: 3.7.4
  • PyTorch version: 1.2.0
  • CUDA/cuDNN version: 10.0
  • GCC version: 5.1.0
  • How did you try to install PyTorch Geometric and its extensions (pip, source):
    (1) pip install --verbose --no-cache-dir torch-scatter
    (2) python setup.py build --compiler=mingw32 and python setup.py install

  • Any other relevant information:

Checklist

  • [ Y] I followed the installation guide.
  • [ Y] I cannot find my error message in the FAQ.
  • [Y ] I set up CUDA correctly and can compile CUDA code via nvcc.
  • [ Y] I have cloned the repository and tried a manual installation from source.
  • [ only CUDA 10.0] I do have multiple CUDA versions on my machine.
  • [] I checked if the official extension example runs on my machine.
  • [] The offical extension example runs on my machine.

Additional context

Failed to build torch-scatter
Installing collected packages: torch-scatter
Running setup.py install for torch-scatter ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\yliau\AppData\Local\Temp\pip-install-mmj7cpph\torch-scatter\setup.py'"'"'; __file__='"'"'C:\Users\yliau\AppData\Local\Temp\pip-install-mmj7cpph\torch-scatter\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\yliau\AppData\Local\Temp\pip-record-4yly6glz\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\yliau\AppData\Local\Temp\pip-install-mmj7cpph\torch-scatter\
Complete output (1436 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\test
copying test\test_backward.py -> build\lib.win-amd64-3.7\test
copying test\test_forward.py -> build\lib.win-amd64-3.7\test
copying test\test_max_min.py -> build\lib.win-amd64-3.7\test
copying test\test_multi_gpu.py -> build\lib.win-amd64-3.7\test
copying test\test_std.py -> build\lib.win-amd64-3.7\test
copying test\utils.py -> build\lib.win-amd64-3.7\test
copying test__init__.py -> build\lib.win-amd64-3.7\test
creating build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter\add.py -> build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter\div.py -> build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter\max.py -> build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter\mean.py -> build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter\min.py -> build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter\mul.py -> build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter\std.py -> build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter\sub.py -> build\lib.win-amd64-3.7\torch_scatter
copying torch_scatter__init__.py -> build\lib.win-amd64-3.7\torch_scatter
creating build\lib.win-amd64-3.7\torch_scatter\utils
copying torch_scatter\utils\ext.py -> build\lib.win-amd64-3.7\torch_scatter\utils
copying torch_scatter\utils\gen.py -> build\lib.win-amd64-3.7\torch_scatter\utils
copying torch_scatter\utils__init__.py -> build\lib.win-amd64-3.7\torch_scatter\utils
running build_ext
C:\Anaconda3\lib\site-packages\torch\utils\cpp_extension.py:189: UserWarning: Error checking compiler version for g++: Command 'g++' returned non-zero exit status 1.
warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))

Most helpful comment

It seems that the problem is solved, referring to
https://github.com/rusty1s/pytorch_geometric/issues/667

  1. Make sure to add a path to environment variable for cl.exe. Mine is located at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
  2. copy the sources
    git clone https://github.com/rusty1s/pytorch_scatter.git
    git clone https://github.com/rusty1s/pytorch_cluster.git
    git clone https://github.com/rusty1s/pytorch_sparse.git
    git clone https://github.com/rusty1s/pytorch_spline_conv.git

  3. cd /d your directory
    python setup.py build --compiler=msvc
    python setup.py install

It works for the sample code:

import torch
from torch.nn import Sequential as Seq, Linear as Lin, ReLU
from torch_geometric.nn import MessagePassing

class EdgeConv(MessagePassing):
def __init__(self, F_in, F_out):
    super(EdgeConv, self).__init__(aggr='max')  # "Max" aggregation.
    self.mlp = Seq(Lin(2 * F_in, F_out), ReLU(), Lin(F_out, F_out))

def forward(self, x, edge_index):
    # x has shape [N, F_in]
    # edge_index has shape [2, E]
    return self.propagate(edge_index, x=x)  # shape [N, F_out]

def message(self, x_i, x_j):
    # x_i has shape [E, F_in]
    # x_j has shape [E, F_in]
    edge_features = torch.cat([x_i, x_j - x_i], dim=1)  # shape [E, 2 * F_in]
    return self.mlp(edge_features)  # shape [E, F_out]

>All comments

It seems that the problem is solved, referring to
https://github.com/rusty1s/pytorch_geometric/issues/667

  1. Make sure to add a path to environment variable for cl.exe. Mine is located at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
  2. copy the sources
    git clone https://github.com/rusty1s/pytorch_scatter.git
    git clone https://github.com/rusty1s/pytorch_cluster.git
    git clone https://github.com/rusty1s/pytorch_sparse.git
    git clone https://github.com/rusty1s/pytorch_spline_conv.git

  3. cd /d your directory
    python setup.py build --compiler=msvc
    python setup.py install

It works for the sample code:

import torch
from torch.nn import Sequential as Seq, Linear as Lin, ReLU
from torch_geometric.nn import MessagePassing

class EdgeConv(MessagePassing):
def __init__(self, F_in, F_out):
    super(EdgeConv, self).__init__(aggr='max')  # "Max" aggregation.
    self.mlp = Seq(Lin(2 * F_in, F_out), ReLU(), Lin(F_out, F_out))

def forward(self, x, edge_index):
    # x has shape [N, F_in]
    # edge_index has shape [2, E]
    return self.propagate(edge_index, x=x)  # shape [N, F_out]

def message(self, x_i, x_j):
    # x_i has shape [E, F_in]
    # x_j has shape [E, F_in]
    edge_features = torch.cat([x_i, x_j - x_i], dim=1)  # shape [E, 2 * F_in]
    return self.mlp(edge_features)  # shape [E, F_out]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

WMF1997 picture WMF1997  Â·  4Comments

WeiyiLee6666 picture WeiyiLee6666  Â·  4Comments

liaopeiyuan picture liaopeiyuan  Â·  3Comments

zc-alexfan picture zc-alexfan  Â·  3Comments

FerranAlet picture FerranAlet  Â·  4Comments