学习shell脚本编写时遇到问题和解决方法整理

PHPer 2025-09-05 14 0 0

开一个帖子 20250905 1808...

立即注册
更新于:2025-09-05 18:08:06
    您需要登录后才可以评论。 立即注册

    SyntaxError: f-string: expecting '}' 关键修复:print(f\"GPU设备: ...\")外层用双引号,内层用单引号,避免冲突。

    print(f'GPU设备: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A'}')

    ^

    SyntaxError: f-string: expecting '}'

    错误代码

    cuda_check_output=$(python -c "
    import torch
    print(f'PyTorch版本: {torch.__version__}')
    print(f'CUDA可用: {torch.cuda.is_available()}')
    if torch.cuda.is_available():
        print(f'CUDA版本: {torch.version.cuda}')
        print(f'GPU设备: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A'}')
    else:
        print('CURRENT_CPU_ON***')
    " 2>&1)

    关键修复:print(f\"GPU设备: ...\")外层用双引号,内层用单引号,避免冲突。

    print(f'GPU设备: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A'}')

    定位到的错误,修改改为...

    立即注册
    更新于:2025-09-05 18:12:31

    setup_train_env.sh: <stdout>: commitBuffer: invalid argument (cannot encode character '\10067')

    shellcheck setup_train_env.sh

    In setup_train_env.sh line 142:

    setup_train_env.sh: <stdout>: commitBuffer: invalid argument (cannot encode character '\10067')

    read -p "For more information:

    shellcheck setup_train_env.sh
    In setup_train_env.sh line 142:
    setup_train_env.sh: <stdout>: commitBuffer: invalid argument (cannot encode character '\10067')
                read -p "For more information:

    Copilot:

    这个报错说明你的脚本里有特殊字符(如中文符号、emoji、或其他 Unicode 字符),而 shellcheck 在 Windows 下无法正确编码这些字符(如 \10067 是 Unicode 问号 ❓)。

    解决方法:

    尽量避免在 shell 脚本中直接使用 emoji 或特殊 Unicode 字符,改用英文或标准 ASCII 字符。...

    立即注册
    更新于:2025-09-06 06:31:09
    相关内容

    SQL 学习整理

    SQL中EXISTS的使用

    Yii2报错没有关联命名 common\models\Post has no relation named

    SQL常用语句

    SQL复杂查询(案例一)

    Sql常用查询操作

    【知乎】从零学会SQL:复杂查询

    sql查询两张表中不同的数据

    python 学习中遇到的问题整理

    没有使用asynccontextmanager ,但是报cannot import name 'asynccontextman...

    python3.10.0+pyinstaller4.7打包,IndexError: tuple index out of range...

    error: Microsoft Visual C++ 14.0 or greater is required.

    安装conda搭建python环境(保姆级教程)

    学习飞浆过程中遇到“缺少paddle.fluid”

    [NLP实践01]simpletransformers安装和文本分类简单实现

    primeqa 安装requirements时报错

    sublime text下 Python 问题:TabError: inconsistent use of tabs and s...

    uiautomation报错 No module named 'comtypes.stream' Can not load UIA...

    解决无法加载UIAutomationCore.dll的报错

    汉字目标点选识别-ddddocr(返回识别的内容和位置)

    python 常用命令

    opencv报错及解决:AttributeError: module ‘cv2‘ has no attribute ‘...

    AttributeError: module 'cv2.cv2' has no attribute 'cv'

    sublime text常用快捷键及多行列模式批量操作教程

    python配置opencv环境后,读取图片,报错:can‘t open/read file: check f...

    各种服务器通用搭建python训练模型用的环境,以训练SoloSpeech为列子

    Python 学习整理2

    fastapi-speaker-extractor whisperx 项目报错 ValueError: The chosen ...

    python报错 UnicodeEncodeError: 'gbk' codec can't encode character '\u...

    python whisperx 报错 in load_align_model raise ValueError(f'The ch...

    pyannote/embedding 模型是真难引入模型

    Trae 或者是我自己 莫名奇妙创建了个文件,影响了项目代码的运行。

    WhisperX 无法加载模型

    HUGGINGFACE_HUB_CACHE 设置错误导致的问题

    Trae的bug太多了,怪不得免费

    通义之旅

    通义之旅2

    目标说话人声音提取模型训练的思路

    python报错 can't convert cuda:0 device type tensor to numpy. Use Tenso...

    Expected all tensors to be on the same device, but found at least two ...

    腾讯元宝推荐的项目结构(音频处理项目)

    音频处理项目fse

    各种python 相关命令

    python 报错 SyntaxError: 'return' outside function

    python常用命令

    腾讯编程助手

    python一些扩展兼容安装的处理方案

    Shell脚本学习过程中遇到问题整理

    如何检测这种格式知道这个是不合法的CLI参数

    推荐内容

    怎样使用V2Ray代理和SSTap玩如魔兽世界/绝地求生/LOL台服/战地3/黑色沙漠/彩...

    sstap游戏代理教程 从此玩如魔兽世界/绝地求生/LOL台服/战地3/黑色沙漠/彩虹六...

    BT磁力搜索网站汇总和找不到的资源

    什么是磁力链接,您如何使用?

    Z-Library:全球最大的数字图书馆/含打不开的解决方案/镜像

    使用V2Ray的mKCP协议加速游戏

    v2rayN已停止工作

    【车险课堂】什么是无赔款优待系数ncd,你“造”吗?