Skip to the content.

Install Pytorch in AWS from Source

Official Instruction

Update OS

```shell script sudo yum update

## Installation
### Python Environment
* Install python
```shell script
sudo yum install python3.7

set(WORKSPACE_PATH /home/ec2-user/workspaces/workspace_cpp) set(PYTORCH_SRC_PATH ${WORKSPACE_PATH}/pytorch) set(PYTORCH_SRC_INC_PATH ${PYTORCH_SRC_PATH}/torch/include/)

set(PYTORCH_BLD_PATH ${PYTORCH_SRC_PATH}/build/) set(PYTORCH_GEN_INC_PATH ${PYTORCH_BLD_PATH}/lib.linux-x86_64-3.7/torch/include/) set(PYTORCH_GEN_LIB_PATH ${PYTORCH_BLD_PATH}/lib/) set(PYTORCH_LIB_PATH ${PYTORCH_BLD_PATH}/lib.linux-x86_64-3.7/torch/lib/) set(STATIC_LIB_PATH ${PYTORCH_GEN_LIB_PATH})

set(static_libs ${STATIC_LIB_PATH}/libprotoc.a ${STATIC_LIB_PATH}/libprotobuf.a ${STATIC_LIB_PATH}/libpthreadpool.a ${STATIC_LIB_PATH}/libc10d.a )

set(shared_libs opencv_core opencv_highgui opencv_imgproc torch torch_cpu glog gflags boost_system c10 rt pthread lmdb python3.7m stdc++fs) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS “-g -std=c++17”) set(CMAKE_BUILD_TYPE Debug)

include_directories(include) include_directories(${CAFFE2_SRC_INC_PATH}) include_directories(${CAFFE2_GEN_INC_PATH}) include_directories(${CAFFE2_SRC_PATH}/torch/csrc/api/include) include_directories(${WORKSPACE_PATH}/matplotlib-cpp) include_directories(/usr/include/python3.7m) include_directories(/usr/local/lib64/python3.7/site-packages/numpy/core/include)

link_directories(${CAFFE2_LIB_PATH}) ```