Tensorflow не видит gpu windows 10

I've tried tensorflow on both cuda 7.5 and 8.0, w/o cudnn (my GPU is old, cudnn doesn't support it). When I execute device_lib.list_local_devices(), there is no gpu in the output. Theano sees my ...

So as of 2022-04, the tensorflow package contains both CPU and GPU builds. To install a GPU build, search to see what’s available:

λ conda search tensorflow
Loading channels: done
# Name                       Version           Build  Channel
tensorflow                    0.12.1          py35_1  conda-forge
tensorflow                    0.12.1          py35_2  conda-forge
tensorflow                     1.0.0          py35_0  conda-forge
…
tensorflow                     2.5.0 mkl_py39h1fa1df6_0  pkgs/main
tensorflow                     2.6.0 eigen_py37h37bbdb1_0  pkgs/main
tensorflow                     2.6.0 eigen_py38h63d3545_0  pkgs/main
tensorflow                     2.6.0 eigen_py39h855417c_0  pkgs/main
tensorflow                     2.6.0 gpu_py37h3e8f0e3_0  pkgs/main
tensorflow                     2.6.0 gpu_py38hc0e8100_0  pkgs/main
tensorflow                     2.6.0 gpu_py39he88c5ba_0  pkgs/main
tensorflow                     2.6.0 mkl_py37h9623b36_0  pkgs/main
tensorflow                     2.6.0 mkl_py38hdc16138_0  pkgs/main
tensorflow                     2.6.0 mkl_py39h31650da_0  pkgs/main

You can see that there are builds of TF 2.6.0 that support Python 3.7, 3.8 and 3.9, and that are built for MKL (Intel CPU), Eigen, or GPU.

To narrow it down, you can use wildcards in the search. This will find any Tensorflow 2.x version that is built for GPU, for instance:

λ conda search tensorflow=2*=gpu*
Loading channels: done
# Name                       Version           Build  Channel
tensorflow                     2.0.0 gpu_py36hfdd5754_0  pkgs/main
tensorflow                     2.0.0 gpu_py37h57d29ca_0  pkgs/main
tensorflow                     2.1.0 gpu_py36h3346743_0  pkgs/main
tensorflow                     2.1.0 gpu_py37h7db9008_0  pkgs/main
tensorflow                     2.5.0 gpu_py37h23de114_0  pkgs/main
tensorflow                     2.5.0 gpu_py38h8e8c102_0  pkgs/main
tensorflow                     2.5.0 gpu_py39h7dc34a2_0  pkgs/main
tensorflow                     2.6.0 gpu_py37h3e8f0e3_0  pkgs/main
tensorflow                     2.6.0 gpu_py38hc0e8100_0  pkgs/main
tensorflow                     2.6.0 gpu_py39he88c5ba_0  pkgs/main

To install a specific version in an otherwise empty environment, you can use a command like:

λ conda activate tf

(tf) λ conda install tensorflow=2.6.0=gpu_py39he88c5ba_0

…

The following NEW packages will be INSTALLED:

  _tflow_select      pkgs/main/win-64::_tflow_select-2.1.0-gpu
  …
  cudatoolkit        pkgs/main/win-64::cudatoolkit-11.3.1-h59b6b97_2
  cudnn              pkgs/main/win-64::cudnn-8.2.1-cuda11.3_0
  …
  tensorflow         pkgs/main/win-64::tensorflow-2.6.0-gpu_py39he88c5ba_0
  tensorflow-base    pkgs/main/win-64::tensorflow-base-2.6.0-gpu_py39hb3da07e_0
  …

As you can see, if you install a GPU build, it will automatically also install compatible cudatoolkit and cudnn packages. You don’t need to manually check versions for compatibility, or manually download several gigabytes from Nvidia’s website, or register as a developer, as it says in other answers or on the official website.

After installation, confirm that it worked and it sees the GPU by running:

λ python
Python 3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.6.0'
>>> tf.config.list_physical_devices()
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

Getting conda to install a GPU build and other packages you want to use is another story, however, because there are a lot of package incompatibilities for me. I think the best you can do is specify the installation criteria using wildcards and cross your fingers.

This tries to install any TF 2.x version that’s built for GPU and that has dependencies compatible with Spyder and matplotlib’s dependencies, for instance:

λ conda install tensorflow=2*=gpu* spyder matplotlib

For me, this ended up installing a two year old GPU version of tensorflow:

  matplotlib         pkgs/main/win-64::matplotlib-3.5.1-py37haa95532_1
  spyder             pkgs/main/win-64::spyder-5.1.5-py37haa95532_1
  tensorflow         pkgs/main/win-64::tensorflow-2.1.0-gpu_py37h7db9008_0

I had previously been using the tensorflow-gpu package, but that doesn’t work anymore. conda typically grinds forever trying to find compatible packages to install, and even when it’s installed, it doesn’t actually install a gpu build of tensorflow or the CUDA dependencies:

λ conda list
…
cookiecutter              1.7.2              pyhd3eb1b0_0
cryptography              3.4.8            py38h71e12ea_0
cycler                    0.11.0             pyhd3eb1b0_0
dataclasses               0.8                pyh6d0b6a4_7
…
tensorflow                2.3.0           mkl_py38h8557ec7_0
tensorflow-base           2.3.0           eigen_py38h75a453f_0
tensorflow-estimator      2.6.0              pyh7b7c402_0
tensorflow-gpu            2.3.0                he13fc11_0

An truing to get TensorFlow to recognize that there is a GPU installed on the PC.
Windows10 Pro 64bit version
Nvidia GTX1660 TI with latest drivers
Tensorflow — 2.3.0-dev20200615
CUDA v10.0
cudnn 7.6.5.32

print(device_lib.list_local_devices())

print(device_lib.list_local_devices())
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 4283633287383166880
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 5791820499534504026
physical_device_desc: "device: XLA_CPU device"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 15245658627817172966
physical_device_desc: "device: XLA_GPU device"
]

so system sees that there isa GPU installed, however

print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
Num GPUs Available:  0

Trying to get a model to train using the GPU to complete faster — my current training takes 5 hours per epoch…..please help as its for a college project and i really need the speed of the GPU to help.

I am working on Windows 10.

I have installed tensorflow-gpu 2.1.0 and checked that it was in the pip list:

enter image description here

My python version is 3.7 and CUDA version is 10.1:

enter image description here

Here is what the nvidia-smi command outpouts:

enter image description here

As you can see I have 2 GPU’s installed and visible with the nvidia command but when I use the command ‘tf.config.get_visible_devices()’ on my notebook I can only see the CPU:

enter image description here

Any ideas on how to solve this problem please?

asked Jul 22, 2020 at 15:06

Thomas Hustache's user avatar

5

Tensorflow 2.1.0 is compatible with CUDA 10.1. Use command nvcc --version to verify which CUDA you have installed, and redo the setup if necessary.

answered Jul 23, 2020 at 4:00

ZWang's user avatar

ZWangZWang

8125 silver badges14 bronze badges

4

I am working on Windows 10.

I have installed tensorflow-gpu 2.1.0 and checked that it was in the pip list:

enter image description here

My python version is 3.7 and CUDA version is 10.1:

enter image description here

Here is what the nvidia-smi command outpouts:

enter image description here

As you can see I have 2 GPU’s installed and visible with the nvidia command but when I use the command ‘tf.config.get_visible_devices()’ on my notebook I can only see the CPU:

enter image description here

Any ideas on how to solve this problem please?

asked Jul 22, 2020 at 15:06

Thomas Hustache's user avatar

5

Tensorflow 2.1.0 is compatible with CUDA 10.1. Use command nvcc --version to verify which CUDA you have installed, and redo the setup if necessary.

answered Jul 23, 2020 at 4:00

ZWang's user avatar

ZWangZWang

8125 silver badges14 bronze badges

4

If TensorFlow doesn’t detect your GPU, it will default to the CPU, which means when doing heavy training jobs, these will take a really long time to complete. This is most likely because the CUDA and CuDNN drivers are not being correctly detected in your system.

I am assuming that you have already installed Tensorflow with GPU support. If you haven’t check this article:

To check that GPU support is enabled, run the following from a terminal:

python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

If your GPU is detected you should see something similar to this output:

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

But if you are unlucky, then you will instead get the following output:

[]

Or you might get an obscure error like the below:


2022-05-24 20:29:24.352218: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: UNKNOWN ERROR (100)
2022-05-24 20:29:24.352261: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (c37259b3e9a1): /proc/driver/nvidia/version does not exist

In both cases, Tensorflow is not detecting your Nvidia GPU. This can be for a variety of reasons:

  • Nvidia Driver not installed
  • CUDA not installed, or incompatible version
  • CuDNN not installed or incompatible version
  • Tensorflow running on Docker but without Nvidia drivers installed in host, or Nvidia Docker not installed
  • etc

Now that you are sure that Tensorflow is not detecting your GPU, it’s time to install Tensorflow correctly. Check the article below:

Recommended Courses for Data Science

  • Learn Python for Beginners 👉🏼 Python for Everybody
  • Learn Deep Learning with Andrew Ng 👉🏼 Neural Networks and Deep Learning by Andrew Ng
  • Learn Data Science with Coursera Plus 👉🏼 Coursera Plus For Data Science

Я новичок в глубоком обучении, и последние 2 дня тщетно пытался установить версию tensorflow-gpu на свой компьютер. Я избегал установки драйверов CUDA и cuDNN, поскольку некоторые форумы в Интернете не рекомендуют это из-за многочисленных проблем с совместимостью. Поскольку раньше я уже использовал дистрибутив python conda, я выбрал conda install -c anaconda tensorflow-gpu, как написано на их официальном сайте здесь: https://anaconda.org/anaconda/tensorflow-gpu.

Однако даже после установки версии gpu в новой виртуальной среде (чтобы избежать потенциальных конфликтов с установленными библиотеками pip в базовой среде env), по какой-то загадочной причине tenorflow, похоже, даже не распознает мой графический процессор.

Некоторые из фрагментов кода, которые я запустил (в приглашении anaconda), чтобы понять, что он не распознает мой графический процессор: —

1 .

>>>from tensorflow.python.client import device_lib
        >>>print(device_lib.list_local_devices())
                    [name: "/device:CPU:0"
                device_type: "CPU"
                memory_limit: 268435456
                locality {
                }
                incarnation: 7692219132769779763
                ]

Как видите, он полностью игнорирует графический процессор.

2 .

>>>tf.debugging.set_log_device_placement(True)
    >>>a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
2020-12-13 10:11:30.902956: I tensorflow/core/platform/cpu_feature_guard.cc:142] This 
TensorFlow 
binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU 
instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
>>>b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
>>>c = tf.matmul(a, b)
>>>print(c)
tf.Tensor(
[[22. 28.]
[49. 64.]], shape=(2, 2), dtype=float32)

Здесь предполагалось указать, что он работал с графическим процессором, показывая Executing op MatMul in device /job:localhost/replica:0/task:0/device:GPU:0 (как написано здесь: https://www.tensorflow.org/guide/gpu), но ничего подобного нет. Также я не уверен, что означает сообщение после второй строки.

Я также искал несколько решений в Интернете, в том числе здесь, но почти все проблемы связаны с первым методом ручной установки, который я еще не пробовал, поскольку все рекомендовали этот подход.

Я больше не использую cmd, так как переменные среды каким-то образом испортились после удаления tenorflow-cpu из базового env и при повторной установке, он отлично работал с приглашением anaconda, но не с cmd. Это отдельная проблема (и тоже широко распространенная), но я упомянул ее на тот случай, если она сыграет здесь свою роль. Я установил версию gpu в новую виртуальную среду, чтобы обеспечить чистую установку, и, насколько я понимаю, переменные пути необходимо настраивать только для ручной установки библиотек CUDA и cuDNN.

Карта, которую я использую :-( которая поддерживает CUDA)

C:WINDOWSsystem32>wmic path win32_VideoController get name
Name
NVIDIA GeForce 940MX
Intel(R) HD Graphics 620

Версия Tensorflow и Python, которую я использую в настоящее время: —

>>> import tensorflow as tf
>>> tf.__version__
'2.3.0'

Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.

Информация о системе: Windows 10 Home, 64-битная операционная система, процессор на базе x64.

Любая помощь могла бы быть полезна. Заранее спасибо.

4 ответа

Лучший ответ

В настоящее время conda install tensorflow-gpu устанавливает tensorflow v2.3.0 и НЕ устанавливает пакеты conda cudnn или cudatoolkit. Их установка вручную (например, с помощью conda install cudatoolkit=10.1), похоже, тоже не решает проблему.

Решением является установка более ранней версии tensorflow, которая устанавливает cudnn и cudatoolkit, а затем обновление с помощью pip

conda install tensorflow-gpu=2.1
pip install tensorflow-gpu==2.3.1

(2.4.0 использует cuda 11.0 и cudnn 8.0, однако cudnn 8.0 отсутствует в Anaconda по состоянию на 16/12/2020)


2

geometrikal
16 Дек 2020 в 07:55

Вам нужно будет установить cuDNN и набор инструментов CUDA для использования вашего графического процессора.

Сначала проверьте совместимую версию здесь.

CuDNN можно найти здесь (требуется бесплатная учетная запись).

Набор инструментов CUDA можно найти здесь.

Опять же, проверьте совместимую версию ПЕРЕД установкой. Более новые версии не имеют обратной совместимости.


0

Royce Schultz
13 Дек 2020 в 06:59

Я вижу, что у вашего графического процессора есть вычислительные возможности 5.0 , и это нормально, TensorFlow это должно понравиться. Таким образом, я предполагаю, что во время настройки среды что-то пошло не так. Попробуйте создать новую среду, используя:

conda create --name tf_gpu tensorflow-gpu 

Затем установите все остальные нужные пакеты в <▪tf_gpu и повторите попытку.

P.S: действительно важно, чтобы в окружении был только один пакет TensorFlow (один gpu). Если у вас их несколько, нет гарантии, что

import tensorflow as tf

Импортирует тот, который вы хотите …


0

Vasil Yordanov
13 Дек 2020 в 10:04

Я также не смог (пока) заставить TF 2.3.0 распознавать мой графический процессор Nvidia Quadro Pro 620.

Примечание. У меня есть 2 других «среды» на этом ПК (Windows Pro). Все они установлены через Anaconda:

  1. Python 3.7.8 TF 2.0.0 … распознает (и использует) графический процессор Nvidia
  2. Python 3.6.9 TF 2.1.0 … распознает (и использует) графический процессор Nvidia
  3. Python 3.8.6 TF 2.3.0 … НЕ видит графический процессор

Моя машина имеет Cuda 11.1; cuDNN 8.0.5

Моя следующая мысль — рассмотреть возможность понижения версии Python с 3.8.6 до 3.7.8 в третьей конфигурации, где TF = 2.3.0.

Стив


0

steve Schneider
13 Дек 2020 в 22:03

Понравилась статья? Поделить с друзьями:
  • Tenorshare ultdata windows data recovery код активации
  • Tenorshare reiboot скачать бесплатно на русском c ключом для windows 10
  • Tenorshare reiboot код активации для windows
  • Tenorshare reiboot for android скачать бесплатно c ключом для windows
  • Tenorshare reboot скачать для windows 7