I am trying to work with tensorflow, but the DNNClassifier (and the other estimators) are not available from tf.estimator.
I am running Python 3.6 within Anaconda on Windows 10. I used conda install tensorflow to load and import tensorflow as tf to import the package.
When I try to use DNNClassifier, I get the error message:
AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'DNNClassifier'
Have any others had this problem?
Install using pip. Install the CPU version unless you have an nvidia GPU.
Related
I'm having some basic issues running the torch and cuda modules in my Python script.
I think that this has something to do with the different versions of Python that I have installed. I have two versions of Python installed:
I think I have torch and cuda installed for the wrong one or something. I don't know how to fix this.
Per the Pytorch website, I installed torch as follows:
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
I've installed cuda as follows: pip3 install cuda-python==11.7 (It doesn't matter if I use the newest version -- I still get the same results.)
When I look up the versions, I get the following:
So it seems like it is all installed correctly.
However, if I run the following:
import torch
print(torch.cuda.is_available())
I get False.
If I try to run my code that uses torch, I get the following error:
I don't get what I'm doing wrong. As far as I can tell, I've installed torch with CUDA enabled. So I'm not sure why it's telling me otherwise.
Any ideas? Thanks for any help.
Edit: Here is the info for my GPU:
The issue had to do with the different versions of Python. I ended up using a Conda virtual environment, which solved this issue by ensuring I was using the correct version of Pytorch.
I'm using anaconda ver 3, and I have installed python as well separately from anaconda. I installed python ver 2.7 and ver 3.6 from python website.
Now, I have installed keras from anaconda command prompt by using conda install keras. However, when I open jupyter notebook and write :
import keras
it says :
no module named keras
I also tried importing tensorflow but it gave me the same error
As far as i know, keras is a version of tensorflow. You should try installing tensorflow instead and then run
import tensorflow as tf
tf.__version__
if you get '2.1.0' or any 2., you should be all set!
EDIT1: Keras is part of tensorflow not a version (as pointed out in the comments).
EDIT2: The link below gives good details on environments activation/creation.
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
Okay so what I did is first updated anaconda by using :
conda update conda
and then I installed python :
conda install python=3.7
and finally I installed keras again :
conda install keras
And now I can import both packages of keras and tenserflow
i'm trying to generate seed using TensorFlow 2.1 but this error appears module 'TensorFlow' has no attribute 'random'
I suspect that you think you're using TensorFlow 2.0 but actually, it is a previous version of tensorflow.
It's easy to check:
import tensorflow as tf
print(tf.__version__)
This should produce output like this:
2.1.0
If not, you know you have the wrong TensorFlow version installed.
It's also possible that you have multiple versions of python installed. For example:
Python 3.6 might be installed with TensorFlow 1.x, and
Python 3.7 might be installed with TensorFlow 2.x.
In this case, just be careful that the version of Python being used by Jupyter Notebook is the version of Python with TensorFlow 2.x installed.
just want to make sure
run this command then restart the runtime pip install --upgrade tensorflow
and then try that code again
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.
On Windows 10 with CUDA 8 and CuDNN 7 installed, I have troubles installing Tensorflow (both the GPU and CPU edition, though I'll focus on the GPU version).
When trying to install it system-wide with python3.5 using pip install tensorflow-gpu, it reports that there are no matching packages.
If I instead install it using the community supported anaconda distribution (using the steps described at the documentation page, it correctly installs Tensorflow, but when I import it into a program the following error is shown:
>>> import tensorflow as tf
[...]
ImportError: DLL load failed: The specified module could not be found.
[...]
ImportError: No module named '_pywrap_tensorflow_internal'
[...]
Failed to load the native TensorFlow runtime.
Entire stack trace is available on paste-bin.
For CUDA, I've set the following system environment variables: CUDA_HOME, CUDA_PATH, and CUDA_PATH_V8_0 as suggested by various tutorials. Furthermore cuDNN has been installed using nVidia's instructions, and path variables have been set to CUDA\v8.0\bin, and CUDA\v8.0\libnvvp.
It's probably because Tensorflow now only supports cuDNN v6.0 or v6.1, at least is what's maintained in the Installation Guide for Windows.
I had the same problem, but after updating Tensorflow from an old version to a newer one where the cuDNN had to be updated.