pytorch / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
https://pytorch.org
Other
82.27k stars 22.13k forks source link

error while installing pytorch from source code #26100

Closed banshee1 closed 5 years ago

banshee1 commented 5 years ago

I am trying to install pytroch from source code and I met an error while compiling:

[ 86%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/autograd/profiler_cuda.cpp.o
[ 86%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/autograd/functions/comm.cpp.o
[ 86%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/cuda/comm.cpp.o
[ 86%] Linking CXX shared library ../lib/libtorch.so
/usr/bin/ld: /home/wjfan/anaconda3/envs/video-lfb/lib/libmagma.a(error.cpp.o): unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libtorch.so] Error 1
make[1]: *** [caffe2/CMakeFiles/torch.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 759, in <module>
    build_deps()
  File "setup.py", line 321, in build_deps
    cmake=cmake)
  File "/media/sdf/wjfan/Pytorch/pytorch/tools/build_pytorch_libs.py", line 63, in build_caffe2
    cmake.build(my_env)
  File "/media/sdf/wjfan/Pytorch/pytorch/tools/setup_helpers/cmake.py", line 329, in build
    self.run(build_args, my_env)
  File "/media/sdf/wjfan/Pytorch/pytorch/tools/setup_helpers/cmake.py", line 142, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/wjfan/anaconda3/envs/video-lfb/lib/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '56']' returned non-zero exit status 2 

here are the commands I ran:

conda create -n video-lfb python=2.7
source activate video-lfb

conda install numpy pyyaml mkl mkl-include setuptools cmake cffi typing
conda install -c pytorch magma-cuda100

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
rm -r caffe2/videos
cp -r caffe2-project-path/caffe2_customized_ops/video caffe2/

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
export CUDNN_LIB_DIR=[path to cnDNN]/lib64
export CUDNN_INCLUDE_DIR=[path to cnDNN]/include
python2 setup.py install

Is there anyone who know how to fix this error? Please help me !

albanD commented 5 years ago

Do you have CUDA9.0 as well inside your conda environment?

banshee1 commented 5 years ago

Do you have CUDA9.0 as well inside your conda environment?

Sorry I just checked and the version of cuda is 10.0, I have modified the commands I listed. I have cuda 10 in /usr/local/cuda-10.0

fmassa commented 5 years ago

I see that you are patching caffe2 before the build, can you try compiling PyTorch from a clean clone, without modifying anything?

banshee1 commented 5 years ago

I see that you are patching caffe2 before the build, can you try compiling PyTorch from a clean clone, without modifying anything?

I have tried to install an official pytorch version, but without modifying the caffe2/video and then compiling I cannot run my codes.

banshee1 commented 5 years ago

I see that you are patching caffe2 before the build, can you try compiling PyTorch from a clean clone, without modifying anything?