Expected all tensors to be on the same device, but found at least two devices

Expected all tensors to be on the same device, but found at least two devices,

原因是计算的过程中,两个不同类型的变量在一起进行运算,即一个变量存储在gpu中,一个变量存储在cpu中,两个变量的存储位置冲突,导致无法计算,把变量统一下就行

python 复制代码
    x = x + kp_x_ofst
    y = y + kp_y_ofst
    x = torch.reshape(x, [-1])  
    y = torch.reshape(y, [-1])
    
    x = x.to('cpu')
    y = y.to('cpu')
 
    x0 = torch.floor(x).to(torch.int32)
    x1 = x0 + 1
    y0 = torch.floor(y).to(torch.int32)
    y1 = y0 + 1
    # device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    x0 = torch.clamp(x0, zero, max_x)
    x1 = torch.clamp(x1, zero, max_x)
    y0 = torch.clamp(y0, zero, max_y)
    y1 = torch.clamp(y1, zero, max_y)
相关推荐
小程故事多_807 小时前
Agent+Milvus,告别静态知识库,打造具备动态记忆的智能AI助手
人工智能·深度学习·ai编程·milvus
m0_488913018 小时前
万字长文带你梳理Llama开源家族:从Llama-1到Llama-3,看这一篇就够了!
人工智能·学习·机器学习·大模型·产品经理·llama·uml
哥布林学者9 小时前
深度学习进阶(八)Swin Transformer
机器学习·ai
YoseZang9 小时前
【机器学习】【手工】Streaming Machine Learning 流数据学习 – 应对变化的机器学习方法(一)
人工智能·学习·机器学习
生命是有光的11 小时前
【深度学习】卷积神经网络CNN
人工智能·深度学习·cnn
henrylin999912 小时前
Hermes Agent 核心运行系统调用流程--源码分析
开发语言·人工智能·python·机器学习·hermesagent
泰恒12 小时前
国内外大模型的区别与差距
人工智能·深度学习·yolo·机器学习·计算机视觉
zs宝来了12 小时前
LangChain RAG 架构:向量检索与生成流水线
机器学习·ai·基础设施
沅_Yuan12 小时前
基于LSTM神经网络的锂电池SOH估算模型(NASA数据集)【MATLAB】
神经网络·机器学习·matlab·锂电池·nasa·soh
加勒比海带6613 小时前
目标检测算法——低空智能实验室开放数据集汇总附下载链接【点赞+收藏】
大数据·图像处理·人工智能·python·深度学习·目标检测·计算机视觉