您的位置:首页 > 教育 > 培训 > 专业网站设计制作优化排名_深建工程建设集团_北京seo费用是多少_网站推广优化教程

专业网站设计制作优化排名_深建工程建设集团_北京seo费用是多少_网站推广优化教程

2025/9/24 7:06:54 来源:https://blog.csdn.net/chengyq116/article/details/144301314  浏览:    关键词:专业网站设计制作优化排名_深建工程建设集团_北京seo费用是多少_网站推广优化教程
专业网站设计制作优化排名_深建工程建设集团_北京seo费用是多少_网站推广优化教程

PyTorch torch.cuda.is_available

  • 1. `torch.cuda.is_available`
  • 2. Example
  • 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

torch.cuda.is_available()

Return a bool indicating if CUDA is currently available.

  • Return type

bool

2. Example

https://github.com/karpathy/llama2.c/blob/master/sample.py

import torchdevice = '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.autocastprint("device =", device)
print("device_type =", device_type)
/home/yongqiang/miniconda3/bin/python /home/yongqiang/llm_work/llama2.c/yongqiang.py 
device = cpu
device_type = cpuProcess finished with exit code 0

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com