PyTorch torch.cuda.is_available()

PyTorch torch.cuda.is_available{}

  • [1. `torch.cuda.is_available()`](#1. torch.cuda.is_available())
  • [2. `torch.cuda.is_available()`](#2. torch.cuda.is_available())
  • References

PyTorch documentation
https://pytorch.org/docs/master/index.html

PyTorch is an optimized tensor library for deep learning using GPUs and CPUs.

  • torch.cuda.is_available (Python function, in torch.cuda.is_available)

1. torch.cuda.is_available()

https://pytorch.org/docs/stable/generated/torch.cuda.is_available.html

Return a bool indicating if CUDA is currently available.

Return type

bool

2. torch.cuda.is_available()

复制代码
import torch

device = 'cuda' if torch.cuda.is_available() else 'cpu'  # examples: 'cpu', 'cuda', 'cuda:0', 'cuda:1', etc.
device_type = 'cuda' if 'cuda' in device else 'cpu'  # for later use in torch.autocast

print("device =", device)
print("device_type =", device_type)

/home/yongqiang/miniconda3/bin/python /home/yongqiang/llm_work/llama2.c/yongqiang.py 
device = cpu
device_type = cpu

Process finished with exit code 0

References

1\] Yongqiang Cheng,

相关推荐
猫天意14 小时前
【深度学习小课堂】| torch | 升维打击还是原位拼接?深度解码 PyTorch 中 stack 与 cat 的几何奥义
开发语言·人工智能·pytorch·深度学习·神经网络·yolo·机器学习
囊中之锥.16 小时前
《从零到实战:基于 PyTorch 的手写数字识别完整流程解析》
人工智能·pytorch·python
不如语冰19 小时前
AI大模型入门1.3-python基础-类
人工智能·pytorch·python·类和方法
知乎的哥廷根数学学派21 小时前
基于物理引导和不确定性量化的轻量化神经网络机械退化预测算法(Python)
人工智能·pytorch·python·深度学习·神经网络·算法·机器学习
koo36421 小时前
pytorch深度学习笔记17
pytorch·笔记·深度学习
梨子串桃子_1 天前
推荐系统学习笔记 | PyTorch学习笔记
pytorch·笔记·python·学习·算法
xwill*2 天前
python 格式化输出详解(占位符:%、format、f表达式
开发语言·pytorch·python·深度学习
知乎的哥廷根数学学派2 天前
基于卷积特征提取和液态神经网络的航空发动机剩余使用寿命预测算法(python)
人工智能·pytorch·python·深度学习·神经网络·算法
小码hh3 天前
【PonitNet++】1. 从数据到方法:点云技术核心知识全景梳理
人工智能·pytorch·python
岑梓铭3 天前
(YOLO前置知识点)神经网络、Pytorch、卷积神经网络CNN
人工智能·pytorch·笔记·深度学习·神经网络·yolo·计算机视觉