AttributeError: 'Tensor' object has no attribute 'numpy'
LiuYuLOL opened this issue · 1 comments
Hi,
When I run the code, an error occurred as below. The TensorFlow version is 2.3.1, and memory is 60 GBs. As the work does not use GPUs, I think the failure of loading a GPU library may not be related.
Could you help me check it (error occurs at line 304 of ``alinet.py'')?
Cheers,
Getting AliNet model...
2020-10-05 13:03:26.566125: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-10-05 13:03:26.644590: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:3b:00.0 name: GeForce RTX 2080 Ti computeCapability: 7.5
coreClock: 1.545GHz coreCount: 68 deviceMemorySize: 10.73GiB deviceMemoryBandwidth: 573.69GiB/s
2020-10-05 13:03:26.645612: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 1 with properties:
pciBusID: 0000:af:00.0 name: GeForce RTX 2080 Ti computeCapability: 7.5
coreClock: 1.545GHz coreCount: 68 deviceMemorySize: 10.73GiB deviceMemoryBandwidth: 573.69GiB/s
2020-10-05 13:03:26.648167: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 2 with properties:
pciBusID: 0000:d8:00.0 name: GeForce RTX 2080 Ti computeCapability: 7.5
coreClock: 1.545GHz coreCount: 68 deviceMemorySize: 10.73GiB deviceMemoryBandwidth: 573.69GiB/s
2020-10-05 13:03:26.648240: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-10-05 13:03:26.650992: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-10-05 13:03:26.652471: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2020-10-05 13:03:26.652902: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2020-10-05 13:03:26.654970: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2020-10-05 13:03:26.656429: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2020-10-05 13:03:26.656771: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory
2020-10-05 13:03:26.656838: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2020-10-05 13:03:26.657666: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-10-05 13:03:26.707577: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 3400000000 Hz
2020-10-05 13:03:26.721101: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5611a002ffd0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-05 13:03:26.721315: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2020-10-05 13:03:26.724715: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-10-05 13:03:26.724866: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]
Traceback (most recent call last):
File "/home/uqyliu42/workspace/pycharm/AliNet/code/main.py", line 60, in
gcn_model.train(args.batch_size, max_epochs=args.max_epoch, start_valid=args.start_valid, eval_freq=args.eval_freq)
File "/home/uqyliu42/workspace/pycharm/AliNet/code/alinet.py", line 304, in train
grads = tape.gradient(batch_loss, self.model.trainable_variables)
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/eager/backprop.py", line 1073, in gradient
unconnected_gradients=unconnected_gradients)
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/eager/imperative_grad.py", line 77, in imperative_grad
compat.as_str(unconnected_gradients.value))
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/eager/backprop.py", line 162, in _gradient_function
return grad_fn(mock_op, *out_grads)
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/ops/math_grad.py", line 212, in _SumGrad
op.inputs[1])
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py", line 3904, in reduced_shape
input_shape = input_shape.numpy()
AttributeError: 'Tensor' object has no attribute 'numpy'
Update: downgrade from tf2.3 to tf2.1 solved the issue.