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()
,
When I look up your GPU, I see that it only supports CUDA Compute Capability 2.1. (Can be checked through https://developer.nvidia.com/cuda-gpus) Unfortunately, TensorFlow needs a GPU with minimum CUDA Compute Capability 3.0. https://www.tensorflow.org/get_started/os_setup#optional_install_cuda_gpus_on_linux
You might see some logs from TensorFlow checking your GPU, but ultimately the library will avoid using an unsupported GPU.
If you are using conda, you might have installed the cpu version of the tensorflow. Check package list (conda list
) of the environment to see if this is the case . If so, remove the package by using conda remove tensorflow
and install keras-gpu instead (conda install -c anaconda keras-gpu
. This will install everything you need to run your machine learning codes in GPU. Cheers!
P.S. You should check first if you have installed the drivers correctly using nvidia-smi
. By default, this is not in your PATH so you might as well need to add the folder to your path. The .exe file can be found at C:\Program Files\NVIDIA Corporation\NVSMI
I came across this same issue in jupyter notebooks. This could be an easy fix.
$ pip uninstall tensorflow
$ pip install tensorflow-gpu
You can check if it worked with:
tf.test.gpu_device_name()
It seems like tensorflow 2.0+ comes with gpu capabilities therefore
pip install tensorflow
should be enough
The following worked for me, hp laptop. I have a Cuda Compute capability (version) 3.0 compatible Nvidia card. Windows 7.
pip3.6.exe uninstall tensorflow-gpu
pip3.6.exe uninstall tensorflow-gpu
pip3.6.exe install tensorflow-gpu
Summary:
*
source - https://www.tensorflow.org/install/gpu
Detailed instruction:
check if tensorflow sees your GPU (optional)
from tensorflow.python.client import device_lib
def get_available_devices():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos]
print(get_available_devices())
# my output was => ['/device:CPU:0']
# good output must be => ['/device:CPU:0', '/device:GPU:0']
check if your card can work with tensorflow (optional)
tensorflow needs Compute Capability 3.5 or higher. (https://www.tensorflow.org/install/gpu#hardware_requirements)
https://developer.nvidia.com/cuda-gpus
find versions of CUDA Toolkit and cuDNN SDK, that you need
a) find your tf version
import sys
print (sys.version)
# 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
import tensorflow as tf
print(tf.__version__)
# my output was => 1.13.1
b) find right versions of CUDA Toolkit and cuDNN SDK for your tf version
https://www.tensorflow.org/install/source#linux
* it is written for linux, but worked in my case
see, that tensorflow_gpu-1.13.1 needs: CUDA Toolkit v10.0, cuDNN SDK v7.4
install CUDA Toolkit
a) install CUDA Toolkit 10.0
https://developer.nvidia.com/cuda-toolkit-archive
select: CUDA Toolkit 10.0 and download base installer (2 GB)
installation settings: select only CUDA
(my installation path was: D:\Programs\x64\Nvidia\Cuda_v_10_0\Development)
b) add environment variables:
system variables / path must have:
D:\Programs\x64\Nvidia\Cuda_v_10_0\Development\bin
D:\Programs\x64\Nvidia\Cuda_v_10_0\Development\libnvvp
D:\Programs\x64\Nvidia\Cuda_v_10_0\Development\extras\CUPTI\libx64
D:\Programs\x64\Nvidia\Cuda_v_10_0\Development\include
install cuDNN SDK
a) download cuDNN SDK v7.4
https://developer.nvidia.com/rdp/cudnn-archive (needs registration, but it is simple)
select "Download cuDNN v7.4.2 (Dec 14, 2018), for CUDA 10.0"
b) add path to 'bin' folder into "environment variables / system variables / path":
D:\Programs\x64\Nvidia\cudnn_for_cuda_10_0\bin
pip uninstall tensorflow pip install tensorflow-gpu
check if tensorflow sees your GPU
- restart your PC
- print(get_available_devices())
- # now this code should return => ['/device:CPU:0', '/device:GPU:0']
I was using Ubuntu and had to downgrade Python to 3.6.9. I also had to use tensorflow-gpu
instead of just plain tensorflow, I believe. Regardless, here is the environment I am currently using:
absl-py==0.9.0
alabaster==0.7.12
alembic==1.4.3
appdirs==1.4.3
apt-clone==0.2.1
apturl==0.5.2
argh==0.26.2
asn1crypto==1.3.0
astor==0.8.1
astroid==2.3.3
atomicwrites==1.3.0
attrs==19.3.0
autopep8==1.4.4
Babel==2.8.0
backcall==0.1.0
bcrypt==3.1.7
beautifulsoup4==4.6.0
bleach==3.1.0
Brlapi==0.6.6
caffe==1.0.0
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
cliff==3.4.0
cloudpickle==1.3.0
cmaes==0.6.1
cmd2==1.3.11
colorama==0.4.3
colorlog==4.2.1
command-not-found==0.3
cryptography==2.8
cupshelpers==1.0
cycler==0.10.0
cytoolz==0.10.1
decorator==4.1.2
defer==1.0.6
distro-info===0.18ubuntu0.18.04.1
docutils==0.14
entrypoints==0.2.3.post1
flake8==3.5.0
future==0.15.2
gast==0.3.3
google-pasta==0.2.0
greenlet==0.4.12
grpcio==1.24.0
h5py==2.7.1
html5lib==0.999999999
httplib2==0.9.2
idna==2.6
imagesize==0.7.1
importlib-metadata==2.0.0
ipykernel==4.8.2
ipython==5.5.0
ipython-genutils==0.2.0
ipywidgets==6.0.0
isort==4.3.4
jedi==0.11.1
Jinja2==2.10
joblib==0.11
jsonschema==2.6.0
jupyter-client==5.2.2
jupyter-console==5.2.0
jupyter-core==4.4.0
Keras==2.3.1
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
keyring==10.6.0
keyrings.alt==3.0
language-selector==0.1
launchpadlib==1.10.6
lazr.restfulclient==0.13.5
lazr.uri==1.0.3
lazy-object-proxy==1.4.3
leveldb==0.1
llvmlite==0.31.0
logilab-common==1.4.1
louis==3.5.0
lxml==4.2.1
macaroonbakery==1.1.3
Mako==1.0.7
Markdown==2.6.9
MarkupSafe==1.0
matplotlib==2.1.1
mccabe==0.6.1
mistune==0.8.3
mkl-fft==1.0.15
mkl-random==1.1.0
mkl-service==2.3.0
msgpack==0.5.6
nbconvert==5.3.1
nbformat==4.4.0
neovim==0.2.0
netifaces==0.10.4
networkx==1.11
nose==1.3.7
nose-parameterized==0.3.4
notebook==5.2.2
numba==0.48.0
numexpr==2.6.4
numpy==1.19.2
numpydoc==0.7.0
nvidia-ml-py==7.352.0
oauth==1.0.1
olefile==0.46
optuna==2.2.0
packaging==20.4
PAM==0.4.2
pandas==0.22.0
pandocfilters==1.4.2
parso==0.1.1
pbr==5.5.0
pexpect==4.2.1
pickleshare==0.7.4
Pillow==7.0.0
pluggy==0.6.0
ply==3.11
prettytable==0.7.2
prompt-toolkit==1.0.15
protobuf==3.8.0
psutil==5.4.2
py==1.5.2
pycairo==1.16.2
pycocotools==2.0
pycodestyle==2.5.0
pycosat==0.6.3
pycparser==2.19
pycrypto==2.6.1
pycuda==2019.1.2
pycups==1.9.73
pydot==1.2.3
pyflakes==1.6.0
Pygments==2.2.0
pygobject==3.26.1
pygpu==0.7.6
PyICU==1.9.8
pyinotify==0.9.6
pylint==1.8.3
pymacaroons==0.13.0
PyNaCl==1.1.2
pyOpenSSL==17.5.0
pyparsing==2.2.0
pyperclip==1.8.0
pyRFC3339==1.0
pytest==3.3.2
python-apt==1.6.5+ubuntu0.2
python-dateutil==2.6.1
python-debian==0.1.32
python-editor==1.0.4
pytools==2017.6
pytz==2018.3
PyWavelets==0.5.1
pyxdg==0.25
PyYAML==3.12
pyzmq==16.0.2
QtAwesome==0.4.4
qtconsole==4.3.1
QtPy==1.3.1
reportlab==3.4.0
requests==2.18.4
requests-unixsocket==0.1.5
roman==2.0.0
rope==0.10.5
ruamel.yaml==0.16.10
ruamel.yaml.clib==0.2.0
scikit-cuda==0.5.3
scikit-image==0.13.1
scikit-learn==0.19.1
scipy==1.5.2
screen-resolution-extra==0.0.0
SecretStorage==2.3.1
simplegeneric==0.8.1
simplejson==3.13.2
six==1.14.0
Sphinx==1.6.7
spyder==3.2.6
SQLAlchemy==1.3.19
ssh-import-id==5.7
stevedore==3.2.2
system-service==0.3
systemd-python==234
tables==3.4.2
tensorboard==1.15.0
tensorflow-estimator==1.15.1
tensorflow-gpu==1.15.2
tensorflow-serving-api==1.15.0
termcolor==1.1.0
terminado==0.7
testpath==0.3.1
Theano==1.0.4
toolz==0.10.0
torch==1.3.1
torchvision==0.4.2
tornado==4.5.3
tqdm==4.50.1
traitlets==4.3.2
typed-ast==1.4.1
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
urllib3==1.22
usb-creator==0.3.3
virtualenv==15.1.0
virtualenv-clone==0.5.4
virtualenvwrapper==4.8.4
wadllib==1.3.2
wcwidth==0.1.7
webencodings==0.5
Werkzeug==0.16.0
wrapt==1.11.2
xkit==0.0.0
zipp==3.3.0
zope.interface==4.3.2