tensorflow 测试 cuda 是否安装成功,测试代码环境
生活随笔
收集整理的這篇文章主要介紹了
tensorflow 测试 cuda 是否安装成功,测试代码环境
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?tensorflow
import tensorflow as tftf.test.is_gpu_available() # 或者 sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))torch
import torch flag = torch.cuda.is_available() print(flag)gpunumber = 1 # Decide which device we want to run on device = torch.device("cuda:0" if (torch.cuda.is_available() and gpunumber > 0) else "cpu") print(device) print(torch.cuda.get_device_name(0)) print(torch.rand(3,3).cuda())總結(jié)
以上是生活随笔為你收集整理的tensorflow 测试 cuda 是否安装成功,测试代码环境的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Python根据原图解析拍摄地点
- 下一篇: python 计算 IOU