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,

相关推荐
言之。10 小时前
Andrej Karpathy 演讲【PyTorch at Tesla】
人工智能·pytorch·python
DKunYu12 小时前
PyTorch入门
人工智能·pytorch·python·深度学习
技术闲聊DD12 小时前
深度学习(8)- PyTorch 数据处理与加载
人工智能·pytorch·深度学习
蓝博AI15 小时前
基于卷积神经网络的香蕉成熟度识别系统,resnet50,vgg16,resnet34【pytorch框架,python代码】
人工智能·pytorch·python·神经网络·cnn
新子y17 小时前
【小白笔记】关于 Python 类、初始化以及 PyTorch 数据处理的问题
pytorch·笔记·python
技术闲聊DD18 小时前
深度学习(13)-PyTorch 数据转换
人工智能·pytorch·深度学习
少林and叔叔18 小时前
人工智能Pytorch开发环境的搭建
人工智能·pytorch·python·pycharm·conda
电棍23318 小时前
工程实践心得记录-pytorch要安装在哪里
人工智能·pytorch·python
星期天要睡觉18 小时前
深度学习——基于 PyTorch 的蔬菜图像分类
人工智能·pytorch·python·深度学习·分类
IT_Octopus1 天前
triton backend 模式docker 部署 pytorch gpu模型 镜像选择
pytorch·docker·triton·模型推理