Download vision_commads.txt from Akshay9028/NotWorking: direct link, hf CLI and curl.
- Browser
- Download file 7.48 kB
-
https://huggingface.co/Akshay9028/NotWorking/resolve/main/vision_commads.txt
- Command line
-
hf download hf://Akshay9028/NotWorking/vision_commads.txt
-
curl -L -o vision_commads.txt https://huggingface.co/Akshay9028/NotWorking/resolve/main/vision_commads.txt
7.48 kB
| root@1ef1af939ad2:/opt/Megatron-Bridge# history | |
| 1 nvidia-smi | |
| 2 pwd | |
| 3 ls | |
| 4 export HF_MODEL_PATH=nvidia/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 5 export MEGATRON_MODEL_PATH=/models/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 6 ./scripts/conversion/convert.sh import --hf-model $HF_MODEL_PATH --megatron-path $MEGATRON_MODEL_PATH --trust-remote-code | |
| 7 ls | |
| 8 cd scripts | |
| 9 ls | |
| 10 cd.. | |
| 11 cd .. | |
| 12 python examples/conversion/convert_checkpoints.py import --hf-model $HF_MODEL_PATH --megatron-path $MEGATRON_MODEL_PATH --trust-remote-code | |
| 13 python examples/conversion/hf_to_megatron_generate_vlm.py --hf_model_path $HF_MODEL_PATH --megatron_model_path $MEGATRON_MODEL_PATH --image_path /data/test.jpg --prompt "Describe this image." --max_new_tokens 100 --use_llava_model | |
| 14 torchrun --nproc_per_node=1 examples/conversion/hf_to_megatron_generate_vlm.py --hf_model_path $HF_MODEL_PATH --megatron_model_path $MEGATRON_MODEL_PATH --image_path /data/test.jpg --prompt "Describe this image." --max_new_tokens 100 --use_llava_model | |
| 15 nvidia-smi | |
| 16 export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True | |
| 17 torchrun --nproc_per_node=1 examples/conversion/hf_to_megatron_generate_vlm.py --hf_model_path $HF_MODEL_PATH --megatron_model_path $MEGATRON_MODEL_PATH --image_path /data/test.jpg --prompt "Describe this image." --max_new_tokens 100 --use_llava_model | |
| 18 Command 'torchrun' not found, but can be installed with: | |
| 19 sudo apt install python3-torch | |
| 20 find . -iname "*nemotron*vl*" -name "*.py" | |
| 21 find . -path "*recipes*" -iname "*nemotron*" | |
| 22 python examples/recipes/nemotron_vl/finetune_nemotron_nano_v2_vl.py --help | |
| 23 cat examples/recipes/nemotron_vl/conf/nemotron_nano_v2_vl_override_example.yaml | |
| 24 ls /data/ai_enhanced_photos | head | |
| 25 grep -rn "def make_raven_dataset" src/ | |
| 26 F=src/megatron/bridge/data/vlm_datasets/hf_dataset_makers.py | |
| 27 sed -n '1,40p' $F | |
| 28 sed -n '117,180p' $F | |
| 29 grep -rn "maker_name\|make_raven_dataset" src/ examples/ | grep -v "def make_raven" | |
| 30 F=src/megatron/bridge/data/vlm_datasets/hf_dataset_makers.py | |
| 31 P=src/megatron/bridge/data/vlm_datasets/hf_provider.py | |
| 32 cp $F ${F}.bak; cp $P ${P}.bak | |
| 33 cat >> $F <<'EOF' | |
| 34 F=src/megatron/bridge/data/vlm_datasets/hf_dataset_makers.py | |
| 35 P=src/megatron/bridge/data/vlm_datasets/hf_provider.py | |
| 36 cp $F ${F}.bak; cp $P ${P}.bak | |
| 37 cat >> $F <<'EOF' | |
| 38 sed -i '0,/^\(\s*\)make_raven_dataset,$/s//&\n\1make_house_condition_dataset,/' $P | |
| 39 sed -i 's/^\(\s*\)"make_raven_dataset": make_raven_dataset,/&\n\1"make_house_condition_dataset": make_house_condition_dataset,/' $P | |
| 40 grep -n "make_house_condition_dataset" $P | |
| 41 python -c " | |
| from megatron.bridge.data.vlm_datasets.hf_dataset_makers import make_house_condition_dataset as m | |
| from megatron.bridge.data.vlm_datasets import hf_provider | |
| d = m() | |
| print('examples:', len(d)) | |
| print('image type:', type(d[0]['conversation'][0]['content'][0]['image'])) | |
| print('answer:', d[0]['conversation'][1]['content'][0]['text']) | |
| " | |
| 42 cat > /data/my_ft.yaml <<'EOF' | |
| model: | |
| seq_length: 4096 | |
| freeze_language_model: False | |
| freeze_vision_model: False | |
| freeze_vision_projection: False | |
| tensor_model_parallel_size: 1 | |
| train: | |
| train_iters: 20 | |
| global_batch_size: 8 | |
| micro_batch_size: 1 | |
| eval_iters: 0 | |
| optimizer: | |
| lr: 2e-5 | |
| min_lr: 2e-6 | |
| scheduler: | |
| lr_warmup_iters: 5 | |
| checkpoint: | |
| save: /models/house_condition_lora | |
| save_interval: 20 | |
| dist: | |
| use_megatron_fsdp: false | |
| use_torch_fsdp2: false | |
| logger: | |
| log_interval: 1 | |
| wandb_project: null | |
| wandb_exp_name: house_condition_test | |
| wandb_entity: null | |
| wandb_save_dir: /models/wandb | |
| dataset: | |
| sequence_length: 4096 | |
| maker_name: make_house_condition_dataset | |
| rng: | |
| seed: 42 | |
| ddp: | |
| grad_reduce_in_fp32: true | |
| EOF | |
| 43 export HF_MODEL_PATH=nvidia/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 44 export MEGATRON_MODEL_PATH=/models/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 45 xport PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True WANDB_MODE=disabled | |
| 46 export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True WANDB_MODE=disabled | |
| 47 torchrun --nproc_per_node=1 examples/recipes/nemotron_vl/finetune_nemotron_nano_v2_vl.py --config-file /data/my_ft.yaml --hf-model-path $HF_MODEL_PATH --pretrained-checkpoint $MEGATRON_MODEL_PATH --lora-on-language-model --lora-on-vision-model | |
| 48 sed -i 's/^\(\s*train_iters:\).*/\1 95/' /data/my_ft.yaml | |
| 49 sed -i 's#^\(\s*save:\).*#\1 /models/house_condition_lora_full#' /data/my_ft.yaml | |
| 50 sed -i 's/^\(\s*save_interval:\).*/\1 19/' /data/my_ft.yaml | |
| 51 grep -E "train_iters|global_batch_size|lr_warmup_iters|save:|save_interval" /data/my_ft.yaml | |
| 52 export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True WANDB_MODE=disabled | |
| 53 export HF_MODEL_PATH=nvidia/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 54 export MEGATRON_MODEL_PATH=/models/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 55 torchrun --nproc_per_node=1 examples/recipes/nemotron_vl/finetune_nemotron_nano_v2_vl.py --config-file /data/my_ft.yaml --hf-model-path $HF_MODEL_PATH --pretrained-checkpoint $MEGATRON_MODEL_PATH --lora-on-language-model --lora-on-vision-model 2>&1 | tee /models/train_full.log | |
| 56 grep -o "iteration *[0-9]*/.*lm loss: [0-9.E+-]*" /models/train_full.log | awk '{print $2, $NF}' | |
| 57 find . -iname "*merge*" -name "*.py" | grep -v -e __pycache__ -e tests | |
| 58 python examples/peft/merge_lora.py --help | |
| 59 export HF_MODEL_PATH=nvidia/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 60 export MEGATRON_MODEL_PATH=/models/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 61 export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True | |
| 62 torchrun --nproc_per_node=1 examples/peft/merge_lora.py --lora-checkpoint /models/house_condition_lora_full --pretrained $MEGATRON_MODEL_PATH --hf-model-path $HF_MODEL_PATH --output /models/house_condition_merged --dtype bf16 | |
| 63 ls -R /models/house_condition_merged | head | |
| 64 export HF_MODEL_PATH=nvidia/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 65 export MEGATRON_MODEL_PATH=/models/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16 | |
| 66 export LORA_ITER=/models/house_condition_lora_full/iter_0000095 | |
| 67 export MERGED=/models/house_condition_merged | |
| 68 export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True | |
| 69 export PROMPT="Analyze the condition of the room or area of the house shown in this image. List any visible defects, cleanliness issues, and signs of wear-and-tear." | |
| 70 ls $LORA_ITER # should list .metadata, *.distcp and possibly run_config.yaml | |
| 71 nvidia-smi # check the GPU is free | |
| 72 torchrun --nproc_per_node=1 examples/peft/merge_lora.py --lora-checkpoint $LORA_ITER --pretrained $MEGATRON_MODEL_PATH --hf-model-path $HF_MODEL_PATH --output $MERGED --dtype bf16 | |
| 73 torchrun --nproc_per_node=1 examples/conversion/hf_to_megatron_generate_vlm.py --hf_model_path $HF_MODEL_PATH --megatron_model_path $MERGED --image_path /data/ai_enhanced_photos/house_01_balcony_backyard_enhanced-1.jpg --prompt "$PROMPT" --max_new_tokens 200 --use_llava_model | |
| 74 du -sh $MEGATRON_MODEL_PATH /models/house_condition_merged | |
| 75 ls -la /models/house_condition_merged/*/ | head | |
| 76 history |