I tried it out two different versions of cmake, namely 3.10.2 and 3.18.5. Also I applied the patch that was referred to in this post for the PyTorch installation with Python 3.6 - PyTorch for Jetson, but none of those measures helped.
Hi @patrick.nagelm8t1h, I haven’t build PyTorch for Python 3.8 myself, so some folks from the community may have more suggestions - have you tried building a specific version of PyTorch as opposed to PyTorch master? i.e. changing your git clone command to git clone --recursive --branch v1.7.0 http://github.com/pytorch/pytorch
Hey @dusty_nv, thank you for your quick response. With your help I was able to build PyTorch 1.7 for Python 3.8 on Jetpack 4.4.1 (Jetson Xavier). It actually helped to switch to the 1.7 branch of PyTorch. Here are the steps that worked for me:
I’ve tried to compile the pytorch-1.8 (the master branch on Dec 12, 2020) on JetPack 4.3 (cuda-10.2, cudnn-8) image (ubuntu 18.04) using the gcc-7.5, gcc-8.4, gcc-9.3 and gcc-10.1.
Finally, only the gcc-9.3 can be used to compile the code and generate the final wheel.
I am installing Torch 1.7 with python3.8 to Xavier NX (JetPack 4.4) on Ubuntu 18.04 using @patrick.nagelm8t1h’s advice. I got an error when I ran python3.8 setup.py install after python3.8 setup.py build.
Install the project…
– Install configuration: “Release”
– Set runtime path of “/home/costar/Documents/pytorch/torch/lib/libtorch_cuda.so” to “$ORIGIN:/usr/local/cuda/lib64:/usr/lib/aarch64-linux-gnu/openmpi/lib”
– Set runtime path of “/home/costar/Documents/pytorch/torch/lib/libtorch.so” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_atomic_ops_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_complex_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_complex_math_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_integer_divider_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_half_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_distributions_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_optional_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_packedtensoraccessor_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_vectorized_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/test/cuda_generator_test” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/lib/libtorchbind_test.so” to “$ORIGIN:/usr/local/cuda/lib64”
– Set runtime path of “/home/costar/Documents/pytorch/torch/lib/libjitbackend_test.so” to “$ORIGIN:/usr/local/cuda/lib64”
////
CMake Error at test_jit/cmake_install.cmake:90 (file):
file RPATH_CHANGE could not write new RPATH:
$ORIGIN:/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs
to the file:
/home/costar/Documents/pytorch/torch/bin/test_jit
////
No valid ELF RPATH or RUNPATH entry exists in the file; Failed to load
section headers.
Call Stack (most recent call first):
caffe2/cmake_install.cmake:3191 (include)
cmake_install.cmake:111 (include)
Makefile:61: recipe for target ‘install’ failed
make: *** [install] Error 1
Traceback (most recent call last):
File “setup.py”, line 727, in
build_deps()
File “setup.py”, line 314, in build_deps
build_caffe2(version=version,
File “/home/costar/Documents/pytorch/tools/build_pytorch_libs.py”, line 62, in build_caffe2
cmake.build(my_env)
File “/home/costar/Documents/pytorch/tools/setup_helpers/cmake.py”, line 346, in build
self.run(build_args, my_env)
File “/home/costar/Documents/pytorch/tools/setup_helpers/cmake.py”, line 141, in run
check_call(command, cwd=self.build_dir, env=env)
File “/usr/lib/python3.8/subprocess.py”, line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘cmake’, ‘–build’, ‘.’, ‘–target’, ‘install’, ‘–config’, ‘Release’, ‘–’, ‘-j’, ‘2’]’ returned non-zero exit status 2.
Hi, @xianmei.lei, I didn’t meet the problem you met. When I was compiling the pytorch from the source, I set export BUILD_TEST=0 before the compilation, so the test-related compilation might be skipped.
I retried with a fresh reinstallation of Jetpack 4.4.1 for python3.8 and torch1.7 using @patrick.nagelm8t1h’s solution again. Here is the error this time:
Run Build Command:“/usr/bin/make” “cmTC_7d06d/fast”
/usr/bin/make -f CMakeFiles/cmTC_7d06d.dir/build.make CMakeFiles/cmTC_7d06d.dir/build
make[1]: Entering directory ‘/home/costar/pytorch1.7/build/CMakeFiles/CMakeTmp’
Building CXX object CMakeFiles/cmTC_7d06d.dir/src.cxx.o
/usr/bin/c++ -DCAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING -std=c++14 -o CMakeFiles/cmTC_7d06d.dir/src.cxx.o -c /home/costar/pytorch1.7/build/CMakeFiles/CMakeTmp/src.cxx
/home/costar/pytorch1.7/build/CMakeFiles/CMakeTmp/src.cxx:1:10: fatal error: glog/stl_logging.h: No such file or directory include <glog/stl_logging.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Some posts said it is a bug for installing Torch from source. Some said cuDNN needs to be above version 6 so jetpack 4.4 comes with cuDNN v8, right?
I install following your suggestion, and got the error below.
any advise would be appreciated
– Private Dependencies : pthreadpool;cpuinfo;nnpack;XNNPACK;/usr/lib/aarch64-linux-gnu/libnuma.so;fp16;aten_op_header_gen;foxi_loader;rt;fmt::fmt-header-only;gcc_s;gcc;dl
– Configuring incomplete, errors occurred!
See also “/home/workspace/pytorch/build/CMakeFiles/CMakeOutput.log”.
See also “/home/workspace/pytorch/build/CMakeFiles/CMakeError.log”.
Traceback (most recent call last):
File “setup.py”, line 727, in
build_deps()
File “setup.py”, line 314, in build_deps
build_caffe2(version=version,
File “/home/workspace/pytorch/tools/build_pytorch_libs.py”, line 54, in build_caffe2
cmake.generate(version,
File “/home/workspace/pytorch/tools/setup_helpers/cmake.py”, line 330, in generate
self.run(args, env=my_env)
File “/home/workspace/pytorch/tools/setup_helpers/cmake.py”, line 141, in run
check_call(command, cwd=self.build_dir, env=env)
File “/home/samuel/archiconda3/envs/torchreid/lib/python3.8/subprocess.py”, line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘cmake’, ‘-GNinja’, ‘-DBUILD_PYTHON=True’, ‘-DBUILD_TEST=True’, ‘-DCMAKE_BUILD_TYPE=Release’, ‘-DCMAKE_INSTALL_PREFIX=/home/workspace/pytorch/torch’, ‘-DCMAKE_PREFIX_PATH=/home/samuel/archiconda3/envs/torchreid/lib/python3.8/site-packages’, ‘-DNUMPY_INCLUDE_DIR=/home/samuel/archiconda3/envs/torchreid/lib/python3.8/site-packages/numpy/core/include’, ‘-DPYTHON_EXECUTABLE=/home/samuel/archiconda3/envs/torchreid/bin/python3.8’, ‘-DPYTHON_INCLUDE_DIR=/home/samuel/archiconda3/envs/torchreid/include/python3.8’, ‘-DPYTHON_LIBRARY=/home/samuel/archiconda3/envs/torchreid/lib/libpython3.8.so.1.0’, ‘-DTORCH_BUILD_VERSION=1.7.0’, ‘-DUSE_DISTRIBUTED=0’, ‘-DUSE_NCCL=0’, ‘-DUSE_NUMPY=True’, ‘-DUSE_PYTORCH_QNNPACK=0’, ‘-DUSE_QNNPACK=0’, ‘/home/workspace/pytorch’]’ returned non-zero exit status 1.