I installed Pytorch for PYthon 3.6 using pip as instructed on https://pytorch.org/.
Pytorch is installed succesfully, but when I run code, I get this:
File "C:\Users\\PycharmProjects\chatbot-light\pytorch\rnn_attention\seq2seq_translation_tutorial.py", line 93, in <module>
import torch
File "C:\Users\\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\__init__.py", line 78, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found
Pytorch devs recommend installing Pytorch using Anaconda.
Since Anaconda deals with all the dependencies you shouldn't have any DLL-related problems after installing Pytorch with it.
Go https://anaconda.org/anaconda/intel-openmp/files
Download win-64/intel-openmp-2018.0.3-0.tar.bz2
Extract files under its Library/bin/ to any directory
Add the directory in Step 3 to your PATH environment
Restart
This solved ImportError on my computer with Windows 10 + Python 3.6.6 + PyTorch 0.4.0.
Hope it helps.
This is an open Windows-related issue, see https://github.com/pytorch/pytorch/issues/4518 .
As a work-around, I installed SUSE Linux in a VirtualBox on Win10, then used the Linux pip instructions on PyTorch.org. No import error. BTW, the MS Visual Studio Code editor can be installed in Linux if you go that route.
I remember getting an import error (I think it was the same error you show) when I installed Pytorch with CUDA.
Installing Pytorch without CUDA made the error go away.
conda install pytorch-cpu -c pytorch
pip3 install torchvision
The upshot is that you can only run it on your CPU, not a GPU, which is an issue if you're already dealing with complex models and huge datasets, but shouldn't matter too much if you're just starting to tinker with Pytorch.
Related
I have been encountering this message after trying to import numpy, pandas, matplotlib, and seaborn all by themselves. I am not sure how to fix this. Any suggestions?
I am using Python 3.8.8, matplotlib 3.3.4, pandas 1.2.4, numpy 1.20.1, seaborn 0.11.1.
I have recently updated my Anaconda navigator to 2.1.0. Would this possibly have caused any issues?
In the shell command, after trying to import each of those packages individually, I see this message:
Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.1.dylib.
Solution: I reinstalled Anaconda Navigator.
If you using window 10 or 11, you can follow these steps for activating tensorflow and GPU CUDA in pycharm globally and handle that error:
Uninstall tensorflow and tensorflow-gpu (if using GPU) and reinstall again tensorflow and tensorflow-gpu:
pip tensorflow
pip tensorflow-gpu
Download and install CUDA (https://developer.nvidia.com/cuda-downloads) and cuDNN (https://developer.nvidia.com/cudnn) if you have never downloaded before.
Unzip cuDNN zip folder and copy all files that in bin, include and lib folder to folder Nvidia GPU Computing Toolkit (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7)
Check GPU available in terminal using:
import tensorflow as tf
tf.test.is_gpu_available()
Run file python with pycharm and if show this error:
the kernel for appears to have died. It will restart automatically.
Don't panic, follow this next steps.
Download zlibwapi.dll. zlibwapi will help to read cudnn from path running on local environment so we can use that globally. Download from this link: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-zlib-windows
Right click on zlibwapi -> save link as -> and download the zip file of ZLIB DLL.
Unzip that file, and you can find zlibwapi.dll inside of folder dll_x64.
copied zlibwapi.dll to C:\Windows\System32 and C:\Windows\SysWOW64
Running again python file in pycharm that using CNN or ImageDataGenerator API from tensorflow, and see how it work.
In my case, this is work on my laptop. I hope this will help you.
Recently, I want to run some pytorch codes on centos6. However, no matter I perform either "pip install torch" or "conda install torch", the prompt shows:
>>> import torch
Traceback (most recent call last):
File "", line 1, in
File "XXX/anaconda3/envs/XXX/lib/python3.6/site-packages/torch/init.py", line 56, in
from torch._C import *
ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by XXX/anaconda3/envs/XXX/lib/python3.6/site-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so)
My enviroment:
OS: CentOS release 6.7
How you installed PyTorch (conda, pip, source): pip & conda
Python version: 3.6.5
I tried mannually compiling glibc-2.19, but when I put the library path into LD_LIBRARY_PATH, I can't use commands like "ls", "make", etc. And I got "segment fault". I also tried just copying the *.so to the lib directory under the python virtual environment, no wonder, python crashed with "segment fault". I understand plenty of components rely on a specific glibc library. I just wonder how I can run pytorch on centos6 without switching to a new linux distribution.
PS: I need to deploy such python environments on the product environment, whose OS is centos6.
It's a tough one. You can either downgrade to a very old version of torch ( v0.3.1 as I remember was running ok on Centos 6.5 ), or upgrade to Centos 7. Having 2 version of glibc is hell.
If you really need Centos 6 to live with the latest version of torch, try installing glibc into non standard location and compiling both Python and pytorch from source.
update
You can't replace system's glibc and but you can install it somewhere else, like /opt/myglibc.
Pytorch stopped supporting Centos 6 since v0.4.1. So you will have to build it using gcc v5+ and linking it to your glibc version. Here are the instructions. But since you don't invoke pytorch directly, you need to build Python also. Then you can run your program by setting glibc path specifically for your program.
LD_LIBRARY_PATH=/opt/myglibc python my_program.py
my python version is 3.7.5.
In vscode, I created my virtual environment
python -m venv myProj
Then I switch my python interpreter to: python3.7.5 64bit ('myProj':venv)
I install tensorflow as below:
pip install tensorflow
I can see tensorflow appear in the myProj/lib-sitePackages
Then I tried to run python file in which there is one line 'import tensorflow'
The prompt became like below:
(myProj) C:\Users\xxx\Documents\My_Document\myname\myProj>
I got error like below:
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.........
Interestingly, when I did pip install tensorflow outside of virtual environment, I was able to run python3.7.5 and import tensorflow.
I spend hours try this and that. But got no success.
Do anyone know why it happens?
Run tensorflow in anaconda.
Delete and unistall all existing python software and download anaconda.then view tutorials of how to install tensorflow and keras in anaconda. It takes about 20 mins with goodnet speed.
I used to get the same dll error load module not found error when tried without anaconda.these are compatibility issues
when i import mxnet using import mxnet as mx in intellij (python) then compier generate error
OSError: [WinError 126] The specified module could not be found"
and shows trackcall shows
line 1 "import mxnet as mx" in test.python
mxnet already in env/lib
You might be having PyCharm configuration issues, so I recommend you check things from the command line first. Open up a command prompt and activate the virtual env using \path\to\env\Scripts\activate. Confirm that MXNet has been installed in this environment by listing the pip packages with pip list and looking for mxnet. Use pip install mxnet if you don't see it in the list of installed packages. Now run a Python interpreter with python and try import mxnet.
If this works, you now need to ensure that PyCharm is using the correct Python environment, as there maybe multiple environments installed on the system. And instructions can be found here.
I had the same problem.
Pip did not download correct version of MXnet for my version of CUDA (10.2).
The DLL which is not found is for the CUDA version for which MXNet was downloaded.
I solved the problem by accessing the repository and directly downloading the correct package.
In my case it was mxnet_cu102mkl-2.0.0b20200504-py2.py3-none-win_amd64.whl.
It worked normally after this.
I am trying to install Keras with Tensorflow. I have followed all steps from
here
I have installed CUDA 9 . cuDNN 7.i had problems intalling it with command provided on the site so i used
python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
which i have found here on SO. Installation went fine, however when i tried test script ( provided on the tensorflow site ) i recieved error:
No module named '_pywrap_tensorflow
I have tried to check SO for answer but found nothing usefull, how can fix this?
thanks for help.
Regarding your issues you are installing cpu only and old MAC version of tensorflow which shouldn't work on windows.
You could try using the following command
python3 -m pip install https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl
But I suggest you use Anaconda for the windows to install tensorflow and keras it has much less errors on windows, you can find a guide for it here https://github.com/antoniosehk/keras-tensorflow-windows-installation.