pytorch使用gpu

import cv2

import dlib

import torch as t

if name == ‘main’:
t.cuda.current_device()
t.cuda._initialized = True

x = t.rand(5, 3)

y = t.rand(5, 3)

if t.cuda.is_available():
    x = x.cuda()

    y = y.cuda()

    print(x + y)
发布了172 篇原创文章 · 获赞 52 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/weixin_32759777/article/details/101212760