Jetson TX2 编译 Pytorch (Wheel)

参考 https://gist.github.com/dusty-nv/ef2b372301c00c0a9d3203e42fd83426

1. 按照注释内容修改源码

2. 修改 -d 参数 

sudo python setup.py bdist_wheel -d [the path where to save the wheel file]

 3. 执行以下命令

### before you build pytorch modify the following files

#./pytorch/CMakeList.txt
#   > CmakeLists.txt : Change NCCL to 'OFF' on line 97
#./pytorch/setup.py
#   > setup.py: Add USE_NCCL = False below line 198
#./pytorch/tools/setup_helpers/nccl.py
#   > nccl.py : Change USE_SYSTEM_NCCL to 'False'
#               Change NCCL to 'False'
#./pytorch/torch/csrc/cuda/nccl.h
#   > nccl.h : Comment self-include on line 8
#              Comment entire code:
#		//void throw_nccl_error(ncclResult_t status);
#
#		//static inline void NCCL_CHECK(ncclResult_t status) {
#		//  if (status != ncclSuccess) {
#		//    throw_nccl_error(status);
#		//  }
#		//}
#./torch/csrc/distributed/c10d/ddp.cpp
#   > ddp.cpp : Comment #include 
#               Comment torch::cuda::nccl::reduce

###



sudo apt install libopenblas-dev libatlas-dev liblapack-dev
sudo apt install liblapacke-dev checkinstall # For OpenCV
sudo apt-get install python-pip

pip install --upgrade pip==9.0.1
sudo apt-get install python-dev

sudo pip install numpy scipy # ~20-30 min
sudo pip install pyyaml
sudo pip install scikit-build
sudo apt-get -y install cmake
sudo apt install libffi-dev
sudo pip install cffi

#add couple of lines to the end of  ~/.bashrc or ~/.profile
sudo gedit ~/.bashrc
export CUDNN_LIB_DIR=/usr/lib/aarch64-linux-gnu
export CUDNN_INCLUDE_DIR=/usr/include
source ~/.bashrc

wget https://rpmfind.net/linux/mageia/distrib/cauldron/aarch64/media/core/release/ninja-1.8.2-3.mga7.aarch64.rpm

sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install alien
sudo apt-get install nano

sudo alien ninja-1.8.2-3.mga7.aarch64.rpm
   #If previous line fails, proceed to <$sudo dpkg -i ninja-1.8.2-3.mga7.aarch64.deb> 
   sudo alien -g ninja-1.8.2-3.mga7.aarch64.rpm
   cd ninja-1.8.2
   sudo nano debian/control
   #at architecture, add arm64 after aarch64 (aarch64, arm64)
   sudo debian/rules binary
cd ..
sudo dpkg -i ninja_1.8.2-4_arm64.deb
sudo apt install ninja-build
cd ..
git clone http://github.com/pytorch/pytorch
cd pytorch
sudo pip install -U setuptools
sudo pip install -r requirements.txt
git submodule update --init --recursive

python setup.py build_deps


   
sudo nvpmodel -m 0
sudo DEBUG=1 python setup.py build develop

#If build fails before 100%
sudo python setup.py clean
sudo DEBUG=1 python setup.py build develop

#elif build fails after 100%
sudo python setup.py clean
sudo DEBUG=1 python setup.py develop

sudo apt clean
sudo apt-get install libjpeg-dev zlib1g-dev

sudo pip install pillow
sudo pip install pandas # ~20-30 min
sudo pip install Cython
sudo pip install scikit-image
sudo python setup.py bdist_wheel -d [the path where to save the wheel file]
#sudo pip --no-cache-dir install torchvision

 

 

你可能感兴趣的:(深度学习,机器学习)