有些代码项目给.sh文件。
例如
GitHub - renqianluo/NAO_pytorch: Pytorch Implementation of Neural Architecture Optimization
文件名 train_NAONet_A_36_cifar10.sh
# Train the architecture discovered by NAO, with channel size of 36, noted as NAONet-A-36
nvidia-smi
MODEL=NAONet_A_36_cifar10
OUTPUT_DIR=exp/$MODEL
DATA_DIR=data
mkdir -p $OUTPUT_DIR
fixed_arc="0 7 1 15 2 8 1 7 0 6 1 7 0 8 4 7 1 5 0 7 0 7 1 13 0 6 0 14 0 9 1 10 0 14 2 6 1 11 0 7"
python train_cifar.py \
--data=$DATA_DIR \
--output_dir=$OUTPUT_DIR \
--arch="$fixed_arc" \
--use_aux_head \
--cutout_size=16 | tee -a $OUTPUT_DIR/train.log
四种执行方法
方式一: (要进到shell脚本所在文件夹中)
bash train_NAONet_A_36_cifar10.sh
方式二: (要进到shell脚本所在文件夹中)
sh train_NAONet_A_36_cifar10.sh
方式三: (要进到shell脚本所在文件夹中)
./train_NAONet_A_36_cifar10.sh
第三种方式可能会出现
-bash: ./train_NAONet_A_36_cifar10.sh: Permission denied
解决方式:
chmod +x train_NAONet_A_36_cifar10.sh
方式四:
/root/autodl-tmp/NAO_pytorch-master/NAO_V1/train_NAONet_A_36_cifar10.sh
运行结果展示
Sun Oct 6 14:39:01 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.90.07 Driver Version: 550.90.07 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 2080 Ti On | 00000000:3D:00.0 Off | N/A |
| 28% 31C P8 8W / 250W | 1MiB / 11264MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 1 NVIDIA GeForce RTX 2080 Ti On | 00000000:40:00.0 Off | N/A |
| 26% 29C P8 20W / 250W | 1MiB / 11264MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+
10/06 02:39:01 PM Args = Namespace(arch='0 7 1 15 2 8 1 7 0 6 1 7 0 8 4 7 1 5 0 7 0 7 1 13 0 6 0 14 0 9 1 10 0 14 2 6 1 11 0 7', batch_size=128, channels=36, cutout_size=16, data='dataset', dataset='cifar10', drop_path_keep_prob=0.8, epochs=600, eval_batch_size=500, grad_bound=5.0, keep_prob=0.6, l2_reg=0.0003, layers=6, lr_max=0.025, lr_min=0, mode='data/cifar-10/', nodes=5, output_dir='exp/NAONet_A_36_cifar10', seed=0, steps=234600, use_aux_head=True)
Files already downloaded and verified
Files already downloaded and verified
10/06 02:39:03 PM param size = 11.470150MB
10/06 02:39:03 PM Use 2 GPUs !