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.

暂无数据