Suggestion to add Megatron to PYTHONPATH
Browse files
README.md
CHANGED
|
@@ -71,6 +71,22 @@ You can move those files to different directories if needed.
|
|
| 71 |
python3 $MYDIR/transformers/src/transformers/models/megatron_bert/convert_megatron_bert_checkpoint.py $MYDIR/nvidia/megatron-bert-uncased-345m/checkpoint.zip
|
| 72 |
```
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
## Masked LM
|
| 75 |
|
| 76 |
The following code shows how to use the Megatron BERT checkpoint and the Transformers API to perform a `Masked LM` task.
|
|
|
|
| 71 |
python3 $MYDIR/transformers/src/transformers/models/megatron_bert/convert_megatron_bert_checkpoint.py $MYDIR/nvidia/megatron-bert-uncased-345m/checkpoint.zip
|
| 72 |
```
|
| 73 |
|
| 74 |
+
As explained in [PR #14956](https://github.com/huggingface/transformers/pull/14956), if when running this conversion
|
| 75 |
+
script and you're getting an exception:
|
| 76 |
+
```
|
| 77 |
+
ModuleNotFoundError: No module named 'megatron.model.enums'
|
| 78 |
+
```
|
| 79 |
+
you need to tell python where to find the clone of Megatron-LM, e.g.:
|
| 80 |
+
```
|
| 81 |
+
cd /tmp
|
| 82 |
+
git clone https://github.com/NVIDIA/Megatron-LM
|
| 83 |
+
PYTHONPATH=/tmp/Megatron-LM python src/transformers/models/megatron_bert/convert_megatron_bert_checkpoint.py ...
|
| 84 |
+
```
|
| 85 |
+
Or, if you already have it cloned elsewhere, simply adjust the path to the existing path.
|
| 86 |
+
|
| 87 |
+
If the training was done using a Megatron-LM fork, e.g. [Megatron-DeepSpeed](https://github.com/microsoft/Megatron-DeepSpeed/) then
|
| 88 |
+
you may need to have that one in your path, i.e., /path/to/Megatron-DeepSpeed.
|
| 89 |
+
|
| 90 |
## Masked LM
|
| 91 |
|
| 92 |
The following code shows how to use the Megatron BERT checkpoint and the Transformers API to perform a `Masked LM` task.
|