Thursday, August 1, 2019

Instructions for the C++ Torch installation modified for the Mac

https://github.com/intel/mkl-dnn/releases
https://github.com/intel/mkl-dnn

https://intel.github.io/mkl-dnn/dev_guide_build.html

Linux/macOS

  • Generate makefile: 
    mkdir -p build && cd build && cmake ..
  • Build the library: 
    make -j
  • Build the documentation: 
    make doc
  • Install the library, headers, and documentation: 
    make install
git clone https://github.com/intel/mkl-dnn.git
cd mkl-dnn/
mkdir -p build && cd build && cmake ..
make -j
make doc
make install

Validate the Build

Run unit tests:
ctest


// add this env var to your .bash_profile file

export Torch_DIR=$USER/libtorch

// HACK ALERT
// https://github.com/pytorch/pytorch/issues/14727#issuecomment-516575929

wget https://github.com/intel/mkl-dnn/releases/download/v0.20-rc/mklml_mac_2019.0.5.20190502.tgz
mv ~/Downloads//mklml_mac_2019.0.5.20190502.tar .
tar xvf mklml_mac_2019.0.5.20190502.tar


wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-latest.zip
unzip libtorch-macos-latest.zip 
cd build/
source ~/.bash_profile
cd ..
mv first_example.cc first_example.cpp
cd build

cmake -DCMAKE_PREFIX_PATH=~/libtorch ..

~/torch/build
./first_example 
 0.9762  0.1762  0.9328
 0.5004  0.3410  0.1637
 0.3285  0.0761  0.6350
[ Variable[CPUFloatType]{3,3} ]
 0.9762  0.1762  0.9328
 0.5004  0.3410  0.1637
 0.3285  0.0761  0.6350

[ Variable[CPUFloatType]{3,3} ]



https://github.com/zdevito/ATen/tree/master/aten/src



No comments:

Post a Comment