Getting errors installing Tensorflow GPU - tensorflow

I was earlier working with the CPU only version of tensorflow. I tried installing the GPU version now using this link.
But I think I messed up.
When I try to do import tensorflow it gives the following message:
ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory
What should I do?

It could be because a wrong version of cuda is installed : check /usr/local/ for the versions of cuda that are installed and if it matches with the version in the Tensorflow error. If it both versions don't match, you'll have to either install another version of cuda or Tensorflow.
Another reason could be because of missing environment variables (as explained here).
Try this :
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
export CUDA_HOME=/usr/local/cuda

Related

Cannot import Tensorflow

I can't import tensorflow, even after checking all dependencies. I'm getting an error message 'ModuleNotFoundError: No module named 'tensorflow'' when importing 'import tensorflow as tf' in vs code
I installed tensorflow through conda with 'conda install tensorflow'. It seems to have worked, since when I use 'pip show tensorflow', it shows up as 'version 2.10.0'. Moreover, my Python version is '3.9.15', so it should be compatible. I've been looking all over and no other installatoins have been working. Any suggestions?
Please try again by using Python version 3.10 as Python 3.9 shows some version errors in VS code.
Please check this link to install TensorFlow in VScode.

Loaded runtime CuDNN library: 8.0.5 but source was compiled with: 8.1.0

I get this error when I run the model.fit_generator code to train images using the CNN model. I don't understand the error, and what should I do? Can anyone help me?
this is the full error description
`Loaded runtime CuDNN library: 8.0.5, but the source was compiled with: 8.1.0. CuDNN library needs to have a matching major version and equal or higher minor version. If using a binary install, upgrade your CuDNN library. If building from sources, ensure the library loaded at runtime is compatible with the version specified during compile configuration.
I had the same error "tensorflow/stream_executor/cuda/cuda_dnn.cc:362] Loaded runtime CuDNN library: 8.0.5 but source was compiled with: 8.1.0."
I solved it by downgrading the TensorFlow version, here it says that you use a new version of TensorFlow that is not compatible with the google colab CuDNN version. I used TensorFlow 2.4.0 plus all the dependence required on version 2.4.0.
Here it says which version of TensorFlow to use for cudnn compatibility, https://www.tensorflow.org/install/source
You should always have version of libraries installed that is matching the version dependency you want to use is compiled with.
You can download the version you need from nvidia website or use conda for package management. It will handle all dependencies for you.
You can miniconda and type conda install -c anaconda tensorflow-gpu to get it sorted for you. If you need a specific version of python, you can create environment with it.
My solution:
After confirming that my cuda and cudnn versions are compatible with tensorflow, I first thought that the system did not synchronize after the installation was completed. After several restarts, it was found that it was not and could not be the problem, so I started to check all the cuda in the system. For the software that depends on cudnn, matlab was uninstalled during the period but it was useless. Later, I thought that pytorch is also related to cuda and cudnn. I checked the version of pytorch and found that I was using torch 1.8, and the cuda it was adapted to was 11.1 , The corresponding cudnn is 8.0.5, now the case is solved. Finally upgraded pytorch and solved it.
I have faced the same issue. It seems like if TensorFlow versions requires specific cuDNN version.
Check the link for required versions.
https://www.tensorflow.org/install/source#gpu
Thanks for This answer.
My solution:
After confirming that my cuda and cudnn versions are compatible with
tensorflow, I first thought that the system ...
It helps me a lot,but I use different way to solve this problem.
I found that pytorch 1.8 is compatible with cudnn 8.1.0. So, instead of upgrade pytorch version, I overwrite the cudnn 8.0.5 dll library with cudnn 8.1.0 in directory D:\Program Files\Python37\Lib\site-packages\torch\lib. You can find this location with Everything, which is always helpful.

Tensorflow can find right cudnn in one python file but fail in another

I am trying to use tensorflow gpu version to train and test my deep learning model. But here comes the problem. When I train my model in one python file things go on well. Tensorflow-gpu can be used properly. Then I save my model as a pretrained on as grapg.pb format and try to reuse it in another python file.
Then I got the following error messages.
E tensorflow/stream_executor/cuda/cuda_dnn.cc:363] Loaded runtime CuDNN
library: 7.1.4 but source was compiled with: 7.2.1. CuDNN library major
and minor version needs to match or have higher minor version in case of
CuDNN 7.0 or later version. If using a binary install, upgrade your CuDNN
library. If building from sources, make sure the library loaded at runtime
is compatible with the version specified during compile configuration.
I checked my cudnn version, in fact it is version 7.4.2. I also checked my environment path settings /cuda/v9.0/bin, cuda/v9.0/lib/x64, /cuda/v9.0/include are in there.
So why this happens? And how can I solve this?
--
cuda:v9.0
cudnn:7.4.2 (I think, I copy those cudnn files manually)
windows 10
python: 3.5
If you have multiple CuDNN installed thorough various ways like anaconda module and windows installation, you need to remove the older version in order for your code to detect the latest version and reinstall tensorflow-gpu.
You can follow this guide for installation based on OS.

Tensorflow on Anaconda error cannot find cudnn64_6.dll

I am having a problem with Tensorflow running on Spyder. When I installed it in cmd, it had the same problem that it couldn't find the path to cudnn64_6.dll, and so I added pathway to it and it seemed to import. Then, I installed the theano library and the keras and it seemed ok, then when I tried to import the keras library in spider, I got this message:
I have Cuda v8.0 and it should have that with it, at least I am told. I have installed all the drivers and downloaded the cudnn v6.0 for Cuda 8.0 and have added enough paths but still no luck. Where have I gone wrong?
Its Ok I just had to get rid of some environment paths and restart. My bad

glibc 2.14 not recognized by TensorFlow installation in Redhat

After TF complaining about lack of glibc_2.14, I installed glibc_2.14 in my home dir (I am using a supercomputing account,and I don't have root access) However, I still get this error when I try running TF. I have installed TF in anaconda using conda install. The system runs a Red Hat OS.
ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by users/ABCD1234/user123/opt/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so)
I suspect this is due to the TF installation not searching for glibc_2.14 in the home dir, instead searching in /lib64 system folder. How can I make TF work using glibc?
You need GLIBC-2.14, not (ancient) GLIBC-2.1.
In addition, you need to read this answer on how to make your TF program use the copy of GLIBC in your home directory.