Install tensorflow in ubuntu19.10 system

1. Comparison of various versions of tensorflow

Before installing tensorflow, pay attention to the relationship between the cuda version and cudnn version corresponding to each tensorflow version, and then install it. The following list is the tensorflow-gpu version corresponding to each cuda and cudnn version.
Linux version

LinuxCPU
LinuxGPUMacOS corresponding version
MacOSCPU
MacOSGPU

2. Install CUDA+CUDNN

The CUDA environment is a hardware acceleration library commonly used in deep learning, and will not be described in detail here. For the installation process, refer to the author's another blog Ubuntu installation CUDA and CUDNN tutorial .

3. Modify the link file

The environment used by the author is ubuntu19.10, as well as CUDA10.2 and CUDNN7.6.5. But currently tensorflow has not released the cuda10.2 installation package for tensorflow-gpu, so the following situation will occur when tensorflow-2.2.0 is installed in this situation:
Test oneso tensorflow-gpu 2.2.0 can not be used. There are two ways to solve this problem. The first method is to directly use the bazel tool to compile from the source code, generate the whl file and install it. This method will not be described for the time being. In a later article, how to build the tensorflow installation package from the source code will be described. Interested friends can view The source code construction method of official documents . The second is to modify the soft link of the library file. In order to make tensorflow-gpu2.2.0 use the cuda10.2 library file, you only need to create a soft link between the following two files

cd /usr/local/cuda-10.2/targets/x86_64-linux/lib/
ln -s libcudart.so.10.2.89 libcudart.so.10.1

cd /usr/local/cuda-10.2/extras/CUPTI/lib64
ln -s libcupti.so.10.2.75 libcupti.so.10.1

In this way, tensorflow will use the cuda10.2 library as cuda10.1.
The test results are shown below to
Test Resultssee how many GPU devices can be used.

Test result two

reference

[1] tensorflow2.x uses cuda10.2
[2] Zhihu Q&A

Guess you like

Origin blog.csdn.net/Zhang_Pro/article/details/107009456