Compile From Source Error

I wanted to use the ignore_index() in ClassNLL2d criterion, which was added in a recent commit on July 14, so I compiled from source. I followed the instructions given on the PyTorch GitHub page.

I tried doing this with the latest version as well as the snapshot at the commit I linked to, but both give me the following gcc error when they trying to build torch._C after running the python setup.py install command:

...
...
Install the project...
-- Install configuration: "Release"
-- Installing: /home/rishabh/pytorch/torch/lib/tmp_install/lib/libTHD.so.1
-- Installing: /home/rishabh/pytorch/torch/lib/tmp_install/lib/libTHD.so
-- Set runtime path of "/home/rishabh/pytorch/torch/lib/tmp_install/lib/libTHD.so.1" to ""
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/THD.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/base/ChannelType.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/base/Cuda.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/base/DataChannel.h
...
...
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/master_worker/master/THDTensor.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/master_worker/master/generic/THDStorage.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/master_worker/master/generic/THDTensor.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/master_worker/master/generic/THDTensorCopy.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/master_worker/master/generic/THDTensorLapack.h
-- Installing: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/master_worker/master/generic/THDTensorMath.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/master_worker/master/generic/THDTensorRandom.h
-- Up-to-date: /home/rishabh/pytorch/torch/lib/tmp_install/include/THD/master_worker/worker/Worker.h
running build
running build_py
-- Building version 0.1.12+d6bc264
copying torch/version.py -> build/lib.linux-x86_64-3.6/torch
copying torch/autograd/variable.py -> build/lib.linux-x86_64-3.6/torch/autograd
copying torch/autograd/__init__.py -> build/lib.linux-x86_64-3.6/torch/autograd
copying torch/autograd/gradcheck.py -> build/lib.linux-x86_64-3.6/torch/autograd
copying torch/nn/functional.py -> build/lib.linux-x86_64-3.6/torch/nn
...
...
copying torch/lib/include/THC/generic/THCTensorTopK.h -> build/lib.linux-x86_64-3.6/torch/lib/include/THC/generic
copying torch/lib/include/THC/generic/THCTensorMasked.h -> build/lib.linux-x86_64-3.6/torch/lib/include/THC/generic
copying torch/lib/include/THC/generic/THCTensorRandom.h -> build/lib.linux-x86_64-3.6/torch/lib/include/THC/generic
copying torch/lib/include/THC/generic/THCTensorMathScan.h -> build/lib.linux-x86_64-3.6/torch/lib/include/THC/generic
copying torch/lib/include/THC/generic/THCTensorCopy.h -> build/lib.linux-x86_64-3.6/torch/lib/include/THC/generic
copying torch/lib/include/THC/generic/THCTensorMathPairwise.h -> build/lib.linux-x86_64-3.6/torch/lib/include/THC/generic
running build_ext
-- Building with NumPy bindings
-- Detected cuDNN at /usr/local/cuda/lib64, /usr/local/cuda/include
-- Detected CUDA at /usr/local/cuda
-- Building NCCL library
-- Building with distributed package 
building 'torch._C' extension
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/rishabh/pytorch -I/home/rishabh/pytorch/torch/csrc -I/home/rishabh/pytorch/torch/lib/tmp_install/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/TH -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THPP -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THNN -I/home/rishabh/pytorch/torch/lib/tmp_install/include/ATen -I/home/rishabh/anaconda3/lib/python3.6/site-packages/numpy/core/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THD -I/usr/local/cuda/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THCUNN -I/usr/local/cuda/include -I/home/rishabh/anaconda3/include/python3.6m -c torch/csrc/PtrWrapper.cpp -o build/temp.linux-x86_64-3.6/torch/csrc/PtrWrapper.o -D_THP_CORE -std=c++11 -Wno-write-strings -fno-strict-aliasing -DWITH_NUMPY -DWITH_DISTRIBUTED -DWITH_CUDA -DCUDA_LIB_PATH=/usr/local/cuda/lib64 -DWITH_NCCL -DWITH_CUDNN
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/rishabh/pytorch -I/home/rishabh/pytorch/torch/csrc -I/home/rishabh/pytorch/torch/lib/tmp_install/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/TH -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THPP -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THNN -I/home/rishabh/pytorch/torch/lib/tmp_install/include/ATen -I/home/rishabh/anaconda3/lib/python3.6/site-packages/numpy/core/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THD -I/usr/local/cuda/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THCUNN -I/usr/local/cuda/include -I/home/rishabh/anaconda3/include/python3.6m -c torch/csrc/Exceptions.cpp -o build/temp.linux-x86_64-3.6/torch/csrc/Exceptions.o -D_THP_CORE -std=c++11 -Wno-write-strings -fno-strict-aliasing -DWITH_NUMPY -DWITH_DISTRIBUTED -DWITH_CUDA -DCUDA_LIB_PATH=/usr/local/cuda/lib64 -DWITH_NCCL -DWITH_CUDNN
...
...
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/rishabh/pytorch -I/home/rishabh/pytorch/torch/csrc -I/home/rishabh/pytorch/torch/lib/tmp_install/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/TH -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THPP -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THNN -I/home/rishabh/pytorch/torch/lib/tmp_install/include/ATen -I/home/rishabh/anaconda3/lib/python3.6/site-packages/numpy/core/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THD -I/usr/local/cuda/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THCUNN -I/usr/local/cuda/include -I/home/rishabh/anaconda3/include/python3.6m -c torch/csrc/cudnn/BatchNorm.cpp -o build/temp.linux-x86_64-3.6/torch/csrc/cudnn/BatchNorm.o -D_THP_CORE -std=c++11 -Wno-write-strings -fno-strict-aliasing -DWITH_NUMPY -DWITH_DISTRIBUTED -DWITH_CUDA -DCUDA_LIB_PATH=/usr/local/cuda/lib64 -DWITH_NCCL -DWITH_CUDNN
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/rishabh/pytorch -I/home/rishabh/pytorch/torch/csrc -I/home/rishabh/pytorch/torch/lib/tmp_install/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/TH -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THPP -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THNN -I/home/rishabh/pytorch/torch/lib/tmp_install/include/ATen -I/home/rishabh/anaconda3/lib/python3.6/site-packages/numpy/core/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THD -I/usr/local/cuda/include -I/home/rishabh/pytorch/torch/lib/tmp_install/include/THCUNN -I/usr/local/cuda/include -I/home/rishabh/anaconda3/include/python3.6m -c torch/csrc/cudnn/Conv.cpp -o build/temp.linux-x86_64-3.6/torch/csrc/cudnn/Conv.o -D_THP_CORE -std=c++11 -Wno-write-strings -fno-strict-aliasing -DWITH_NUMPY -DWITH_DISTRIBUTED -DWITH_CUDA -DCUDA_LIB_PATH=/usr/local/cuda/lib64 -DWITH_NCCL -DWITH_CUDNN
torch/csrc/cudnn/Conv.cpp: In static member function ‘static cudnnConvolutionFwdAlgoPerf_t torch::cudnn::{anonymous}::algorithm_search<cudnnConvolutionFwdAlgo_t>::findAlgorithm(THCState*, cudnnHandle_t, const torch::cudnn::Convolution&, void*, void*, void*)’:
torch/csrc/cudnn/Conv.cpp:160:10: error: ‘CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED’ was not declared in this scope
          CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED,
          ^
torch/csrc/cudnn/Conv.cpp: In static member function ‘static cudnnConvolutionBwdDataAlgoPerf_t torch::cudnn::{anonymous}::algorithm_search<cudnnConvolutionBwdDataAlgo_t>::findAlgorithm(THCState*, cudnnHandle_t, const torch::cudnn::Convolution&, void*, void*, void*)’:
torch/csrc/cudnn/Conv.cpp:201:10: error: ‘CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED’ was not declared in this scope
          CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED
          ^
torch/csrc/cudnn/Conv.cpp: In static member function ‘static cudnnConvolutionBwdFilterAlgoPerf_t torch::cudnn::{anonymous}::algorithm_search<cudnnConvolutionBwdFilterAlgo_t>::findAlgorithm(THCState*, cudnnHandle_t, const torch::cudnn::Convolution&, void*, void*, void*)’:
torch/csrc/cudnn/Conv.cpp:245:10: error: ‘CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED’ was not declared in this scope
          CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED,
          ^
error: command 'gcc' failed with exit status 1

BTW, I had already installed PyTorch using Anaconda on my system (CUDA 8.0, Python 3.6), using the command on the main page, at the location ~/anaconda3.

Any idea why this might be happening?

Try the following:

pip uninstall torch
python setup.py clean
python setup.py build

Worked perfectly. Thanks. :slight_smile:

1 Like

I get the error, even after clean… at least when I try

NO_DISTRIBUTED=1 python3.5 setup.py clean
NO_DISTRIBUTED=1 python3.5 setup.py install --user