下面的命令可以帮助我们查看Pytorch是否使用GPU

# 返回当前设备索引
torch.cuda.current_device()
    # 返回GPU的数量
    torch.cuda.device_count()
    
      # 返回gpu名字,设备索引默认从0开始
      torch.cuda.get_device_name(0)
      
        # cuda是否可用
        torch.cuda.is_available()
        

          我的结果是:

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Bj0dLYom-1609642835880)(C:\Users\Administrator\Desktop\查看pytorch是否使用GPU.png)]

          转载自:https://blog.csdn.net/weixin_43593330/article/details/112132428

          Logo

          昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链

          更多推荐