Runtimeerror: numpy is not available solution
Problem Description:
Today, the old computer crashed (cried) and the new computer got started. I couldn’t wait to install the pytorch and check the operation of the previous project. As a result, there was an error running the model training
the key sentence is the sentence loading the model training data
for i, data in enumerate(train_loader):
The bottom layer of this statement is applied to the operation of converting the tensor variable to numpy, that is
import numpy
import torch
test_torch = torch.rand(100,1,28,28)
print(test_torch.numpy())
# will produce the same error
Problem root
The direct correlation between pytoch and tensorflow is ignored
if there is only torch but no tensorflow in the environment, the tensor variable used by torch will lose the tensor related operation function, such as torch. Numpy()
Solution:
Install tensorflow in the basic environment, whether CPU version or GPU version
in Anaconda environment, you can directly
conda install tensorflow
Otherwise pip
pip install --ignore-installed --upgrade tensorflow-gpu
Read More:
- [Solved] Pytorch Tensor to numpy error: RuntimeError: Can‘t call numpy() on Tensor that requires grad.报错
- [Solved] RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the
- [Solved] torchsummary Error: RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.F
- [Solved] RuntimeError : PyTorch was compiled without NumPy support
- Pytorch torch.cuda.FloatTensor Error: RuntimeError: one of the variables needed for gradient computation has…
- For the problem of rejecting old usage errors after numpy is updated, modified in numpy 1.20; for more details and guidance
- [Solved] Tensorflow Error: NameError: name ‘layers‘ is not defined
- Python error collection: NameError: name ‘numpy’ is not defined
- [Solved] Using summary to View network parameters Error: RuntimeError: Input type (torch.cuda.FloatTensor)
- Here is the difference and connection of Torch. View (), Transpose (), and Permute ()
- RuntimeError: Failed to register operator torchvision::_new_empty_tensor_op. +torch&torchversion Version Matching
- [Solved] bert_as_service startup error: Tensorflow 2.1.0 is not tested!
- Python3 Error: Cannot uninstall ‘numpy’. It is a distutils installed project and thus we cannot accurate
- [Solved] Python Error: “RuntimeError: ‘cryptography‘ package is required for sha256_password or caching_sha2_pas”
- [How to Fix]RuntimeError: Python is not installed as a framework, If you are using (Ana)Conda
- [Solved] RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.
- Python: Torch.nn.functional.normalize() Function
- numpy.AxisError: axis 1 is out of bounds for array of dimension 1
- torch.nn.functional.normalize() Function Interpretation
- [Solved] RuntimeError (note: full exception trace is shown but execution is paused at: <module>)