6
运行时
Pytorch 兼容问题
2025-09-29 09:18:42
138

import torch

print(f"PyTorch版本: {torch.__version__}")

print(f"DCU可用: {torch.cuda.is_available()}")

if torch.cuda.is_available():

   # 测试基础张量操作

   a = torch.randn(1000, 1000).cuda()

   b = torch.randn(1000, 1000).cuda()

   print("张量创建成功")

   

   # 逐步骤测试

   c = a + b  # 先测试简单操作

   print("加法操作成功")

   

   c = torch.matmul(a, b)  # 再测试矩阵乘法

   print("矩阵乘法成功")

   

   print("✅ 所有测试通过!")

#   python test.py


上述代码报错:

(dcu_env) [root@r5330 workspace]# python test.py

PyTorch版本: 2.1.0a0

DCU可用: True

张量创建成功

Traceback (most recent call last):

 File "test.py", line 12, in <module>

   c = a + b  # 先测试简单操作

RuntimeError: HIP error: invalid device function

HIP kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.

For debugging consider passing HIP_LAUNCH_BLOCKING=1.

Compile with `TORCH_USE_HIP_DSA` to enable device-side assertions.

全部评论(5)
只看楼主
A
ANYA
1楼
麻烦老师说一下您使用的DCU型号以及使用的DTK和DAS版本或者给出您使用的容器链接
2025/9/29
F
future
回复 @ANYA
您好我用的容器镜像链接是这个https://sourcefind.cn/#/image/dcu/pytorch?activeName=overview;DCU型号是​ ​K100_AI;
2025/9/29
W
wangwei
回复 @future
建议直接拉取最新的基于DTK25041的torch镜像,比如:docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.4.1-ubuntu22.04-dtk25.04.1-py3.10
2025/9/29
F
future
回复 @wangwei
好的感谢,我试一试
2025/9/29
全部4条回复
没有更多内容了
--
楼主
Level.1
0 帖子
楼主热帖
暂无数据