Using GPU with Keras - python

i'm actally facing a probleme since last friday and didn't find a solution for the moment.
First of all, you need to know that i'm a beginner on linux,i'm trying to do some deep learning in my internship, and i discovered that even if my company have a 1080 Ti, keras wasn't using it, so have the job to correct this.
I am trying to use Keras with GPU. I installer Tensorflow by following these steps : https://www.tensorflow.org/install/install_linux
I also installer CUDA,cuDNN.
I found on my machine an older installation of CUDA (version 7.5). I installed version 9.2 without uninstalling version 7.5. I added the PATH variables but it seems like it is not taking in account : [][https://i.stack.imgur.com/B3Pqm.png]
I tried to uninstall CUDA version 7.5 but i don't know how to do it, since in the usr/local folder, there is no cuda-7.5 folder.
When i enter nvidia-smi in the prompt, it works correctly. I installed tensorflow and tensorflow-gpu, but i does not work : [][https://i.stack.imgur.com/78gPd.png]
Did anyone know how to help me? i Guess the solution of my probleme is not really complicated for someone who knows Ubuntu, and i feel like i'm loosing a lot of times doing something i don't really understand.
If someone need some further informations in order to help me, feel free to ask.
Thank you

Uninstall tensorflow and install only tensorflow-gpu. You should not install both. If you are using keras, then install keras-gpu.
Let's say you are working with conda and you want to tidy up all this. Do
conda remove keras
conda remove tensorflow*
conda install keras-gpu
If you are not, then i highly recommend Anaconda for dealing with these issues which you seem to be having stress-free.

Related

downgrade tensorflow GPU from v2.8 to v2.7 in google colab

I have some models I trained using TF and have been using for awhile now but since V2.8 came out I am having issues with the models based in MobileNetV3 (large and small), I posted the issue on the tensor-flow git and am waiting for a solution. In the mean time I wan to make some predictions on colab using V2.7 instead of 2.8. I know this involves installing CUDA and and cuDNN. I am really in experienced at this level and setting up TF. does anyone know how to proceed with this? I saw this post but was hoping for a less intensive solution. like can I 'flash' an old colab machine that has 2.7 setup?
as a side note, shouldn't colab have options like this? the main reason I am using colab is that I can run my code anywhere and that it is repeatable.
also I can install and run my code for V2.7 for the CPU version but I want to run on the GPU.
thanks for your help!
edit: sorry I did a poor job at explaining what I already tried. I have tired using pip
!pip install --upgrade tensorflow-gpu==2.7.*
!pip install --upgrade tensorflow==2.7.*
but I get this error
UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
I have also pip uninstalled keras, TF and TF-GPU before installing and I get the same error. yes I restart the runtime as well. someone mentioned that conda tried to install everything when installing TF, is this a possible solution?

Getting CondaVerificationError when installing tensorflow(windows 10)

I got error message when I am trying to setup tensorflow.
I examine a lot of discussion from github issues. I tried different versions but output doesn't change.
I saw this previous question in stackoverflow too but there is no answer avaliable.
I am trying to be more specific about error and platforms I am currently using and I hope someone help me or show me different approaches.
First of all I had python 3.6.x
but I deleted this version cause I want to make this setup clearly.
I downloaded Anaconda (Anaconda Python 3.7 version)
After that I checked my python version and its changed like 3.7 as I expected.
After that I follow the guide for setup tensorflow
conda create -n tf-gpu tensorflow-gpu
Because I want to use my gpu which is much faster comparing with CPU
(I already checked my gpu compability for tensorflow,I am currently using rtx 2060)
Summary:
-Anaconda Python 3.7 version
-Python 3.7.4
I solved my problem about insalling tensorflow maybe it will help other people.
Firstly, I just cleared my PATH under the Environment Variable which are related with Anaconda or you can delete Anaconda and reinstall.
After that open Anaconda command line and write:
pip install tensorflow-gpu

Existing Tensorflow model to use GPU

I made a TensorFlow model without using CUDA, but it is very slow. Fortunately, I gained access to a Linux server (Ubuntu 18.04.3 LTS), which has a Geforce 1060, also the necessary components are installed - I could test it, the CUDA acceleration is working.
The tensorflow-gpu package is installed (only 1.14.0 is working due to my code) in my virtual environment.
My code does not contain any CUDA-related snippets. I was assuming that if I run it in a pc with CUDA-enabled environment, it will automatically use it.
I tried the with tf.device('/GPU:0'): then reorganizing my code below it, didn't work. I got a strange error, which said only XLA_CPU, CPU and XLA_GPU is there. I tried it with XLA_GPU but didn't work.
Is there any guide about how to change existing code to take advantage of CUDA?
Not enough to give exact answer.
Have you installed tensorflow-gpu separately? Check using pip list.
Cause, initially, you were using tensorflow (default for CPU).
Once you use want to use Nvidia, make sure to install tensorflow-gpu.
Sometimes, I had problem having both installed at the same time. It would always go for the CPU. But, once I deleted the tensorflow using "pip uninstall tensorflow" and I kept only the GPU version, it worked for me.

Can I let people use a different Tensorflow-gpu version above what they had installed with different CUDA dependencies?

I was trying to pack and release a project which uses tensorflow-gpu. Since my intention is to make the installation as easy as possible, I do not want to let the user compile tensorflow-gpu from scratch so I decided to use pipenv to install whatsoever version pip provides.
I realized that although everything works in my original local version, I can not import tensorflow in the virtualenv version.
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Although this seems to be easily fixable by changing local symlinks, that may break my local tensorflow and is against the concept of virtualenv and I will not have any idea on how people installed CUDA on their instances, so it doesn't seems to be promising for portability.
What can I do to ensure that tensorflow-gpu works when someone from internet get my project only with the guide of "install CUDA X.X"? Should I fall back to tensorflow to ensure compatibility, and let my user install tensorflow-gpu manually?
Having a working tensorflow-gpu on a machine does involve a series of steps including installation of cuda and cudnn, the latter requiring an NVidia approval. There are a lot of machines that would not even meet the required config for tensorflow-gpu, e.g. any machine that doesn't have a modern nvidia gpu. You may want to define the tensorflow-gpu requirement and leave it to the user to meet it, with appropriate pointers for guidance. If the project can work acceptably on tensorflow-cpu, that would be a much easier fallback option.

tensorflow installation error in rasa_core package

Tried a lot of things to rectify the problem but nothing helped. tried downloading tensorflow separately but while installing rasa_core again the same problem is coming. I have a 32 bit machine with python 3.6.5 installed and with the latest version of pip.
I would really appreciate the help.
Tensorflow causes a lot of problem when installing.
Would be good if you could specify if you are installing the cpu or the gpu version.
Firstly, update your version of pip and try again.
If you are installing the gpu version, then you need to find all the compatible gpus(not all work with tensorflow). You need the exact right version of CUDA(even more recent versions will not work) and there are plenty of other errors that can come up.
I have little experience with the cpu version, I would not recommend using tensorflow on cpu since processing time gets really high even for some basic machine learning. You can get a GT740 for under $90
I would recommend finding a tensorflow tutorial that shows exactly how to install it, get one as recent as possible.
Personally it took me a lot of trial and error getting tensorflow to work so its not uncommon.

Categories

Resources