I know this is one of the popular questions, but none of the solutions worked for me, so far.
I'm running a legacy code that is written in tensorflow v1.13.1
and keras v2.2.4
. I cannot modify the code to run latest tensorflow version. Since keras has now been merged into tensorflow, I'm facing problems installing the specific versions of tensorflow and keras via pip. I found that anaconda has option to install keras and tensorflow with the above version. So, I installed it with
conda install -c conda-forge keras-gpu=2.2.4 tensorflow-gpu=1.13.1
It installed the version and all works too. But it doesn't use GPU, and instead runs on CPU. I noticed that anaconda installed both CPU and GPU versions of tensorflow and I guess this is why it is defaulting to CPU version. So, my question is, how can I force it to use GPU version?
PS: There are many answers out there that suggest to remove CPU version of tensorflow. But when I try to remove CPU version, conda uninstalls everything including keras. So, I assume there should be a way to use tensorflow-gpu when both of them are installed. Any help in this regard is appreciated!
Let me start off with the assumption you're using an NVIDIA GPU. It's most likely due to you either not having CUDA installed or having the wrong version. Although, do double check to make sure you also have the latest NVIDIA drivers. If you look at this list you can see that tensorflow_gpu-1.13.1 uses CUDA version 10.0 and CudNN 7.4. To install those through anaconda use the following command.
conda install cudatoolkit==10.0.130
As for cudnn 7.4 check out the archive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With