deploy_server.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/env bash
  2. #################
  3. # Parse options #
  4. #################
  5. instructions() {
  6. echo "Usage: $0 [-i] [ -d ] [ -s ] [ -b ] [-p] [-t]" >&2
  7. echo " -i: initial peer"
  8. echo " -d: device" >&2
  9. echo " -s: server_id" >&2
  10. echo " -b: block_ids" >&2
  11. echo " -p: port to run a server" >&2
  12. echo " -t: whether to run local tests" >&2
  13. exit 1
  14. }
  15. if [ ! $# -ge 8 ]; then
  16. instructions
  17. fi
  18. while getopts ":i:d:s:b:p:t:" option; do
  19. case $option in
  20. i) INITIAL_PEER=${OPTARG}
  21. ;;
  22. d) DEVICE=${OPTARG}
  23. #((${DEVICE} == 'cpu' || ${DEVICE} == 'cuda')) || instructions
  24. ;;
  25. s) SERVER_ID=${OPTARG}
  26. ;;
  27. b) BLOCK_IDS=${OPTARG}
  28. ;;
  29. p) PORT=${OPTARG}
  30. ;;
  31. t) RUN_LOCAL_TESTS=true
  32. ;;
  33. \?) instructions
  34. ;;
  35. esac
  36. done
  37. echo "=========="
  38. echo "= Config ="
  39. echo "=========="
  40. echo "Initial peer: ${INITIAL_PEER}"
  41. echo "Device: ${DEVICE}"
  42. echo "Server name: server${SERVER_ID}.id"
  43. echo "Server address: /ip4/127.0.0.1/tcp/${PORT}"
  44. echo "Bloom blocks: ${BLOCK_IDS}"
  45. ###########################
  46. # Install or activate env #
  47. ###########################
  48. source ~/miniconda3/etc/profile.d/conda.sh
  49. if conda env list | grep ".*bloom-demo.*" >/dev/null 2>/dev/null; then
  50. conda activate bloom-demo
  51. else
  52. conda create -y --name bloom-demo python=3.8.12 pip
  53. conda activate bloom-demo
  54. conda install -y -c conda-forge cudatoolkit-dev==11.3.1 cudatoolkit==11.3.1 cudnn==8.2.1.32
  55. # Specify -i https://pypi.org/simple at ultramar
  56. pip install -i https://pypi.org/simple torch==1.11.0+cu113 torchvision==0.12.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html
  57. pip install -i https://pypi.org/simple accelerate==0.10.0 huggingface-hub==0.7.0 hivemind==1.1.0
  58. pip install -i https://pypi.org/simple bitsandbytes-cuda113==0.26.0
  59. pip install -i https://pypi.org/simple https://github.com/huggingface/transformers/archive/6589e510fa4e6c442059de2fab84752535de9b23.zip
  60. fi
  61. ##############
  62. # Local test #
  63. ##############
  64. if [ "$RUN_LOCAL_TESTS" = true ] ; then
  65. echo "Run test on your local machine"
  66. python -m cli.inference_one_block --config cli/config.json --device ${DEVICE} # see other args
  67. fi
  68. ##############
  69. # Run server #
  70. ##############
  71. python -m cli.run_server --prefix bloom6b3 --converted_model_name_or_path bigscience/test-bloomd-6b3 --device ${DEVICE} --initial_peer ${INITIAL_PEER} \
  72. --block_indices ${BLOCK_IDS} --torch_dtype float32 --identity_path ./server${SERVER_ID}.id --host_maddrs /ip4/127.0.0.1/tcp/${PORT} 2> server_${SERVER_ID}.out