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,

相关推荐
Zzzz_my4 小时前
正则表达式(RE)
pytorch·python·正则表达式
alex18015 小时前
pytorch LSTM类解析
pytorch·机器学习·lstm
剑穗挂着新流苏3126 小时前
114_PyTorch 进阶:模型保存与读取的两大方式及“陷阱”避坑指南
人工智能·pytorch·深度学习
GoCoding6 小时前
Triton + RISC-V
pytorch·openai·编译器
GoCodingInMyWay7 小时前
Triton + RISC-V
pytorch·riscv·triton
rebekk8 小时前
pytorch custom op的简单介绍
人工智能·pytorch·python
文艺小码农12 小时前
pytorch(GPU版)安装教程
人工智能·pytorch·python
剑穗挂着新流苏31213 小时前
113_站在巨人的肩膀上:PyTorch 经典模型(VGG16)的获取与自定义修改
人工智能·pytorch·python
诶尔法Alpha13 小时前
jetson设备上自己手动编译适配版本的pytorch全过程,及报错的解决方法
pytorch·nvidia·jetson·torchvision
Chen三变15 小时前
Pytorch和Tensorflow两大架构如何安装?想在自己的电脑上跑神经网络?如何找到部署自己电脑版本的神经网络工具?人工智能专业的学生集合!!
人工智能·pytorch·tensorflow