Facebook
From Denim Iguana, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 89
  1. # Copyright (c) 2022, NVIDIA CORPORATION.  All rights reserved.
  2. #
  3. # NVIDIA CORPORATION and its licensors retain all intellectual property
  4. # and proprietary rights in and to this software, related documentation
  5. # and any modifications thereto.  Any use, reproduction, disclosure or
  6. # distribution of this software and related documentation without an express
  7. # license agreement from NVIDIA CORPORATION is strictly prohibited.
  8.  
  9. # GPU family of target platform. Supported values: tegra, non-tegra
  10. riva_target_gpu_family="tegra"
  11.  
  12. # Name of tegra platform that is being used. Supported tegra platforms: orin, xavier
  13. riva_tegra_platform="orin"
  14.  
  15. # Enable or Disable Riva Services
  16. service_enabled_asr=true
  17. service_enabled_nlp=true
  18. service_enabled_tts=true
  19.  
  20. # Enable Riva Enterprise
  21. # If enrolled in Enterprise, enable Riva Enterprise by setting configuration
  22. # here. You must explicitly acknowledge you have read and agree to the EULA.
  23. # RIVA_API_KEY=<ngc api key>
  24. # RIVA_API_NGC_ORG=<ngc organization>
  25. # RIVA_EULA=accept
  26.  
  27. # Language code to fetch models of a specify language
  28. # Currently only ASR supports languages other than English
  29. # Supported language codes: en-US, en-GB, de-DE, es-US, ru-RU, zh-CN, hi-IN, fr-FR, ko-KR, pt-BR
  30. # for any language other than English, set service_enabled_nlp and service_enabled_tts to False
  31. # for multiple languages enter space separated language codes.
  32. language_code=("en-US")
  33.  
  34. # ASR acoustic model architecture
  35. # Supported values are: conformer, citrinet_1024, citrinet_256 (en-US + arm64 only), jasper (en-US + amd64 only), quartznet (en-US + amd64 only)
  36. asr_acoustic_model=("conformer")
  37.  
  38. # Specify one or more GPUs to use
  39. # specifying more than one GPU is currently an experimental feature, and may result in undefined behaviours.
  40. gpus_to_use="device=0"
  41.  
  42. # Specify the encryption key to use to deploy models
  43. MODEL_DEPLOY_KEY="tlt_encode"
  44.  
  45. # Locations to use for storing models artifacts
  46. #
  47. # If an absolute path is specified, the data will be written to that location
  48. # Otherwise, a docker volume will be used (default).
  49. #
  50. # riva_init.sh will create a `rmir` and `models` directory in the volume or
  51. # path specified.
  52. #
  53. # RMIR ($riva_model_loc/rmir)
  54. # Riva uses an intermediate representation (RMIR) for models
  55. # that are ready to deploy but not yet fully optimized for deployment. Pretrained
  56. # versions can be obtained from NGC (by specifying NGC models below) and will be
  57. # downloaded to $riva_model_loc/rmir by `riva_init.sh`
  58. #
  59. # Custom models produced by NeMo or TLT and prepared using riva-build
  60. # may also be copied manually to this location $(riva_model_loc/rmir).
  61. #
  62. # Models ($riva_model_loc/models)
  63. # During the riva_init process, the RMIR files in $riva_model_loc/rmir
  64. # are inspected and optimized for deployment. The optimized versions are
  65. # stored in $riva_model_loc/models. The riva server exclusively uses these
  66. # optimized versions.
  67. riva_model_loc="riva-model-repo"
  68.  
  69. if [[ $riva_target_gpu_family == "tegra" ]]; then
  70.     riva_model_loc="`pwd`/model_repository"
  71. fi
  72.  
  73. # The default RMIRs are downloaded from NGC by default in the above $riva_rmir_loc directory
  74. # If you'd like to skip the download from NGC and use the existing RMIRs in the $riva_rmir_loc
  75. # then set the below $use_existing_rmirs flag to true. You can also deploy your set of custom
  76. # RMIRs by keeping them in the riva_rmir_loc dir and use this quickstart script with the
  77. # below flag to deploy them all together.
  78. use_existing_rmirs=false
  79.  
  80. # Ports to expose for Riva services
  81. riva_speech_api_port="50051"
  82.  
  83. # NGC orgs
  84. riva_ngc_org="nvidia"
  85. riva_ngc_team="riva"
  86. riva_ngc_image_version="2.7.0"
  87. riva_ngc_model_version="2.7.0"
  88.  
  89. # Pre-built models listed below will be downloaded from NGC. If models already exist in $riva-rmir
  90. # then models can be commented out to skip download from NGC
  91.  
  92. ########## ASR MODELS ##########
  93.  
  94. models_asr=()
  95.  
  96. for lang_code in ${language_code[@]}; do
  97.     modified_lang_code="${lang_code/-/_}"
  98.     modified_lang_code=${modified_lang_code,,}
  99.     if [[ $riva_target_gpu_family  == "tegra" ]]; then
  100.  
  101.       if [[ ${asr_acoustic_model} == "jasper" || \
  102.             ${asr_acoustic_model} == "quartznet" ]]; then
  103.           echo "Jasper and Quartznet models are not available for arm64 architecture"
  104.           exit 1
  105.       fi
  106.  
  107.       if [[ ${asr_acoustic_model} == "citrinet_256" && ${lang_code} != "en-US" ]]; then
  108.         echo "For arm64 architecture, citrinet_256 acoustic model is only available for language code en-US."
  109.         exit 1
  110.       fi
  111.       models_asr+=(
  112.           "${riva_ngc_org}/${riva_ngc_team}/models_asr_${asr_acoustic_model}_${modified_lang_code}_str:${riva_ngc_model_version}-${riva_target_gpu_family}-${riva_tegra_platform}"
  113.       )
  114.     else
  115.  
  116.       if [[ ${asr_acoustic_model} != "conformer" && \
  117.             ${asr_acoustic_model} != "citrinet_1024" && \
  118.             ${asr_acoustic_model} != "jasper" && \
  119.             ${asr_acoustic_model} != "quartznet" ]]; then
  120.         echo "For amd64 architecture, valid acoustic models are conformer, citrinet_1024, jasper and quartznet."
  121.         exit 1
  122.       fi
  123.  
  124.       if [[ (${asr_acoustic_model} == "jasper" || \
  125.             ${asr_acoustic_model} == "quartznet") && \
  126.             ${lang_code} != "en-US" ]]; then
  127.         echo "jasper and quartznet acoustic models are only available for language code en-US."
  128.         exit 1
  129.       fi
  130.       #Setting default Conformer Mandarin models to greedy decoder due to high high latency in os2s.
  131.       decoder=""
  132.       if [[ ${asr_acoustic_model} == "conformer" && ${lang_code} == "zh-CN" ]]; then
  133.         decoder="_gre"
  134.       fi
  135.       models_asr+=(
  136.       ### Streaming w/ CPU decoder, best latency configuration
  137.           "${riva_ngc_org}/${riva_ngc_team}/rmir_asr_${asr_acoustic_model}_${modified_lang_code}_str${decoder}:${riva_ngc_model_version}"
  138.  
  139.       ### Streaming w/ CPU decoder, best throughput configuration
  140.       #    "${riva_ngc_org}/${riva_ngc_team}/rmir_asr_${asr_acoustic_model}_${modified_lang_code}_str_thr${decoder}:${riva_ngc_model_version}"
  141.  
  142.       ### Offline w/ CPU decoder,
  143.           "${riva_ngc_org}/${riva_ngc_team}/rmir_asr_${asr_acoustic_model}_${modified_lang_code}_ofl${decoder}:${riva_ngc_model_version}"
  144.       )
  145.     fi
  146.  
  147.     ### Punctuation model
  148.     if [[ "${lang_code}"  == "en-US" || "${lang_code}" == "de-DE" || "${lang_code}" == "hi-IN" || "${lang_code}" == "fr-FR" || "${lang_code}" == "es-US" || "${lang_code}" == "zh-CN" || "${lang_code}" == "en-GB" ]]; then
  149.       if [[ $riva_target_gpu_family == "tegra" ]]; then
  150.         models_asr+=(
  151.             "${riva_ngc_org}/${riva_ngc_team}/models_nlp_punctuation_bert_base_${modified_lang_code}:${riva_ngc_model_version}-${riva_target_gpu_family}-${riva_tegra_platform}"
  152.         )
  153.       else
  154.         models_asr+=(
  155.             "${riva_ngc_org}/${riva_ngc_team}/rmir_nlp_punctuation_bert_base_${modified_lang_code}:${riva_ngc_model_version}"
  156.         )
  157.       fi
  158.     fi
  159.  
  160. done
  161. ########## NLP MODELS ##########
  162.  
  163. if [[ $riva_target_gpu_family == "tegra" ]]; then
  164.   models_nlp=(
  165.   ### BERT Base Intent Slot model for misty domain fine-tuned on weather, smalltalk/personality, poi/map datasets.
  166.       "${riva_ngc_org}/${riva_ngc_team}/models_nlp_intent_slot_misty_bert_base:${riva_ngc_model_version}-${riva_target_gpu_family}-${riva_tegra_platform}"
  167.  
  168.   ### DistilBERT Intent Slot model for misty domain fine-tuned on weather, smalltalk/personality, poi/map datasets.
  169.   #    "${riva_ngc_org}/${riva_ngc_team}/models_nlp_intent_slot_misty_distilbert:${riva_ngc_model_version}-${riva_target_gpu_family}-${riva_tegra_platform}"
  170.   )
  171. else
  172.   models_nlp=(
  173.   ### Bert base Punctuation model
  174.       "${riva_ngc_org}/${riva_ngc_team}/rmir_nlp_punctuation_bert_base_en_us:${riva_ngc_model_version}"
  175.  
  176.   ### BERT base Named Entity Recognition model fine-tuned on GMB dataset with class labels LOC, PER, ORG etc.
  177.       "${riva_ngc_org}/${riva_ngc_team}/rmir_nlp_named_entity_recognition_bert_base:${riva_ngc_model_version}"
  178.  
  179.   ### BERT Base Intent Slot model fine-tuned on weather dataset.
  180.       "${riva_ngc_org}/${riva_ngc_team}/rmir_nlp_intent_slot_bert_base:${riva_ngc_model_version}"
  181.  
  182.   ### BERT Base Question Answering model fine-tuned on Squad v2.
  183.       "${riva_ngc_org}/${riva_ngc_team}/rmir_nlp_question_answering_bert_base:${riva_ngc_model_version}"
  184.  
  185.   ### Megatron345M Question Answering model fine-tuned on Squad v2.
  186.   #    "${riva_ngc_org}/${riva_ngc_team}/rmir_nlp_question_answering_megatron:${riva_ngc_model_version}"
  187.  
  188.   ### Bert base Text Classification model fine-tuned on 4class (weather, meteorology, personality, nomatch) domain model.
  189.       "${riva_ngc_org}/${riva_ngc_team}/rmir_nlp_text_classification_bert_base:${riva_ngc_model_version}"
  190.   )
  191. fi
  192.  
  193. ########## TTS MODELS ##########
  194.  
  195. if [[ $riva_target_gpu_family == "tegra" ]]; then
  196.   models_tts=(
  197.      "${riva_ngc_org}/${riva_ngc_team}/models_tts_fastpitch_hifigan_en_us:${riva_ngc_model_version}-${riva_target_gpu_family}-${riva_tegra_platform}"
  198.   )
  199. else
  200.   models_tts=(
  201.     "${riva_ngc_org}/${riva_ngc_team}/rmir_tts_fastpitch_hifigan_en_us:${riva_ngc_model_version}"
  202.   )
  203. fi
  204.  
  205. NGC_TARGET=${riva_ngc_org}
  206. if [[ ! -z ${riva_ngc_team} ]]; then
  207.   NGC_TARGET="${NGC_TARGET}/${riva_ngc_team}"
  208. else
  209.   team="\"\""
  210. fi
  211.  
  212. # Specify paths to SSL Key and Certificate files to use TLS/SSL Credentials for a secured connection.
  213. # If either are empty, an insecure connection will be used.
  214. # Stored within container at /ssl/servert.crt and /ssl/server.key
  215. # Optional, one can also specify a root certificate, stored within container at /ssl/root_server.crt
  216. ssl_server_cert=""
  217. ssl_server_key=""
  218. ssl_root_cert=""
  219.  
  220. # define docker images required to run Riva
  221. image_speech_api="nvcr.io/${NGC_TARGET}/riva-speech:${riva_ngc_image_version}-l4t-aarch64"
  222.  
  223. # define docker images required to setup Riva
  224. image_init_speech="nvcr.io/${NGC_TARGET}/riva-speech:${riva_ngc_image_version}-servicemaker-l4t-aarch64"
  225.  
  226. # daemon names
  227. riva_daemon_speech="riva-speech"
  228. if [[ $riva_target_gpu_family != "tegra" ]]; then
  229.     riva_daemon_client="riva-client"
  230. fi
  231.