I want to use Tensorflow on GPU. So I install all the needed tool and installed as below-
CUDA-11.2
CUDNN-11.1
Anaconda-2020.11
Tensorflow-GPU-2.3.0
I tested that my cuda,cudnn is working using deviseQuery example.
But Tensorflow not used GPU. Then i find that version compatibility issue is possible so i innstalled CudaToolkit,cudnn using conda environment checking with version compatibility on Tensorflow website which is given below.
CUDA-10.2.89
CUDNN-7.6.5
Tensorflow-GPU-2.3.0
But after this try Tensorflow-GPU not used GPU,yet. so what i am doing now? Any steps or suggestion require.
The installation engine has a problem for tensorflow-gpu 2.3 in Anaconda on Windows 10.
Workaround is to explicitly specify the correct tensorflow build:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
Related
I'm trying to use tensorflow with my PC's GPU (Nvidia RTX 3070Ti) in python-conda environment. I'm solving a small image-classification problem from kaggle. I've solved it in google-collab, but now I'm intrested in solving it on my local machine. However TF doesn't work properly locally and I have no idea why. I've read tons of solutions but it didn't help yet.
I'm following this guide and always install proper versions of TF and CUDA: https://www.tensorflow.org/install/source_windows
cuda-toolkit 10.1, cudnn 7.6, tf-gpu 2.3, python 3.8
Also I've installed latest NVidia drivers for videocard.
What I've tried:
I've installed proper version CUDA-toolkit and CUDnn from nvidia site. I've installed it properly and included everything that was needed into PATH. I've checked it - MS Visiual Studio finds both CUDA and CUDnn and can work with it. I've installed proper version of Tensorflow-GPU using conda into my environment.
Result: TF can't find my GPU and uses only CPU.
I've removed all CUDA and CUDAnn drivers. I've installed CUDA-toolkit, CUDnn and Tensorflow-GPU python packages into my conda environment.
Result: TF recognizes my GPU and uses it! But during DNN training happens error: Failed to launch ptxas Relying on driver to perform ptx compilation. Modify $PATH to customize ptxas location. And training goes very bad - accuracy is very low and doesn't improving.
When I use absolutely same code and data on google-collab, everything is going smoothly - I get ~90% accuracy on 5th epoch.
I've tried tf 2.1 and relevant cuda and cudnn, but it's still same result!
I've tried to install cudatoolkit-dev, but it didn't help to solve ptxas problem.
I'm about to give up and use PyTorch instead of Tensorflow.
So here is what worked for me:
Create 3.9 python environment
Install cuda and tensorflow packages from "Esri":
conda install -c esri cudatoolkit
conda install -c esri cudnn
conda install -c esri tensorflow-gpu
Then install tensorflow-hub:
conda install -c conda-forge tensorflow-hub
It will downgrade installations from previous steps, but it works. Maybe installing tensorflow-hub first could help to avoid it, but I didn't test it.
I want to run the project using Anaconda, TensorFlow 2.3, Keras 2.4.3 (CNN example). OS Windows 10.
I installed Visual Studio 2019 Community Edition, CUDA 10.1 and cudnn 8.0.5 for CUDA 10.1.
Using Anaconda I created an environment with TensorFlow (tensorflow-gpu didn't help), Keras, matplotlib, scikit-learn. I tried to run it on CPU but it takes a lot of time (20 minutes for just 1 epoch when there are 35).
I need to run it using GPU, but TensorFlow doesn't see my GPU device (GeForce GTX 1060). Can someone help me find the problem? I tried to solve the problem using this guide tensorflow but it didn't help me.
This works 100%, no need to install anything manually (cuda for example)
conda create --name tf_gpu tensorflow-gpu
Ok so I tried to install all the components into new anaconda environment. But instead of "conda install tensorflow-gpu" I decided to write "pip install tensorflow-gpu" and now it works via GPU...
Just a heads up, the Cudnn version you were trying to use was incompatible.
Listing Versions and compatible CUDA+Cudnn
You can go here and then scroll down to the bottom to see what versions of CUDA and Cudnn were used to build TensorFlow.
Anaconda has different packages for Tensorflow with and without GPU support.
In particular, to install Tensorflow with GPU, you should run:
conda install tensorflow-gpu
While for the non-GPU version, you should install:
conda install tensorflow
By checking the version of the installed package, conda installs Tensorflow version 2.1.
But as of today the latest version of Tensorflow is 2.3. Furthermore, as can be seen in the Tensorflow officla documentation, the latest version can be installed with
pip install tensorflow
This package is said in the documentation to be good both for CPU and GPU versions of Tensorflow. Moreover, the documentation states that the packages for CPU and GPU were different for "for releases 1.15 and older".
Why Anaconda provides 2.1 in two different packages, given that the package should be the same for any version > 1.15?
Which one should I install, the pip version or the conda version? An article in Anaconda blog specifies that the version provided with conda is faster, but the article is old (2018) and refers to an old version of Tensorflow (1.10)
By checking the version of the installed package, conda installs Tensorflow version 2.1.
But as of today the latest version of Tensorflow is 2.3. Furthermore
That is only because you are (probably?) on windows. As you can see here tensorflow is available as 2.3 from conda default channels, but currently only on linux.
The reason is also stated on the website you have linked (emphasis mine):
Anaconda is proud of our efforts to deliver a simpler, faster experience using the excellent TensorFlow library. It takes significant time and effort to add support for the many platforms used in production, and to ensure that the accelerated code is still stable and mathematically correct. As a result, our TensorFlow packages may not be available concurrently with the official TensorFlow wheels. We are, however, committed to maintaining our TensorFlow packages, and work to have updates available as soon as we can.
In short: The Anaconda team is creating custom builds of tf against the intel mkl library to speed up calculations on the CPU. Earlier on the same website they also mention that they create builds for different cuda versions.
Why Anaconda provides 2.1 in two different packages, given that the package should be the same for any version > 1.15?
The tensorflow-gpu package is only a meta-package, i.e. it is only used to install a different build of tensorflow with different dependencies (also enabling you to install for different cuda versions). The official releases only allow for combinations of tensorflow version and cuda.
Which one should I install, the pip version or the conda version? An article in Anaconda blog specifies that the version provided with conda is faster, but the article is old (2018) and refers to an old version of Tensorflow (1.10)
Reading said article, the speed up is linked to building against the intel mkl library, which speeds up calculations on the CPU. Given that for your setup, you can only get tensorflow 2.1 installed when using conda, you will need to ask yourself if you rely on the newest tensorflow version and if you don't need the accelerated cpu code. There is usually nothing wrong with installing the newest tensorflow using pip. Just make sure that you create a new environment for said tensorflow version and only install/update tensorflow or any of its dependencies using pip in that environment. There is general advice to not mix conda and pip installations too much, since one could break the other (since they are using different ways to resolve dependencies), but you should be fine when using a seperate env
If you are using Anaconda then you can use conda to install tensorflow. For the cpu version enter
conda install tensorflow
for the gpu version enter
conda install tensorflow-gpu.
If you are using Windows it will install version 2.1.0, the cuda toolkit version 10.1.243 and cudnn version 7.6.5. Note conda can only install tensorflow up to version 2.1.0 on Windows operating system. If you want tensorflow 2.2.0 or 2.3.0 install it with pip using pip after you have installed 2.1. The cuda toolkit and cudnn work with version 2.2 and 2.3. One other thing. Use python3.7 not 3.8. Apparently when you install tensorflow with conda it will not work with 3.8.
If you use pip to install tensorflow 2.1 or higher it includes both the cpu and gpu versions however you have to go through a manual processes to install the Cuda Toolkit and cudnn. This includes downloading the files from NVIDIA . You also have to change your PATH environmental variable.
Tensorflow version for Python 3.7
Any news about tensorflow update for python 3.7. When I try to install tensorflow inside my venv like:
pip install tensorflow
I got an error:
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
Python 3.7 is now supported officially in TensorFlow 1.13.1:
Major Features and Improvements
TensorFlow Lite has moved from contrib to core. This means that
Python modules are under tf.lite and source code is now under
tensorflow/lite rather than tensorflow/contrib/lite.
TensorFlow GPU binaries are now built against CUDA 10 and TensorRT 5.0.
Support for Python3.7 on all operating systems.
Moved NCCL to core.
source
You can see the status of the move to 3.7 here: https://github.com/tensorflow/tensorflow/issues/20517
Firstly, you should download and set up the anaconda via anaconda and then open anaconda prompt and then follow these steps via TensorFlow. Fourthly, you should use 'pip install --ignore-installed --upgrade tensorflow==1.14.0' to install TensorFlow 1.14 on Conda Finally, you can use TensorFlow that is version 1.14 on python 3.7
Have a Great Time.
You need to install a 64-bit version of Python and 3.7 does not work with tensorflow right now, I suggest a downgrade to 3.6.x
I tried many versions of the tensorflow with python 3.7 and failed. But finally tensorflow version 1.14 worked.
I was having the same problem as you- I was using Python 3.7 32-bit on Windows 10 64-bit machine.
Since TensorFlow doesn't support 32-bit Python hence it said that "No matching distribution found for TensorFlow".
What worked for me is that I uninstalled the 32-bit Python version and installed the 64-bit Python version and pip install tensorflow worked immediately for downloading TensorFlow 2.2.0. Note that TensorFlow now supports till Python 3.8.
Check if you have the 32-bit version of Python. To check whether you have the 32-bit version or 64-bit version, type IDLE in the search bar and you will be able to tell which version it is.
Currently, for Windows users,
pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.1.0-cp37-cp37m-win_amd64.whl
works with python_3.7(64-bit) and at least pip 19.0
This is my first question on stackoverflow, please bear with me as I will do my best to provide as much info as possible.
I have a windows 10, 6-bit processor. My end goal is to use keras within spyder. The first thing I did was update python to 3.6 and install tensorflow, which seemed to work. When I attempted to get keras, however, it wasn't working, and I read that keras worked on python 3.5. I successfully installed keras on python 3.5, which automatically installed theano as the backend.
But now I have two spyder environments, one running off of python 3.5, one off of 3.6. The 3.5 reads keras but doesn't go through with any modules because it cannot find tensorflow. The 3.6 can read tensorflow, but cannot find keras.
Please let me know what you would recommend. Thank you!
Create a virtualenv with python 3.5 installed.
I dealt with this same issue, using Jupyter Notebook. Didn't understand why you would even need a virtualenv until I learned from this roadblock.
Full details on installing and setting up a virtualenv can be found here:
http://pymote.readthedocs.io/en/latest/install/windows_virtualenv.html
Odd, the installation instructions say that TF only supports Python 3.5 on Windows. I would uninstall TF with pip uninstall tensorflow (if you installed it with pip to begin with) using pip from your Python 3.6 path, then re-install (pip install --upgrade tensorflow) making sure that you are running pip from your Python 3.5 path.
I had some issues with my tensorflow's installation too.
I personnaly used anaconda to solve the problem.
After installing anaconda (Maybe uninstall the old one if you already have one), launch an anaconda prompt and input conda create -n tensorflow python=3.5, afther that, you must activate it with activate tensorflow.
Once it's done, you have to install tensorflow on your python 3.5.
For that, use:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.0rc1-cp35-cp35m-win_amd64.whl
for cpu version
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.0rc1-cp35-cp35m-win_amd64.whl for gpu version
You now have the r1.2 version of tensorflow.
Then, just use pip install keras and keras will be installed.
Now, all you have to do is launch anaconda navigator, select tensorflow on the scrolling menu and launch spyder/jupyter.
You can now use Keras with a tensorflow backend in Python 3.5
Hope it helped someone ! (It take me so much time to find it by myself)