I recently install tensorflow 2.0 on my computer but when I try to run it on my GPU, the function tf.config.experimental.list_physical_devices('GPU')
on Jupyter or Vitual Studio Code it returns me a void array. Do you know why?
My set-up:
Computer: MSI
Processor: Intel(R) Core(TM) i7-8750H CPU @ 2.220GHz
GPU 0: Intel(R) UHD Graphics 630
GPU: NVIDIA GeForce GTX 1060
Python: Ananconda 3 with Python 3.7
Tensenflow 2.0 installed with pip install tensorflow
My test code:
physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
if physical_devices:
tf.config.experimental.set_memory_growth(physical_devices[0], True)
Thanks in advance: :)
Providing the solution here (Answer Section), even though it is present in the Comment Section for the benefit of the community.
Instead of pip install tensorflow
, you can try pip3 install --upgrade tensorflow-gpu
or just remove tensorflow
and then installing "tensorflow-gpu
will resolves your issue.
After installation of Tensorflow GPU, you can check GPU as below
physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
if physical_devices:
tf.config.experimental.set_memory_growth(physical_devices[0], True)
Output:
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
Upgrading simply worked for me.:
pip3 install --upgrade tensorflow-gpu
and the device name searched has to be 'XLA_GPU', and does not respond with solo 'GPU' search term. But it also raised another error when setting the memory growth which is not supported by 'XLA' gpus.
First install anaconda or mini-anaconda on your system and make sure you have set the environment path for conda
command.
In below command replace
tensor
with a environment name of your choice:
conda create -n tensor tensorflow-gpu cudatoolkit=9.0
conda activate tensor
Then update your
tensorflow-gup
package usingpip
and make sure your environment is activated in conda
pip3 install --upgrade tensorflow-gpu
Verify weather tensorflow with gpu support is installed successfully
(tensor) C:\> python
Python 3.8.15 (default, Nov 24 2022, 14:38:14) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> tensorflow.config.list_physical_devices("GPU")
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
The output [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
in terminal means we have successfully installed tensorflow with gpu.
This answer was taken fromanaconda tensorflow installation link.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.