linux运行python程序的脚本,包括如何指定显卡,使用循环,变量赋值与运算等

#!/bin/bash
for ((i=1;i<=6;i++))
do
        chunk_start=$[10752000*$i]
        chunk_end=$[$chunk_start+1536000]
        CUDA_VISIBLE_DEVICES=2 python scripts/generate_candidates.py --path_to_model_config models/elq_large_params.txt --path_to_model models/elq_webqsp_large.bin --entity_dict_path models/entity.jsonl --saved_cand_ids_dir ../GrailQA_Entity_Linker/data/freebase_candidate_representation --encoding_save_file_dir ../GrailQA_Entity_Linker/data/freebase_entity_encoding --batch_size 512 --chunk_start $chunk_start --chunk_end $chunk_end
done

上述代码涉及到了声明解释器

#!/bin/bash

for循环的使用

for ((i=1;i<=6;i++))
do
...
done

变量赋值与运算

chunk_start=$[10752000*$i]
chunk_end=$[$chunk_start+1536000]

以及显卡的指定等用法

CUDA_VISIBLE_DEVICES=0

为使上述脚本能够正常运行,需要
1、赋予权限

chmod +x script.sh

2、激活相关环境(供参)

conda activate environment

3、export相关路径(供参)

export PYTHONPATH=.

然后,使用bash +x运行脚本即可(bash +x 能够打印调试信息,方便debug):

bash +x ./script.sh
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值