Solve the Linux Tensorflow2.0 installation problem

Solve the Linux Tensorflow2.0 installation problem
conda update conda
pip install tf-nightly-gpu-2.0-preview
conda install https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/cudnn-7.3.1-cuda10.0_0.tar.bz2
conda install https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/cudatoolkit-10.0.130-0.tar.bz2

illustrate:

  • First you need to update conda
  • The latest version of tf2.0 is installed
  • cudnn7.3.1 and cudatoolkit-10.0 versions can be downloaded and installed locally
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/cudnn-7.3.1-cuda10.0_0.tar.bz2
conda install cudnn-7.3.1-cuda10.0_0.tar.bz2

Errors and solutions

Old library problem

ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

The old version has many dependencies and cannot be deleted clearly. In this case, you should ignore the old version upgrade, which is the following solution: pip install tf-nightly-gpu-2.0-preview --ignore-installed wrapt

NumPy version problem

Another problem is that there is an old version of numpy. You can use pip to uninstall numpy until it prompts that there is nothing to uninstall, and then reinstall numpy

Driver issues

tensorflow.python.framework.errors_impl.InternalError: cudaGetDevice() failed. Status: CUDA driver version is insufficient for CUDA runtime version

This is because the driver version does not match. You can download the cuda10.0 driver (which is the same as above) from the NVIDIA official website.

Installation command: https://juejin.im/post/5cce44e3f265da036902a89c , then confirm all the way, and finally use watch nvidia-smi

View the results:


Testing and other

Tests available:

import tensorflow as tf
print(tf.__version__)
print(tf.keras.__version__)

if tf.test.is_gpu_available():
  device = "/gpu:0"
else:
  device = "/cpu:0"

print(device)

Reduce tensorflow output information

TensorFlow has four levels of log information, in ascending order of importance: INFO (notification) < WARNING (warning) < ERROR (error) < FATAL (fatal)

tf.compat.v1.logging.set_verbosity('ERROR')

or

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

Tensorflow2.0 prompts problems under pycharm

Tensorflow2.0 usually uses keras through tensorflow.keras, but pycharm does not prompt it. The reason is that the actual keras path is placed in tensorflow/python/keras, but there is no python directory in tensorflow in the program. The solution is as follows:

try:
  import tensorflow.python.keras as keras
except:
  import tensorflow.keras as keras

In this way, Pycharm can have prompts, and there is no need to modify the code when the program is running.

Summarize

The above is the editor's introduction to solving the Linux Tensorflow2.0 installation problem. I hope it will be helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Tensorflow-gpu has been installed, but keras cannot use GPU acceleration solution
  • Python 3.7 installation tutorial of keras and TensorFlow
  • Solve compatibility issues between Keras and Tensorflow versions

<<:  A brief analysis of MySQL explicit type conversion

>>:  Best Practices for MySQL Upgrades

Recommend

How to configure Linux to use LDAP user authentication

I am using LDAP user management implemented in Ce...

WeChat Mini Programs are shared globally via uni-app

In actual use, it is often necessary to share the...

Practical experience of implementing nginx to forward requests based on URL

Preface Because this is a distributed file system...

Pure CSS to achieve input box placeholder animation and input verification

For more exciting content, please visit https://g...

Steps to use ORM to add data in MySQL

【Foreword】 If you want to use ORM to operate data...

Implement a simple search engine based on MySQL

Table of contents Implementing a search engine ba...

Analysis of MySQL latency issues and data flushing strategy process

Table of contents 1. MySQL replication process 2....

Building a Redis cluster on Docker

Table of contents 1. Pull the image 2. Create a R...

MySQL replication table details and example code

MySQL replication table detailed explanation If w...

Detailed explanation of Javascript basics loop

Table of contents cycle for for-in for-of while d...

Research on the effect of page sidebar realized by JS

Table of contents Discover: Application of displa...

Mini Program to Implement the Complete Shopping Cart

The mini program implements a complete shopping c...

Keepalived+Nginx+Tomcat sample code to implement high-availability Web cluster

Keepalived+Nginx+Tomcat to achieve high availabil...