|-转 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
相关内容
推荐内容