Project scenarios
Recently, I’m learning Python
. First, I installed the following with the CONDA
command provided on the official website:
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
Then test whether the installation is successful and whether it can be used normally according to the method of the official website
import torch
x = torch.rand(5, 3)
print(x)
If the value of x
can be printed normally, it means that it can be used normally, otherwise it is the opposite
Problem description
Error in code operation: importerror: numpy.core.multiarray failed to import
D:\miniconda3\envs\pytorch\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL
initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not
from . import _distributor_init
Traceback (most recent call last):
File "c:/Users/ghgxj/Desktop/pytorch/1_get_started.py", line 1, in <module>
import torch
File "D:\miniconda3\envs\pytorch\lib\site-packages\torch\__init__.py", line 189, in <module>
from torch._C import *
ImportError: numpy.core.multiarray failed to import
Cause analysis
The Python
environment comes with a numpy
, which will conflict with the numpy
version installed with Python
Solutions
Uninstall numpy
first
conda uninstall numpy
reinstall numpy
conda install numpy
The final result
According to the above scheme, the values of x
are printed normally
tensor([[0.8338, 0.1541, 0.0379],
[0.4348, 0.0145, 0.3586],
[0.4098, 0.2363, 0.5405],
[0.7372, 0.7418, 0.3703],
[0.5668, 0.9512, 0.8041]])
Let’s see if GPU
driver and CUDA
can be used:
import torch
print(torch.cuda.is_available())
If the console print shows true
, it means it can be used normally
Similar Posts:
- [Solved] “import numpy as np” ImportError: No module named numpy
- Pycharm introduces numpy error: ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy.
- face_ Face recognition error report
- Pytorch Install Error: OSError: [WinError 126] Could not Find the Module, Error loading “xx\lib\site-packages\torch\lib\asmjit.dl
- [Solved] Importerror: DLL load failed while importing mtrand: the specified program could not be found.
- [Solved] mindspore Error: cannot allocate memory in static TLS block
- [Solved] Tensorflow:ImportError: DLL load failed: The specified module cannot be found Failed to load the native TensorFlow runtime
- Windows Python Install: requires numpy+mkl & ImportError: cannot import name NUMPY_MKL
- [Solved] Error caused by correspondence between tensorflow GPU version number and CUDA
- [Solved] torch.cuda.CudaError: CUDA driver version is insufficient for CUDA runtime version (35) [ WARN:0