Don't use nvidia_torch_version until after None check
State: closed | Pull request: yes
Labels: name: stale

name: NLP

name: Run CICD

# What does this PR do ?

There was a crash when nvidia_torch_version came back as None because it was still being used before the None check.

**Collection**: [NLP]

# Changelog 
Fixed crash when NVIDIA_PYTORCH_VERSION is not set

# Usage
* You can potentially add a usage example below
Run a anything that exercises this code without NVIDIA_PYTORCH_VERSION set

# GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

# Before your PR is "Ready for review"
**Pre checks**:
- [ X] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [X ] Did you write any new necessary tests?
- [ X] Did you add or update any necessary documentation?
- [ ] Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
  - [ ] Reviewer: Does the PR have correct import guards for all optional libraries?
  
**PR Type**:
- [ ] New Feature
- [X ] Bugfix
- [ ] Documentation

If you haven't finished some of the above items you can still open "Draft" PR.


## Who can review?

 @MaximumEntropy  @thomasdhc  (Not sure if I'm supposed to ping the whole NLP reviewer list)

Anyone in the community is free to review the PR once the checks have passed. 
[Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md) contains specific people who can review PRs to various areas.

# Additional Information
* Related to # (issue)
This is a minor fix. No associated tests or documentation. I tried to keep it simple. Devs may prefer different logic (e.g. an extra none check before the official release check, move the is_official_release_version def inside the None check block, etc)

<!-- pylint-output-strict-mode-false -->

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.

---

Your code was analyzed with PyLint. The following annotations have been identified:

```
************* Module nemo.collections.nlp.models.language_modeling.megatron_base_model
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:103:0: C0301: Line too long (149/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:111:0: C0301: Line too long (134/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:252:0: C0301: Line too long (125/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:270:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:345:0: C0301: Line too long (133/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:604:0: C0301: Line too long (123/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:659:0: C0301: Line too long (153/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:831:0: C0301: Line too long (122/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:959:0: C0301: Line too long (121/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:978:0: C0301: Line too long (136/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1095:0: C0301: Line too long (195/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1152:0: C0301: Line too long (135/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1200:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1283:0: C0301: Line too long (128/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:329:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:459:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:464:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:697:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:749:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:920:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1024:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1258:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1289:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1293:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron_base_model.py:1297:4: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.59/10
```

---

Thank you for improving NeMo's documentation!

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

This PR was closed because it has been inactive for 7 days since being marked as stale.