PyTorch 1.1 C++

PyTorch Doc PyTorch C++ 使用参考

1. Pytorch 1.1 Demo

2. Installation

# cuda 10
sudo rpm -i cuda-repo-rhel7-10.0.130-1.x86_64.rpm
sudo yum clean all
sudo yum install cuda-10-0
echo "export PATH=/usr/local/cuda/bin:\$PATH" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:\$LD_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc

# cuda example
mkdir cuda-samples
cuda-install-samples-10.0.sh cuda-samples/
pushd cuda-samples/NVIDIA_CUDA-10.0_Samples/0_Simple/clock
make
./clock
popd

# cudnn
tar -xvf cudnn-10.0-linux-x64-v7.6.1.34.tar
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

# libtorch1.1
#wget https://download.pytorch.org/libtorch/cu100/libtorch-shared-with-deps-latest.zip
#unzip libtorch-shared-with-deps-latest.zip

# cmake
sudo yum -y install cmake3

# python3
cd /usr/bin
sudo mv python python.bak
sudo ln -s python3.6 python
cd ~/path-to-drives
wget https://repo.continuum.io/archive/Anaconda3-2019.03-Linux-x86_64.sh
bash Anaconda3-2019.03-Linux-x86_64.sh
source ~/.bashrc

# pytorch
git clone --recursive https://github.com/pytorch/pytorch
git checkout v1.1.0
git submodule init && git submodule update
mkdir build_libtorch && cd build_libtorch
python ../tools/build_libtorch.py # wait 10~20 mins

echo "export LD_LIBRARY_PATH=/path-to-pytorch/torch/lib64:\$LD_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc

# imgcat
curl -o imgcat  https://iterm2.com/utilities/imgcat
chmod 755 imgcat
sudo cp imgcat /usr/local/bin/
Loading Disqus comments...
Table of Contents