install_fairaws.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # The script is installing seamless_communication (internal) + fairseq2 on AWS cluster.
  2. set -e
  3. set -x
  4. echo "Installing Conda"
  5. export TGT=`echo ~/seacom_aws_dev`
  6. rm -rf $TGT
  7. wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -qO /tmp/conda.sh
  8. bash /tmp/conda.sh -bp $TGT
  9. export CONDA=$TGT/bin/conda
  10. export CONDA_ACTIVATE=$TGT/bin/activate
  11. export ENV_N=sc_fr2_dev
  12. echo "Next step will take ~15 minutes. Get some coffee"
  13. $CONDA create -y -n ${ENV_N} python=3.10 pytorch=2.0.1 pytorch-cuda=11.8 torchvision torchaudio \
  14. compilers libsndfile==1.0.31 gcc==11.4.0 \
  15. --strict-channel-priority --override-channels \
  16. -c https://aws-ml-conda.s3.us-west-2.amazonaws.com \
  17. -c pytorch \
  18. -c nvidia \
  19. -c conda-forge
  20. echo "Setting LD_LIBRARY_PATH"
  21. . $CONDA_ACTIVATE activate ${ENV_N}
  22. if [ -z "$CONDA_PREFIX" ]; then
  23. echo "CONDA_PREFIX env var is not set!"
  24. exit 1
  25. else
  26. path=$CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
  27. echo "export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH\n" >> ${path}
  28. fi
  29. . $CONDA_ACTIVATE activate ${ENV_N} # update env vars
  30. # NOTICE: to compile CUDA kernels, you need NVCC. On AWS cluster an easy way would be to get a GPU container:
  31. # srun -N 1 --gres=gpu:1 --cpus-per-task=20 --partition seamless --time 2400 --pty /bin/bash -l
  32. # Installing fairseq2.
  33. echo "Installing fairseq2"
  34. set -e
  35. rm -rf fairseq2 # wipe existing clones
  36. if [[ "${I_DONT_PLAN_TO_HACK_FAIRSEQ2:-No}" == "Yes" ]] ; then
  37. pip install fairseq2 \
  38. --pre --extra-index-url https://fair.pkg.atmeta.com/fairseq2/whl/nightly/pt2.0.1/cu118
  39. else
  40. nvidia-smi || echo "to compile CUDA kernels, you need NVCC.\n \
  41. On AWS cluster an easy way would be to get a GPU container.\n \
  42. Run smth like 'srun -N 1 --gres=gpu:1 --cpus-per-task=20 --partition seamless --time 2400 --pty /bin/bash -l' \n \
  43. and continue from "Installing fairseq2" line. \
  44. Terminating for now."
  45. nvidia-smi || exit 1
  46. cd $TGT
  47. . $CONDA_ACTIVATE activate ${ENV_N}
  48. git clone --recurse-submodules git@github.com:facebookresearch/fairseq2.git
  49. pip install -r fairseq2/fairseq2n/python/requirements-build.txt
  50. cd fairseq2
  51. pip install -e . # it will install public fairseq2n, we rewrite it below
  52. cd fairseq2n
  53. args="-GNinja\
  54. -DCMAKE_BUILD_TYPE=Release \
  55. -DCMAKE_CUDA_ARCHITECTURES=80-real;80-virtual\
  56. -DFAIRSEQ2N_INSTALL_STANDALONE=ON\
  57. -DFAIRSEQ2N_PERFORM_LTO=ON\
  58. -DFAIRSEQ2N_TREAT_WARNINGS_AS_ERRORS=OFF\
  59. -DFAIRSEQ2N_USE_CUDA=ON\
  60. -DFAIRSEQ2N_BUILD_PYTHON_BINDINGS=ON\
  61. -DFAIRSEQ2N_PYTHON_DEVEL=OFF"
  62. cmake ${args} -B build
  63. cmake --build build
  64. cd python && pip install .
  65. fi
  66. # Quick test
  67. python -c "from fairseq2n.bindings.data.string import CString as CString"
  68. echo "Installing seamless_communication"
  69. cd $TGT
  70. git clone git@github.com:fairinternal/seamless_communication.git
  71. cd seamless_communication
  72. pip install -e . # editable mode for hacking
  73. echo "One more time re-install fairseq2n (most propably overriden by seamless_communication)"
  74. cd $TGT/fairseq2/fairseq2n/python
  75. pip install .
  76. echo "Finished."
  77. echo "To activate the environment run: . $CONDA_ACTIVATE activate ${ENV_N}"
  78. echo "Location of seamless_communication checkout: $TGT/seamless_communication"