pytorch / extension-cpp

C++ extensions in PyTorch
1.02k stars 214 forks source link

Compiler error /cuda/setup.py in MacOS #30

Closed oiwio closed 5 years ago

oiwio commented 5 years ago

Hello, I want to use PyTorch Geometric but "pip install --upgrade torch-scatter" failed, then I want to try to build extension-cpp, but still failed, the following is the information of my system and log

System

Log

running install running bdist_egg running egg_info creating lltm_cuda.egg-info writing lltm_cuda.egg-info/PKG-INFO writing dependency_links to lltm_cuda.egg-info/dependency_links.txt writing top-level names to lltm_cuda.egg-info/top_level.txt writing manifest file 'lltm_cuda.egg-info/SOURCES.txt' reading manifest file 'lltm_cuda.egg-info/SOURCES.txt' writing manifest file 'lltm_cuda.egg-info/SOURCES.txt' installing library code to build/bdist.macosx-10.7-x86_64/egg running install_lib running build_ext building 'lltm_cuda' extension creating build creating build/temp.macosx-10.7-x86_64-3.6 gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kiwee/anaconda3/include -arch x86_64 -I/Users/kiwee/anaconda3/include -arch x86_64 -I/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include -I/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/TH -I/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/Users/kiwee/anaconda3/include/python3.6m -c lltm_cuda.cpp -o build/temp.macosx-10.7-x86_64-3.6/lltm_cuda.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=lltm_cuda -std=c++11 In file included from lltm_cuda.cpp:1: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/ATen/ATen.h:3: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Allocator.h:6: In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Device.h:3: /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/DeviceType.h:48:20: error: explicit specialization of non-template struct 'hash' template <> struct hash { ^ ~~~~~ /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/DeviceType.h:50:21: error: expected '(' for function-style cast or type construction return std::hash()(static_cast(k));


/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/DeviceType.h:50:25: error: expected '(' for
      function-style cast or type construction
    return std::hash<int>()(static_cast<int>(k));
                     ~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/DeviceType.h:50:27: error: expected expression
    return std::hash<int>()(static_cast<int>(k));
                          ^
In file included from lltm_cuda.cpp:1:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/ATen/ATen.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Allocator.h:6:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Device.h:5:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/Exception.h:5:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/StringUtil.h:5:
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/string_utils.h:52:12: error: no member named 'stod' in
      namespace 'std'
using std::stod;
      ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/string_utils.h:53:12: error: no member named 'stoi' in
      namespace 'std'; did you mean 'atoi'?
using std::stoi;
      ~~~~~^~~~
           atoi
/usr/include/c++/4.2.1/cstdlib:113:11: note: 'atoi' declared here
  using ::atoi;
          ^
In file included from lltm_cuda.cpp:1:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/ATen/ATen.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Allocator.h:6:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Device.h:5:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/Exception.h:5:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/StringUtil.h:5:
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/string_utils.h:54:12: error: no member named 'stoull'
      in namespace 'std'
using std::stoull;
      ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/string_utils.h:55:12: error: no member named
      'to_string' in namespace 'std'
using std::to_string;
      ~~~~~^
In file included from lltm_cuda.cpp:1:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/ATen/ATen.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Allocator.h:6:
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Device.h:103:8: error: explicit specialization of
      non-template struct 'hash'
struct hash<c10::Device> {
       ^   ~~~~~~~~~~~~~
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Device.h:103:8: error: redefinition of 'hash'
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/DeviceType.h:48:20: note: previous definition is here
template <> struct hash<c10::DeviceType> {
                   ^
In file included from lltm_cuda.cpp:1:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/ATen/ATen.h:3:
In file included from /Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/core/Allocator.h:7:
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:42:8: error: no template named
      'unique_ptr' in namespace 'std'
  std::unique_ptr<void, DeleterFnPtr> ctx_;
  ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:66:8: error: no template named
      'unique_ptr' in namespace 'std'
  std::unique_ptr<void, DeleterFnPtr>&& move_context() {
  ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:67:17: error: no member named 'move'
      in namespace 'std'
    return std::move(ctx_);
           ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:71:17: error: no member named
      'unique_ptr' in namespace 'std'
    ctx_ = std::unique_ptr<void, DeleterFnPtr>(ctx_.release(), new_deleter);
           ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:71:32: error: expected '(' for
      function-style cast or type construction
    ctx_ = std::unique_ptr<void, DeleterFnPtr>(ctx_.release(), new_deleter);
                           ~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:107:54: error: no type named
      'nullptr_t' in namespace 'std'
inline bool operator==(const UniqueVoidPtr& sp, std::nullptr_t) noexcept {
                                                ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:110:29: error: no type named
      'nullptr_t' in namespace 'std'
inline bool operator==(std::nullptr_t, const UniqueVoidPtr& sp) noexcept {
                       ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:113:54: error: no type named
      'nullptr_t' in namespace 'std'
inline bool operator!=(const UniqueVoidPtr& sp, std::nullptr_t) noexcept {
                                                ~~~~~^
/Users/kiwee/anaconda3/lib/python3.6/site-packages/torch/include/c10/util/UniqueVoidPtr.h:116:29: error: no type named
      'nullptr_t' in namespace 'std'
inline bool operator!=(std::nullptr_t, const UniqueVoidPtr& sp) noexcept {
                       ~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command 'gcc' failed with exit status 1
soumith commented 5 years ago

before you build the extension, run export MACOSX_DEPLOYMENT_TARGET=10.11. Then go ahead and build the extension.

This is a weird thing you have to do specially for Anaconda python on OSX

mohithraj commented 5 years ago

@soumith Thanks, I was able to compile after setting export MACOSX_DEPLOYMENT_TARGET=10.11