[Linux] tf.keras non-root installations CUDA and cuDNN

TensorFlow 2.0 for Linux error when using: (low cuDNN version)

E tensorflow/stream_executor/cuda/cuda_dnn.cc:319] Loaded runtime CuDNN library: 7.4.1 but source was compiled with: 7.6.0.  CuDNN library major and minor version needs to match or have higher minor version in case of CuDNN 7.0 or later version. If using a binary install, upgrade your CuDNN library.  If building from sources, make sure the library loaded at runtime is compatible with the version specified during compile configuration.
...
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above. [Op:Conv2D]

Workaround: Upgrade cuDNN. TF 2.0 and CUDA 10.0, cuDNN 7.6.4 are matched.

root user

Linux server if the user has root privileges, then delete the original cuDNN, and then reinstall the new version.
Delete the existing cuDNN:

sudo rm -rf /usr/local/cuda/include/cudnn.h
sudo rm -rf /usr/local/cuda/lib64/libcudnn*

cuda file after entering cuDNN extract the folder, install the new version:

sudo cp include/cudnn.h /usr/local/cuda/include/
sudo cp lib64/lib* /usr/local/cuda/lib64/

:( establish a flexible connection to 7.6.4 version, for example)

cd /usr/local/cuda/lib64/
sudo chmod +r libcudnn.so.7.6.4
sudo ln -sf libcudnn.so.7.6.4 libcudnn.so.7
sudo ln -sf libcudnn.so.7 libcudnn.so   
sudo ldconfig

Non-root user

If you do not have root privileges, a practice of their own re-installed CUDA and cuDNN.

CUDA installed in the user directory

From the official website https://developer.nvidia.com/cuda-10.0-download-archive download ubuntu cuda_10.0.130_410.48_linux.run use, installation instructions sh cuda_10.0.130_410.48_linux.run, then:

# 按q退出协议说明. 
 
Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48?
(y)es/(n)o/(q)uit: no

Install the CUDA 10.0 Toolkit?
(y)es/(n)o/(q)uit: yes

# 改成自己的用户名
Enter Toolkit Location
 [ default is /usr/local/cuda-10.0 ]: /home/wuliyttaotao/cuda-10.0

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: n

Install the CUDA 10.0 Samples?
(y)es/(n)o/(q)uit: y

# 使用默认路径,回车
Enter CUDA Samples Location
 [ default is /home/wuliyttaotao ]:    

Configuration cuDNN

Copy the file to the CUDA cuDNN installation directory: (cuDNN extract to ~/cudaa directory, and ~/cuda-10.0set itself CUDA installation directory, ~on behalf of / home / wuliyttaotao)

cp ~/cuda/include/cudnn.h ~/cuda-10.0/include
cp ~/cuda/lib64/lib* ~/cuda-10.0/lib64

chmod a+r ~/cuda-10.0/include/cudnn.h ~/cuda-10.0/lib64/libcudnn*

Soft establish the connection:

cd ~/cuda-10.0/lib64
ln -sf libcudnn.so.7.6.4 libcudnn.so.7
ln -sf libcudnn.so.7 libcudnn.so
ldconfig -v

Configure the user environment variables

Modify the ~/.bashrcfile, the following two lines will be added to the list :( wuliyttaotao change your user name)

export PATH=/home/wuliyttaotao/cuda-10.0/bin${PATH:+:${PATH}}  
export LD_LIBRARY_PATH=/home/wuliyttaotao/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Save ~/.bashrcthe file, source ~/.bashrcput it into effect.

References

The Linux cudnn upgrade method - ZONG_XP
non-root installation of a plurality of versions and at linux CUDA cuDNN (cuda 8, cuda 10.1, etc.) - casual attracted whisk

Guess you like

Origin www.cnblogs.com/wuliytTaotao/p/12169315.html