caffe2-update 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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"
  24. if [ "$(uname -s)" == "Darwin" ] && [ "$(which brew)" != "" ]; then
  25. brew bundle --file=- <<-EOS
  26. brew "automake"
  27. brew "cmake"
  28. brew "gflags"
  29. brew "glog"
  30. EOS
  31. fi
  32. export PYTHONUSERBASE=${build}/third_party/pypi/${identifier}
  33. export PATH=$PATH:${PYTHONUSERBASE}/bin
  34. rm -rf ${PYTHONUSERBASE}
  35. ${pip} install --user future leveldb numpy protobuf pydot python-gflags pyyaml scikit-image setuptools six hypothesis
  36. pushd "${third_party}/pytorch" > /dev/null
  37. git submodule update --init
  38. ${python} setup_caffe2.py develop --user
  39. popd > /dev/null
  40. echo "Generate '../src/caffe2-metadata.json'"
  41. pushd ${tools} > /dev/null
  42. ${python} caffe2-metadata.py
  43. popd > /dev/null