Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: attribute namespace "clang" is unrecognized; High Sierra / Fedora compilation with clang results in spurious clang errors in nvcc #13118

Open
meganset opened this issue Oct 25, 2018 · 18 comments
Assignees
Labels
module: build warnings Related to warnings during build process module: build Build system issues module: cuda Related to torch.cuda, and CUDA support in general triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@meganset
Copy link
Contributor

🚀 Feature

Building for mac os generates a lot of new warnings related to C10_NODISCARD macro
(part of the change to make TensorOptions immutable #12630 )

e.g.
pytorch/aten/src/ATen/core/TensorOptions.h(120): warning: attribute namespace "clang" is unrecognized
pytorch/aten/src/ATen/core/TensorOptions.h(129): warning: attribute namespace "clang" is unrecognized
..
pytorch/aten/src/ATen/core/TensorOptions.h(173): warning: attribute namespace "clang" is unrecognized

is there a way to turn these off or fix some error i'm making in setup
thanks

@ezyang ezyang self-assigned this Oct 25, 2018
@zou3519 zou3519 added the module: build Build system issues label Oct 29, 2018
@TheBookKnight
Copy link

Any answers to this?

@ezyang
Copy link
Contributor

ezyang commented Mar 21, 2019

@meganset @RedChallenger4 could you share what version of clang you are using which results in these warnings?

@ezyang
Copy link
Contributor

ezyang commented Mar 21, 2019

cc @carlosgmartin @Jens1503 @waitwaitforget @RedChallenger4 @edwardchor @jordangarside @kumekay @teopb @marpaia @jun-yoon I'm having trouble reproducing this, and it is hard for me to understand how the current macro setup could be not working as we explicitly test (in the macro definition) whether or not the clang-namespaced attribute works or not. More info about the Clang version involved would help quite a bit.

@meganset
Copy link
Contributor Author

Thanks for looking into this.
I haven't built pytorch for a month or so, but the last time on a couple of macs the clang versions
looked like:

clang --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

clang --version
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

To build on w'CUDA & CUDNN I needed to set CUDNN_LIB_DIR/INCLUDE_DIR,
but otherwise used the recommended command:
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

@meganset
Copy link
Contributor Author

Just tried a build now -- CPU only, on the clang version 6.0.1 machine -- and i'm not seeing all the
warning: attribute namespace "clang" is unrecognized
messages

@ezyang
Copy link
Contributor

ezyang commented Mar 21, 2019

@meganset Thanks for attempting. I haven't tried 9.1.0, maybe I can scrounge up a copy somewhere.

@DrClick
Copy link

DrClick commented Mar 23, 2019

I am currently getting this warning with clang 10.0.0 on osx 10.13.6

@meganset
Copy link
Contributor Author

Yes, just rebuilt with clang 9.1.0 and still receive the
warning: attribute namespace "clang" is unrecognized
when headers with C10_NODISCARD macro are included.

@budhiee
Copy link

budhiee commented Mar 24, 2019

I have tried it on clang 8.0.0, clang 9.0.0 and clang 10.0.0 on osx 10.13.6 high sierra and all got this warning : attribute namespace "clang" is unrecognized

@ezyang ezyang added high priority small We think this is a small issue to fix. Consider knocking off high priority small issues needs reproduction Someone else needs to try reproducing the issue given the instructions. No action needed from user triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: build warnings Related to warnings during build process labels Apr 4, 2019
@ezyang
Copy link
Contributor

ezyang commented Apr 5, 2019

It sounds like this is a High Sierra specific issue. I don't have one box handy but I should get one in a few weeks.

@mfuntowicz
Copy link
Contributor

mfuntowicz commented Apr 10, 2019

For information, I'm also seeing the same warning hundreds of lines when compiling PyTorch with clang on Fedora:

/data/Workspace/pytorch/c10/core/TensorOptions.h(202): warning: attribute namespace "clang" is unrecognized

/data/Workspace/pytorch/c10/core/TensorOptions.h(217): warning: attribute namespace "clang" is unrecognized

/data/Workspace/pytorch/c10/core/TensorOptions.h(224): warning: attribute namespace "clang" is unrecognized

/data/Workspace/pytorch/c10/core/TensorOptions.h(231): warning: attribute namespace "clang" is unrecognized

/data/Workspace/pytorch/c10/core/TensorOptions.h(239): warning: attribute namespace "clang" is unrecognized

/data/Workspace/pytorch/c10/util/UniqueVoidPtr.h(69): warning: attribute namespace "clang" is unrecognized

/data/Workspace/pytorch/c10/core/Allocator.h(96): warning: attribute namespace "clang" is unrecognized

I'm using clang 7.0.1 along with CUDA 10.1 and CuDNN 7.5.0

clang version 7.0.1 (Fedora 7.0.1-6.fc29)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

@junjiez
Copy link

junjiez commented Apr 28, 2019

I am seeing the same warnings on a High Sierra box.

I'm using clang 10.0.0 along with CUDA 10.1 and cuDNN 7.5.1

Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@junjiez
Copy link

junjiez commented Apr 28, 2019

I am seeing the same warnings on a High Sierra box.

I'm using clang 10.0.0 along with CUDA 10.1 and cuDNN 7.5.1

Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Interesting, when I changed the "MACOSX_DEPLOYMENT_TARGET" setting to "10.13" in the command and reinstall, that warnings didn't appear at the beginning of the compile, but came out again when progress approached about 70%. Here is the command:

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
MACOSX_DEPLOYMENT_TARGET=10.13 CC=clang CXX=clang++ python setup.py install

I found on both the official guideline and the github page, it writes MACOSX_DEPLOYMENT_TARGET as fixed as 10.9: MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

Not sure how the setting of "MACOSX_DEPLOYMENT_TARGET" places a difference in the compiling. Any insights?

@ezyang
Copy link
Contributor

ezyang commented May 8, 2019

@mfuntowicz Your Fedora case is very unusual. I tried reproducing on a stock Fedora system with CUDA 10.1 and was unable to. What happens when you run the following test:

test.cpp:

[[clang::warn_unused_result]]
int f() { return 2; }

Compile with:

/usr/local/cuda-10.1/bin/nvcc -ccbin clang -c test.cpp -std=c++11 -v --compiler-options=-Wall

?

I've gotten my grubby hands on a High Sierra machine so I'll try reproducing on it.

@mfuntowicz
Copy link
Contributor

@ezyang Thanks for having a look, here is the output:

/data/Workspace/pytorch_clang_test  echo '[[clang::warn_unused_result]]                                                            ✔  3956  13:57:50
int f() { return 2; }' >> test.cpp

mfuntowicz@localhost  /data/Workspace/pytorch_clang_test  nvcc -ccbin clang -c test.cpp -std=c++11 -v --compiler-options=-Wall                       127 ↵  3962  13:56:07

#$ _SPACE_=
#$ _CUDART_=cudart
#$ _HERE_=/usr/bin
#$ _THERE_=/usr/bin
#$ _TARGET_SIZE_=
#$ _TARGET_DIR_=
#$ _TARGET_SIZE_=64
#$ NVVMIR_LIBRARY_DIR=/usr/share/cuda
#$ PATH=/usr/libexec/cuda/open64/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/mfuntowicz/bin
#$ INCLUDES="-I/usr/include/cuda"
#$ LIBRARIES="-L/usr/lib64"
#$ CUDAFE_FLAGS=
#$ PTXAS_FLAGS=
#$ clang -std=c++11 -c -x c++ -D__NVCC__  -Wall "-I/usr/include/cuda"  -D__CUDACC_VER_MAJOR__=10 -D__CUDACC_VER_MINOR__=1 -D__CUDACC_VER_BUILD__=105 -m64 -o "test.o" "test.cpp"

Let me know if you need any other thing on my side that can be helpful.

@ezyang
Copy link
Contributor

ezyang commented May 9, 2019

I've managed to reproduce on a Fedora docker image. My command log:

    1  yum install clang
    2  cd ~
    3  cat > test.cpp
    4  clang++ -c test.cpp -std=c++11
    5  clang++ -c test.cpp -std=c++11 -Wall
    6  clang --version
    7  ls
    8  wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux
.run
    9  yum install wget
   10  wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux
.run
   11  ls
   12  sh cuda_10.1.105_418.39_linux.run 
   13  gcc --version
   14  less /var/log/cuda-installer.log
   15  ls /var/lo
   16  ls /var/log
   17  yum install less
   18  less /var/log/cuda-installer.log
   19  which
   20  yum install which
   21  sh cuda_10.1.105_418.39_linux.run 
   22  less /var/log/cuda-installer.log
   23  nvcc --help
   24  less /var/log/cuda-installer.log
   25  ls /usr/local/cuda-10.1/bin/nvcc --help
   26  ls /usr/local/cuda-10.1/bin/nvcc test.cpp
   27  ls /usr/local/cuda-10.1/bin/nvcc -c test.cpp
   28  /usr/local/cuda-10.1/bin/nvcc -c test.cpp
   29  /usr/local/cuda-10.1/bin/nvcc -c test.cpp -Wall
   30  /usr/local/cuda-10.1/bin/nvcc -c test.cpp -WAll
   31  /usr/local/cuda-10.1/bin/nvcc -c test.cpp 
   32  gcc --version
   33  /usr/local/cuda-10.1/bin/nvcc -ccbin clang -c test.cpp 
   34  clang --version
   35  /usr/local/cuda-10.1/bin/nvcc -ccbin clang --version
   36  /usr/local/cuda-10.1/bin/nvcc -ccbin clang -c test.cpp -v
   37  /usr/local/cuda-10.1/bin/nvcc -ccbin clang -c test.cpp -std=c++11
   38  /usr/local/cuda-10.1/bin/nvcc -ccbin clang -c test.cpp -std=c++11 -v
   39  /usr/local/cuda-10.1/bin/nvcc -ccbin clang -c test.cpp -std=c++11 -v -Wall
   40  /usr/local/cuda-10.1/bin/nvcc -ccbin clang -c test.cpp -std=c++11 -v --compiler-options=-Wall
   41  cat test.cpp
   42  /usr/local/cuda-10.1/bin/nvcc -ccbin clang -c test.cpp -std=c++11 -v --compiler-options=-Wpedantic
   43  ls
   44  git clone https://github.com/pytorch/pytorch.git
   45  yum install pytorch
   46  yum install git
   47  git clone https://github.com/pytorch/pytorch.git
   48  cd pytorch/
   49  ls
   50  python setup.py develop
   51  yum install python
   52  python setup.py develop
   53  git submodule update --init --recursive
   54  python setup.py develop
   55  cd ..
   56  ls
   57  wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
   58  chmod a+x Miniconda3-latest-Linux-x86_64.sh 
   59  ./Miniconda3-latest-Linux-x86_64.sh 
   60  yum install bunzip2
   61  yum install bunzip
   62  yum install bzip2
   63  ./Miniconda3-latest-Linux-x86_64.sh 
   64  ./Miniconda3-latest-Linux-x86_64.sh -u
   65  sa
   66  source activate
   67  ls
   68  . ~/.bashrc
   69  ls
   70  cd pytorch/
   71  ls
   72  vim README.md 
   73  conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing
   74  python setup.py develop
   75  CC=clang python setup.py develop
   76  CC=clang CXX=clang++ python setup.py develop
   77  ls
   78  vim README.md 
   79  USE_MKLDNN=0 CC=clang CXX=clang++ python setup.py develop
   81  history

@ezyang
Copy link
Contributor

ezyang commented May 9, 2019

This appears to be an NVIDIA bug.

@ezyang ezyang added module: cuda Related to torch.cuda, and CUDA support in general and removed needs reproduction Someone else needs to try reproducing the issue given the instructions. No action needed from user small We think this is a small issue to fix. Consider knocking off high priority small issues labels May 9, 2019
@ezyang
Copy link
Contributor

ezyang commented May 9, 2019

@ezyang ezyang changed the title turn off new mac os warnings from C10_NODISCARD macro warning: attribute namespace "clang" is unrecognized; High Sierra / Fedora compilation with clang results in spurious clang errors in nvcc May 9, 2019
ezyang added a commit that referenced this issue May 9, 2019
Fixes #13118.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
ezyang added a commit that referenced this issue May 9, 2019
Make C10_NODISCARD macro more portable for nvcc+clang.

Fixes #13118.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

gh-metadata: pytorch pytorch 20324 gh/ezyang/125/head
ezyang added a commit that referenced this issue May 9, 2019
Fixes #13118.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

gh-metadata: pytorch pytorch 20324 gh/ezyang/125/head
ezyang added a commit that referenced this issue May 10, 2019
Make C10_NODISCARD macro more portable for nvcc+clang.

Fixes #13118.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

gh-metadata: pytorch pytorch 20324 gh/ezyang/125/head
ezyang added a commit that referenced this issue May 10, 2019
Fixes #13118.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

gh-metadata: pytorch pytorch 20324 gh/ezyang/125/head
ezyang added a commit that referenced this issue May 16, 2019
Make C10_NODISCARD macro more portable for nvcc+clang.

Fixes #13118.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

gh-metadata: pytorch pytorch 20324 gh/ezyang/125/head
ezyang added a commit that referenced this issue May 16, 2019
Fixes #13118.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

gh-metadata: pytorch pytorch 20324 gh/ezyang/125/head
ezyang added a commit that referenced this issue May 16, 2019
Make C10_NODISCARD macro more portable for nvcc+clang.

Fixes #13118.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

gh-metadata: pytorch pytorch 20324 gh/ezyang/125/head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: build warnings Related to warnings during build process module: build Build system issues module: cuda Related to torch.cuda, and CUDA support in general triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

8 participants