Open Praful932 opened 3 years ago
For now fixed this with a workaround - normal tensorflow installation (Edit : In a separate Python virtual environment not conda)
Note : Remove Geforce Experience if you have, does not work with CUDA
- Install the prerequisite software requirements from here with proper versions.
pip install tensorflow
(Preferrably in a virtual environment)
Should detect GPU now, check with this command - tf.test.gpu_device_name()
Hello! Having the same issue here. Isn't it advised not to install packages with pip on a conda enviroment?
PD: I tried your workaround but had no success, but pip install tensorflow-gpu
did the trick.
Not conda, I installed it in a separate python virtual environment
I encountered this problem too when I installed tensorflow-gpu in a new conda environment. I checked all the packages it installed in which I cannot find cudatoolkit
and cudnn
which seems to be the reason why it cannot detect gpu, I tried to manually install cudatoolkit
and cudnn
by conda install cudatoolkit cudnn
but have no luck of success. I solved this by using conda install tensorflow-gpu=2.1
, the old version works fine with all the dependencies.
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7: conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8: conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
It works out for me. Thanks very much!
Thank you very much! I have been searching for hours trying to find a solution.
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
It works for me, thank you very much!
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build. Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
Thank you, i just spent the whole night trying to fix that
Thanks for raising this issue here as well. I had asked this same question on Stack Overflow and a couple of guys have given some alternate answers there. Although @ZOUG provides an excellent one-liner solution, in case anyone is interested or the solution provided here is not working due to some reason you may want to check out https://stackoverflow.com/questions/65273118/why-is-tensorflow-not-recognizing-my-gpu-after-conda-install link. (Note that mixing conda with pip isn't always the right thing to do).
ZOUG hack seem not to work now:
PackagesNotFoundError: The following packages are not available from current channels:
- tensorflow==2.3=mkl_py37h936c3e2_0
- tensorflow-gpu=2.3
Current channels:
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://conda.anaconda.org/conda-forge/linux-64
- https://conda.anaconda.org/conda-forge/noarch
My setup is !python -V Python 3.7.6
ZOUG hack seem not to work now:
PackagesNotFoundError: The following packages are not available from current channels: - tensorflow==2.3=mkl_py37h936c3e2_0 - tensorflow-gpu=2.3 Current channels: - https://repo.anaconda.com/pkgs/main/linux-64 - https://repo.anaconda.com/pkgs/main/noarch - https://repo.anaconda.com/pkgs/r/linux-64 - https://repo.anaconda.com/pkgs/r/noarch - https://conda.anaconda.org/conda-forge/linux-64 - https://conda.anaconda.org/conda-forge/noarch
My setup is !python -V Python 3.7.6
@GrigoriiTarasov In the official Anaconda channel, tensorflow-gpu
2.3 is available only for Windows but not for Linux.
Is there a workaround for Linux?
Is there a workaround for Linux?
For now you could try this new (testing) build of Tensorflow 2.4.1 from @katietz's private channel:
conda install -c ktietz tensorflow-gpu
If you find any issues, post your feedbacks under this post.
Thanks @ZOUG, I will try that if I end up needing TensorFlow 2.4. I decided to stick with the official Anaconda channel and just downgrade to get GPU detection working on my Linux system.
In case this helps others: I ended up downgrading to TensorFlow 2.2.0 and using a build from the official Anaconda channel with the gpu
prefix: conda install tensorflow==2.2.0=gpu_py38hb782248_0
This ensures the correct cuda and cudnn versions are installed and it detects my GPU, unlike the broken TF 2.3 build.
Thanks @ZOUG, I will try that if I end up needing TensorFlow 2.4. I decided to stick with the official Anaconda channel and just downgrade to get GPU detection working on my Linux system.
In case this helps others: I ended up downgrading to TensorFlow 2.2.0 and using a build from the official Anaconda channel with the
gpu
prefix:conda install tensorflow==2.2.0=gpu_py38hb782248_0
This ensures the correct cuda and cudnn versions are installed and it detects my GPU, unlike the broken TF 2.3 build.
If you need TF 2.3+, another option is to use pip
(see this post) to perform the upgrade.
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
This is THE solution for windows users. I encourage people to try this before blowing up conda!
For me , it works if I install cudatoolkit and cudnn using conda install cudatoolkit==10.1.243 cudnn
and then install tensorflow using conda install tensorflow-gpu
for both Windows 10 and WSL 2
Note: It doesn't work it I install the other way round
I found a workaround for installing tf>2.3
on Windows. It looks like conda-forge
has cudnn 8.2
and cudatoolkit 11.2
, required for the latest build. So they can be installed with conda install -c conda-forge cudnn
and then tf2.5 can be installed with pip install tensorflow
.
Remember that to associate pip to the current env you should first run conda install pip
on it.
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
you a god or what? ;-; @ZOUG this worked for me. nearly cried ;-;
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
Finally worked:D Thank you
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build. Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
It works out for me. Thanks very much!
saved my life. Thanks!!!!!
tensorflow-gpu was just updated for windows to 2.5.0 on anaconda's main channel. Seems to be working fine!
For some reason, I couldn't get tensorflow-gpu v2.5.0 to detect my GPU on my JupyterHub environment, despite the many answers on the internet. I found a way to get tensorflow-gpu v2.4.1 to work as expected on JupyterHub+RTX 3090. If none of the suggested answers work, give it a go. My configuration works fine now!
https://github.com/tensorflow/tensorflow/issues/45930#issuecomment-877777803
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
This works for my issue
Just an update: It appears this bug is still present. On Linux, we're currently working around using something like this, in case it may be useful to others.
conda create --override-channels --name anaconda-tensorflow2-gpu-20210928-nvidiatest -c nvidia -c defaults -c conda-forge pytorch-gpu numpy 'cudatoolkit<11.3' 'cudatoolkit>=11'
(conda activate anaconda-tensorflow2-gpu-20210928-nvidiatest && pip3 install tensorflow)
(The cudatoolkit constraints are due to us not having the latest kernel driver yet.)
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
Is there a corresponding version for Python 3.9? Thanks
Just an update: It appears this bug is still present. On Linux, we're currently working around using something like this, in case it may be useful to others.
conda create --override-channels --name anaconda-tensorflow2-gpu-20210928-nvidiatest -c nvidia -c defaults -c conda-forge pytorch-gpu numpy 'cudatoolkit<11.3' 'cudatoolkit>=11' (conda activate anaconda-tensorflow2-gpu-20210928-nvidiatest && pip3 install tensorflow)
(The cudatoolkit constraints are due to us not having the latest kernel driver yet.)
Thanks for you suggestion, Michael! Can you please clarify what version of py does it fit? Does this way have advantages over "conda install tensorflow==2.2.0=gpu_py38hb782248_0"?
I've made some variation to try to meet my needs:
conda create --override-channels --name cuda_cond_hack -c nvidia -c defaults -c conda-forge pytorch-gpu numpy 'cudatoolkit<11.3' 'cudatoolkit>=11' python=3.7.0 conda activate cuda_cond_hack pip3 install tensorflow conda install keras-ocr
but it lead to such conda conflicts: https://pastebin.com/tVGYUYcw
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
worked like a charm, thanks man, god bless you
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
Worked well for me! Thanks a ton!
For me: Windows 10, Python 3.8.12, conda 4.12.0
To get it working, I had to follow the steps below:
Download and install CUDA Toolkit 11.6 Update 2 https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exe_local
Run the following commands in the Conda terminal:
pip uninstall protobuf
pip uninstall tensorflow
pip install --upgrade --force-reinstall --user tensorflow-gpu
pip install --upgrade tensorflow-gpu
restart PC
For me: Windows 10, Python 3.8.12, conda 4.12.0
To get it working, I had to follow the steps below:
- Download and install CUDA Toolkit 11.6 Update 2 https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exe_local
- Run the following commands in the Conda terminal:
pip uninstall protobuf pip uninstall tensorflow pip install --upgrade --force-reinstall --user tensorflow-gpu pip install --upgrade tensorflow-gpu
restart PC
Installing packages using pip
in a conda environment would keep the packages out of conda's management system (conflict resolution, dependency management, etc.). Therefore it is normally only adopted as the last resort and not recommended as a common practice.
It looks like the issue is that the installation engine selects a faulty tensorflow build during the process (cf. see this post). A workaround for now is to explicitly specify the correct tensorflow build.
Python 3.7:
conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0
Python 3.8:conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0
This works. Thanks! @ZOUG I am working on Win10, conda 4.12, Python 3.7, and previously had the same issue with "no gpu detected", including "no module tensorflow_estimation" . This is what I initially had (Anaconda's default tensorflow installation: tensorflow=2.1, tensorflow_estimator=2.6).
I suggest to work on a new env (rather than uninstalling, downgrading or upgrading) and fresh install tensorflow using the suggested code above. This will save you a lot of time in the case that you encounter multiple package conflicts.
Running this code:
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
now gives me:
Num GPUs Available: 1
Works like a charm! :)
Please note that tensorflow's gpu is no longer supported on Windows native per their documentation.
Caution: TensorFlow 2.10 was the last TensorFlow release that supported GPU on native-Windows. Starting with TensorFlow 2.11, you will need to install [TensorFlow in WSL2](https://tensorflow.org/install/pip#windows-wsl2), or install tensorflow-cpu and, optionally, try the [TensorFlow-DirectML-Plugin](https://github.com/microsoft/tensorflow-directml-plugin#tensorflow-directml-plugin-)
Actual Behavior
GPU is not detected by tensorflow.
tf.test.gpu_device_name()
gives empty stringExpected Behavior
The GPU should be detected by Tensorflow. This was working on earlier tensorflow-gpu version 2.1(MX150 GPU), on 2.3 it does not work. I followed this tutorial for installing, now the size of tensorflow is also way less 50 mb and size of tf-gpu in kb while installing, earlier it was bigger(>300 mb) than that.
Steps to Reproduce
Create new enivornment and install tf-gpu
conda create --name tf_gpu tensorflow-gpu
Import tensorflow and check if it detects gpuAnaconda or Miniconda version:
conda 4.9.2
Operating System:
Windows 10
conda info
conda 4.9.2
conda list --show-channel-urls