按照官网示例,测试Tensor访问时,发现全是0,有大神知道怎么回事吗?
import paddle
ndim_2_Tensor = paddle.to_tensor([[0, 1, 2, 3],
[4, 5, 6, 7],
[8, 9, 10, 11]])
print("Origin Tensor:", ndim_2_Tensor.numpy())
print("First row:", ndim_2_Tensor[0].numpy())
print("First row:", ndim_2_Tensor[0, :].numpy())
print("First column:", ndim_2_Tensor[:, 0].numpy())
print("Last column:", ndim_2_Tensor[:, -1].numpy())
print("All element:", ndim_2_Tensor[:].numpy())
print("First row and second column:", ndim_2_Tensor[0, 1].numpy())
结果是:
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
runfile('G:/test/numpTest/Tensor/2d.py', wdir='G:/test/numpTest/Tensor')
Origin Tensor: [[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
W0818 09:16:43.512348 14164 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 3.0, Driver API Version: 10.1, Runtime API Version: 10.1
W0818 09:16:43.512348 14164 gpu_resources.cc:91] device: 0, cuDNN Version: 7.6.
First row: [0 0 0 0]
First row: [0 0 0 0]
First column: [0 0 0]
Last column: [0 0 0]
All element: [[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
First row and second column: [0]
提个issue问问吧
新手刚开始看,请问怎么提
place=paddle.CPUPlace() 指定到cpu结果就正常了
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
runfile('G:/test/numpTest/Tensor/2d.py', wdir='G:/test/numpTest/Tensor')
Origin Tensor: [[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
W0818 09:58:35.198829 8844 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 3.0, Driver API Version: 10.1, Runtime API Version: 10.1
W0818 09:58:35.204830 8844 gpu_resources.cc:91] device: 0, cuDNN Version: 7.6.
First row: [0 1 2 3]
First row: [0 1 2 3]
First column: [0 4 8]
Last column: [ 3 7 11]
All element: [[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
First row and second column: [1]
github上提issue,你是不是装的cpu版本的飞桨啊?
两台电脑,一台安装的gpu版本的,运行不正常,但是加上place=paddle.CPUPlace(),结果正常。另一台电脑装的cpu版本,运行正常。难道是我显卡的问题?但也没有报错