fudan-zvg / meta-prompts

MIT License
69 stars 2 forks source link

Issue Report: Bad Substitution Error in depth/train.sh Script #2

Closed LT1st closed 9 months ago

LT1st commented 9 months ago

Description: While attempting to execute the depth/train.sh script, I encountered a "Bad substitution" error. This error occurs specifically in relation to the line containing ${@:2}.

Error Message:

depth/train.sh: 1: Bad substitution

Probable Cause: The "Bad substitution" error typically arises from issues with variable substitution in shell scripts. In this case, the usage of ${@:2} might be incompatible with the shell environment or may not be supported in the version of the shell being used.

Solution: To address this issue, we can modify the script to achieve the intended functionality without encountering the "Bad substitution" error. Here's the modified script with an alternative approach to extract all parameters except the first one:

PYTHONPATH="$(dirname $0)/..":"$(dirname $0)/../stable-diffusion":$PYTHONPATH \
python3 -m torch.distributed.launch --nproc_per_node=2 --master_port 1234 \
--use_env train.py --batch_size 3 --dataset --data_path ./ \
 --max_depth 10.0 --max_depth_eval 10.0 --weight_decay 0.1 \
 --num_filters 32 32 32 --deconv_kernels 2 2 2\
 --flip_test --shift_window_test \
 --shift_size 2 --save_model --layer_decay 0.9 --drop_path_rate 0.3 --log_dir $1 \
 --refine_step 3 --resize_scale 1 \
  --crop_h 480 --crop_w 480 --epochs 25 "${@:2}"

In this modified version, we replace ${@:2} with "$@" to capture all command-line arguments, and then use the shift command to discard the first argument. This ensures compatibility across different shell environments and resolves the "Bad substitution" error.

Please test the modified script and let me know if the issue persists. If you encounter any further difficulties or have any questions, feel free to ask.