caffe2-update 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/..; pwd)
  4. build=${root}/build
  5. node_modules=${root}/node_modules
  6. src=${root}/src
  7. tools=${root}/tools
  8. third_party=${root}/third_party
  9. python=${python:-python}
  10. pip=${pip:-pip}
  11. identifier=pytorch
  12. repository=https://github.com/pytorch/pytorch.git
  13. mkdir -p ${third_party}
  14. if [ -d "${third_party}/${identifier}" ]; then
  15. git -C "${third_party}/${identifier}" fetch -p
  16. git -C "${third_party}/${identifier}" reset --hard origin/master
  17. else
  18. echo "Clone ${repository}..."
  19. git -C "${third_party}" clone --recursive ${repository}
  20. fi
  21. echo "Generate '../src/caffe2.js'"
  22. ${node_modules}/protobufjs/bin/pbjs -t static-module -w closure -r caffe2 -o ${src}/caffe2.js ${third_party}/pytorch/caffe2/proto/caffe2.proto
  23. echo "Install Caffe2 dependencies"
  24. brew bundle --file=- <<-EOS
  25. brew "automake"
  26. brew "cmake"
  27. brew "gflags"
  28. brew "glog"
  29. EOS
  30. export PYTHONUSERBASE=${build}/third_party/pypi/${identifier}
  31. export PATH=$PATH:${PYTHONUSERBASE}/bin
  32. ${pip} install --user future leveldb numpy protobuf pydot python-gflags pyyaml scikit-image setuptools six
  33. echo "Build Caffe2"
  34. pushd "${third_party}/pytorch" > /dev/null
  35. git submodule update --init
  36. ${python} setup_caffe2.py develop --user
  37. popd > /dev/null
  38. echo "Generate '../src/caffe2-metadata.json'"
  39. pushd ${tools} > /dev/null
  40. ${python} caffe2-metadata.py
  41. popd > /dev/null