I was also facing the same problem and creating a conda environment with an environment.yml file solved the issue for me. The content of the .yml file are as follows: Please make sure to provide your system path in the last line of the code. eg. "/home/nikhilanand_1921cs24" should be replaced with your system path.
name: keras-gpu
channels:
- conda-forge
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=4.5=1_gnu
- _tflow_select=2.1.0=gpu
- absl-py=0.13.0=py39h06a4308_0
- aiohttp=3.8.1=py39h7f8727e_0
- aiosignal=1.2.0=pyhd3eb1b0_0
- astor=0.8.1=py39h06a4308_0
- astunparse=1.6.3=py_0
- async-timeout=4.0.1=pyhd3eb1b0_0
- attrs=21.2.0=pyhd3eb1b0_0
- blas=1.0=mkl
- blinker=1.4=py39h06a4308_0
- brotli=1.0.9=h7f98852_5
- brotli-bin=1.0.9=h7f98852_5
- brotlipy=0.7.0=py39h27cfd23_1003
- c-ares=1.17.1=h27cfd23_0
- ca-certificates=2021.10.8=ha878542_0
- cachetools=4.2.2=pyhd3eb1b0_0
- certifi=2021.10.8=py39hf3d152e_1
- cffi=1.14.6=py39h400218f_0
- charset-normalizer=2.0.4=pyhd3eb1b0_0
- click=8.0.3=pyhd3eb1b0_0
- cryptography=3.4.8=py39hd23ed53_0
- cudatoolkit=10.1.243=h6bb024c_0
- cudnn=7.6.5=cuda10.1_0
- cupti=10.1.168=0
- cycler=0.11.0=pyhd8ed1ab_0
- dataclasses=0.8=pyh6d0b6a4_7
- dbus=1.13.6=he372182_0
- expat=2.2.10=h9c3ff4c_0
- fontconfig=2.13.1=h6c09931_0
- fonttools=4.25.0=pyhd3eb1b0_0
- freetype=2.10.4=h0708190_1
- frozenlist=1.2.0=py39h7f8727e_0
- gast=0.4.0=pyhd3eb1b0_0
- glib=2.69.1=h4ff587b_1
- google-auth=1.33.0=pyhd3eb1b0_0
- google-auth-oauthlib=0.4.4=pyhd3eb1b0_0
- google-pasta=0.2.0=pyhd3eb1b0_0
- grpcio=1.42.0=py39hce63b2e_0
- gst-plugins-base=1.14.0=hbbd80ab_1
- gstreamer=1.14.0=h28cd5cc_2
- h5py=2.10.0=py39hec9cf62_0
- hdf5=1.10.6=hb1b8bf9_0
- icu=58.2=hf484d3e_1000
- idna=3.3=pyhd3eb1b0_0
- importlib-metadata=4.8.2=py39h06a4308_0
- intel-openmp=2021.4.0=h06a4308_3561
- jpeg=9d=h7f8727e_0
- keras-preprocessing=1.1.2=pyhd3eb1b0_0
- kiwisolver=1.3.1=py39h2531618_0
- lcms2=2.12=hddcbb42_0
- ld_impl_linux-64=2.35.1=h7274673_9
- libbrotlicommon=1.0.9=h7f98852_5
- libbrotlidec=1.0.9=h7f98852_5
- libbrotlienc=1.0.9=h7f98852_5
- libffi=3.3=he6710b0_2
- libgcc-ng=9.3.0=h5101ec6_17
- libgfortran-ng=7.5.0=ha8ba4b0_17
- libgfortran4=7.5.0=ha8ba4b0_17
- libgomp=9.3.0=h5101ec6_17
- libpng=1.6.37=h21135ba_2
- libprotobuf=3.17.2=h4ff587b_1
- libstdcxx-ng=9.3.0=hd4cf53a_17
- libtiff=4.2.0=h85742a9_0
- libuuid=1.0.3=h7f8727e_2
- libwebp-base=1.2.0=h27cfd23_0
- libxcb=1.13=h7f98852_1003
- libxml2=2.9.12=h03d6c58_0
- lz4-c=1.9.3=h9c3ff4c_1
- markdown=3.3.4=py39h06a4308_0
- matplotlib=3.4.3=py39hf3d152e_2
- matplotlib-base=3.4.3=py39hbbc1b5f_0
- mkl=2021.4.0=h06a4308_640
- mkl-service=2.4.0=py39h7f8727e_0
- mkl_fft=1.3.1=py39hd3c417c_0
- mkl_random=1.2.2=py39h51133e4_0
- multidict=5.1.0=py39h27cfd23_2
- munkres=1.1.4=pyh9f0ad1d_0
- ncurses=6.3=h7f8727e_2
- numpy=1.21.2=py39h20f2e39_0
- numpy-base=1.21.2=py39h79a1101_0
- oauthlib=3.1.1=pyhd3eb1b0_0
- olefile=0.46=pyh9f0ad1d_1
- openssl=1.1.1m=h7f8727e_0
- opt_einsum=3.3.0=pyhd3eb1b0_1
- pcre=8.45=h9c3ff4c_0
- pip=21.2.4=py39h06a4308_0
- protobuf=3.17.2=py39h295c915_0
- pthread-stubs=0.4=h36c2ea0_1001
- pyasn1=0.4.8=pyhd3eb1b0_0
- pyasn1-modules=0.2.8=py_0
- pycparser=2.21=pyhd3eb1b0_0
- pyjwt=2.1.0=py39h06a4308_0
- pyopenssl=21.0.0=pyhd3eb1b0_1
- pyparsing=3.0.7=pyhd8ed1ab_0
- pyqt=5.9.2=py39h2531618_6
- pysocks=1.7.1=py39h06a4308_0
- python=3.9.7=h12debd9_1
- python-dateutil=2.8.2=pyhd8ed1ab_0
- python-flatbuffers=2.0=pyhd3eb1b0_0
- python_abi=3.9=2_cp39
- qt=5.9.7=h5867ecd_1
- readline=8.1=h27cfd23_0
- requests=2.26.0=pyhd3eb1b0_0
- requests-oauthlib=1.3.0=py_0
- rsa=4.7.2=pyhd3eb1b0_1
- scipy=1.7.1=py39h292c36d_2
- setuptools=58.0.4=py39h06a4308_0
- sip=4.19.13=py39h295c915_0
- six=1.16.0=pyhd3eb1b0_0
- sqlite=3.36.0=hc218d9a_0
- tensorboard-plugin-wit=1.6.0=py_0
- tensorflow-estimator=2.6.0=pyh7b7c402_0
- termcolor=1.1.0=py39h06a4308_1
- tk=8.6.11=h1ccaba5_0
- tornado=6.1=py39h3811e60_1
- typing-extensions=3.10.0.2=hd3eb1b0_0
- typing_extensions=3.10.0.2=pyh06a4308_0
- tzdata=2021e=hda174b7_0
- urllib3=1.26.7=pyhd3eb1b0_0
- werkzeug=2.0.2=pyhd3eb1b0_0
- wheel=0.37.0=pyhd3eb1b0_1
- wrapt=1.13.3=py39h7f8727e_2
- xorg-libxau=1.0.9=h7f98852_0
- xorg-libxdmcp=1.1.3=h7f98852_0
- xz=5.2.5=h7b6447c_0
- yarl=1.6.3=py39h27cfd23_0
- zipp=3.6.0=pyhd3eb1b0_0
- zlib=1.2.11=h7f8727e_4
- zstd=1.4.9=ha95c52a_0
- pip:
- joblib==1.1.0
- keras==2.8.0
- keras-applications==1.0.8
- libclang==13.0.0
- opencv-python==4.5.5.62
- pandas==1.4.0
- pillow==9.0.1
- pytz==2021.3
- pyyaml==6.0
- scikit-learn==1.0.2
- tensorboard==2.8.0
- tensorboard-data-server==0.6.1
- tensorflow==2.8.0
- tensorflow-gpu==2.8.0
- tensorflow-io-gcs-filesystem==0.23.1
- tf-estimator-nightly==2.8.0.dev2021122109
- threadpoolctl==3.0.0
prefix: /home/nikhilanand_1921cs24/anaconda3/envs/keras-gpu
Create the environment by runningconda env create -f environment.yml
0... and it is detected.