DeepSpeed icon indicating copy to clipboard operation
DeepSpeed copied to clipboard

[BUG] Multi-Node training "os.PathLike object" and "ds_opt_adam" error.

Open ashmalvayani opened this issue 1 year ago • 4 comments

How to run deepspeed with multi-node configuration?

I have two A100 8x80GB nodes (named as 675d-5, 675d-6) that I want to use for fine-tuning a llama2-7b model using FastChat repository and deepspeed config. When I run my training script I get the following error (I have just copied the error part of the code, the model and data is loaded successfully but before it tries to run a step, it throws this error):

676d-5 optimizer = DeepSpeedCPUAdam(model_parameters,
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/ops/adam/cpu_adam.py", line 94, in __init__
675d-5:     self.ds_opt_adam = CPUAdamBuilder().load()
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/ops/op_builder/builder.py", line 479, in load
675d-5:     return self.jit_load(verbose)
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/ops/op_builder/builder.py", line 499, in jit_load
675d-5:     extra_include_paths = [os.path.abspath(self.deepspeed_src_path(path)) for path in self.include_paths()]
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/ops/op_builder/cpu_adam.py", line 41, in include_paths
675d-5:     CUDA_INCLUDE = [os.path.join(torch.utils.cpp_extension.CUDA_HOME, "include")]
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/posixpath.py", line 76, in join
675d-5:     a = os.fspath(a)
675d-5: TypeError: expected str, bytes or os.PathLike object, not NoneType
675d-5: Traceback (most recent call last):
675d-5:   File "/mnt/beegfs/fahad.khan/Arabic_MobiLlama/FastChat/fastchat/train/train.py", line 326, in <module>
675d-5: Exception ignored in: <function DeepSpeedCPUAdam.__del__ at 0x7fc1e04e1360>
675d-5: Traceback (most recent call last):
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/ops/adam/cpu_adam.py", line 102, in __del__
675d-5:     self.ds_opt_adam.destroy_adam(self.opt_id)
675d-5: AttributeError: 'DeepSpeedCPUAdam' object has no attribute 'ds_opt_adam'
675d-5:     train()
675d-5:   File "/mnt/beegfs/fahad.khan/Arabic_MobiLlama/FastChat/fastchat/train/train.py", line 314, in train
675d-5: Traceback (most recent call last):
675d-5:   File "/mnt/beegfs/fahad.khan/Arabic_MobiLlama/FastChat/fastchat/train/train.py", line 326, in <module>
675d-5:     trainer.train()
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/transformers/trainer.py", line 1539, in train
675d-5:     return inner_training_loop(
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/transformers/trainer.py", line 1690, in _inner_training_loop
675d-5:     model, self.optimizer, self.lr_scheduler = self.accelerator.prepare(
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/accelerate/accelerator.py", line 1255, in prepare
675d-5:     result = self._prepare_deepspeed(*args)
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/accelerate/accelerator.py", line 1640, in _prepare_deepspeed
675d-5:     train()
675d-5:   File "/mnt/beegfs/fahad.khan/Arabic_MobiLlama/FastChat/fastchat/train/train.py", line 314, in train
675d-5:     engine, optimizer, _, lr_scheduler = deepspeed.initialize(**kwargs)
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/__init__.py", line 176, in initialize
675d-5:     engine = DeepSpeedEngine(args=args,
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/runtime/engine.py", line 307, in __init__
675d-5:     self._configure_optimizer(optimizer, model_parameters)
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/runtime/engine.py", line 1230, in _configure_optimizer
675d-5:     basic_optimizer = self._configure_basic_optimizer(model_parameters)
675d-5:   File "/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed/runtime/engine.py", line 1301, in _configure_basic_optimizer

My hostfile is as follows:

675d-4 slots=8
675d-5 slots=8

My running script is as follows:

deepspeed --hostfile hostfile.sh fastchat/train/train.py \
    --deepspeed ds_config.json \
    --model_name_or_path meta-llama/Llama-2-7b-hf  \
    --data_path Data2.json \
    --fp16 True \
    --output_dir Outputs \
    --num_train_epochs 1 \
    --per_device_train_batch_size 4 \
    --per_device_eval_batch_size 4 \
    --gradient_accumulation_steps 16 \
    --evaluation_strategy "no" \
    --save_strategy "steps" \
    --save_steps 100 \
    --save_total_limit 3 \
    --learning_rate 2e-5 \
    --weight_decay 0. \
    --warmup_ratio 0.04 \
    --lr_scheduler_type "cosine" \
    --logging_steps 1 \
    --tf32 True \
    --model_max_length 2048 \
    --report_to wandb \
    --run_name "Run_Experiment_llama2" \
    --gradient_checkpointing True \
    --lazy_preprocess True

Libraries Versions

Deepspeed version: 0.14.0
Torch version: pytorch 2.0.0 py3.10_cuda11.7_cudnn8.5.0_0
Accelerate Version: 0.28.0

ds_report output

[2024-04-08 00:55:50,191] [INFO] [real_accelerator.py:191:get_accelerator] Setting ds_accelerator to cuda (auto detect)
--------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
      runtime if needed. Op compatibility means that your system
      meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [OKAY]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
async_io ............... [NO] ....... [OKAY]
fused_adam ............. [NO] ....... [OKAY]
cpu_adam ............... [NO] ....... [OKAY]
cpu_adagrad ............ [NO] ....... [OKAY]
cpu_lion ............... [NO] ....... [OKAY]
 [WARNING]  Please specify the CUTLASS repo directory as environment variable $CUTLASS_PATH
evoformer_attn ......... [NO] ....... [NO]
fused_lamb ............. [NO] ....... [OKAY]
fused_lion ............. [NO] ....... [OKAY]
inference_core_ops ..... [NO] ....... [OKAY]
cutlass_ops ............ [NO] ....... [OKAY]
transformer_inference .. [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
ragged_device_ops ...... [NO] ....... [OKAY]
ragged_ops ............. [NO] ....... [OKAY]
random_ltd ............. [NO] ....... [OKAY]
 [WARNING]  sparse_attn requires a torch version >= 1.5 and < 2.0 but detected 2.0
 [WARNING]  using untested triton version (2.0.0), only 1.0.0 is known to be compatible
sparse_attn ............ [NO] ....... [NO]
spatial_inference ...... [NO] ....... [OKAY]
transformer ............ [NO] ....... [OKAY]
stochastic_transformer . [NO] ....... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ............... ['/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/torch']
torch version .................... 2.0.0
deepspeed install path ........... ['/home/ashmal.vayani/anaconda3/envs/finetune_mobillama/lib/python3.10/site-packages/deepspeed']
deepspeed info ................... 0.14.0, unknown, unknown
torch cuda version ............... 11.7
torch hip version ................ None
nvcc version ..................... 11.7
deepspeed wheel compiled w. ...... torch 2.2, cuda 12.1
shared memory (/dev/shm) size .... 503.79 GB

Screenshots image

Docker context No Docker

ashmalvayani avatar Apr 07 '24 22:04 ashmalvayani

Hi there!

I encountered the same error on a single A100 80 GPU. The error occurred in the code at "deepspeed.ops.op_builder.CPUAdamBuilder().load()" and output the message "TypeError: expected str, bytes, or os.PathLike object, not NoneType".

Can someone help me understand what's wrong and how to fix it?

bboylyg avatar May 12 '24 11:05 bboylyg

Hi there!

I encountered the same error on a single A100 80 GPU. The error occurred in the code at "deepspeed.ops.op_builder.CPUAdamBuilder().load()" and output the message "TypeError: expected str, bytes, or os.PathLike object, not NoneType".

Can someone help me understand what's wrong and how to fix it?

If I commented out this code "deepspeed.ops.op_builder.CPUAdamBuilder().load()", this will cause an error of "AttributeError: 'DeepSpeedCPUAdam' object has no attribute 'ds_opt_adam". Looking forward to a kindly response about this question!

bboylyg avatar May 12 '24 11:05 bboylyg

Can you try running the following line:

export CUDA_HOME=/usr/local/cuda-11.X

Change the path with the path of your CUDA.

ashmalvayani avatar May 12 '24 12:05 ashmalvayani

Can you try running the following line:

export CUDA_HOME=/usr/local/cuda-11.X

Change the path with the path of your CUDA.

Thanks for your reply. I have changed the CUDA version and this helped me fix the error.

bboylyg avatar May 17 '24 14:05 bboylyg