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:

- Python: Torch.nn.functional.normalize() Function
- [Solved] Pytorch-transformers Error: AttributeError: ‘str‘ object has no attribute ‘shape‘
- torch.nn.functional.normalize() Function Interpretation
- [Solved] Python Error: An attempt has been made to start a new process before the current process has finished …
- Error:output with shape [1, 224, 224] doesn‘t match the broadcast shape [3, 224, 224]
- [Solved] Pytorch Tensor to numpy error: RuntimeError: Can‘t call numpy() on Tensor that requires grad.报错
- [Solved] Pyg load dataset Error: attributeerror [pytorch geometry]
- [Solved] ValueError: only one element tensors can be converted to Python scalars
- [Solved] RuntimeError : PyTorch was compiled without NumPy support
- [Solved] RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the
- How to Solve Pytorch DataLoader Loading Error: UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xe5 in position 1023
- ModuleNotFoundError: No module named ‘tensorflow.python’ And the pits encountered after installation
- [ONNXRuntimeError] : 10 : INVALID_Graph loading model error
- Tensorflow: Common Usage of tf.get_variable_scope()
- The lenet model trained by Python failed to predict its own handwritten pictures
- Python: RNN principle realized by numpy
- Normalize error: TypeError: Input tensor should be a float tensor…
- Pytorch Error: runtimeerror: expected scalar type double but found float
- RuntimeError: CUDA error: an illegal memory access was encountered
- [Solved] RuntimeError: scatter(): Expected dtype int64 for index