install_environment_dev.sh 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. ################################################################################
  3. # Copyright (c) 2021 ContinualAI. #
  4. # Copyrights licensed under the MIT License. #
  5. # See the accompanying LICENSE file for terms. #
  6. # #
  7. # Date: 09-02-2021 #
  8. # Author(s): Gabriele Graffieti #
  9. # E-mail: contact@continualai.org #
  10. # Website: avalanche.continualai.org #
  11. ################################################################################
  12. python="3.8"
  13. cuda_version="none"
  14. help=false
  15. while test $# -gt 0; do
  16. case "$1" in
  17. --python)
  18. shift
  19. python=$1
  20. shift
  21. ;;
  22. --cuda_version)
  23. shift
  24. cuda_version=$1
  25. shift
  26. ;;
  27. --help)
  28. help=true
  29. shift
  30. ;;
  31. *)
  32. echo "$1 is not a recognized flag! Use --python and/or --cuda_version. Use --help to open the guide."
  33. exit 1;
  34. ;;
  35. esac
  36. done
  37. if [ "$help" = true ] ; then
  38. echo 'Usage: bash -i ./install_environment_dev.sh [OPTION]...'
  39. echo 'Install the avalanche development environment using conda'
  40. echo ''
  41. echo 'The scrip takes the following arguments:'
  42. echo ''
  43. echo ' --python set the python version. Can take the values [3.6, 3.7, 3.8, 3.9], default 3.8.'
  44. echo ' --cuda_version set the cuda version. You have to check the current version of cuda installed on your system and pass it as argument. If cuda is not installed or you want to use cpu pass "none". Can take the values [9.2, 10.1, 10.2, 11.0, 11.1, none], default none.'
  45. echo ' --help display this help and exit.'
  46. echo ''
  47. echo 'Examples:'
  48. echo ' bash -i install_environment_dev.sh --python 3.7 --cuda_version 10.2'
  49. echo ' bash -i install_environment_dev.sh --cuda_version none'
  50. exit 0
  51. fi
  52. echo "python version : $python";
  53. echo "cuda version : $cuda_version";
  54. if ! [[ "$python" =~ ^(3.6|3.7|3.8|3.9)$ ]]; then
  55. echo "Select a python version between 3.6, 3.7, 3.8, 3.9"
  56. exit 1
  57. fi
  58. if ! [[ "$cuda_version" =~ ^(9.2|10.1|10.2|11.0|11.1|"none")$ ]]; then
  59. echo "Select a CUDA version between 9.2 10.1, 10.2, 11.0, 11.1, none"
  60. exit 1
  61. fi
  62. conda create -n avalanche-dev-env python=$python -c conda-forge
  63. conda activate avalanche-dev-env
  64. if [[ "$cuda_version" = "none" ]]; then
  65. if [[ "$python_version" = 3.9 ]]; then
  66. conda install pytorch torchvision cpuonly -c pytorch -c=conda-forge
  67. else
  68. conda install pytorch torchvision cpuonly -c pytorch
  69. fi
  70. else
  71. if [[ "$python_version" = 3.9 || "$cuda_version" = 11.1 ]]; then
  72. conda install pytorch torchvision cudatoolkit=$cuda_version -c pytorch -c=conda-forge
  73. else
  74. conda install pytorch torchvision cudatoolkit=$cuda_version -c pytorch
  75. fi
  76. fi
  77. conda env update --file environment-dev.yml