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

Solution to Nginx 500 Internal Server Error

Today, when I was using Nginx, a 500 error occurr...

Summary of various postures of MySQL privilege escalation

Table of contents 1. Write Webshell into outfile ...

How to handle token expiration in WeChat Mini Programs

Table of contents Conclusion first question Solut...

Detailed explanation of Vue's sync modifier

Table of contents 1. Instructions 2. Modifiers 3....

MySQL 8.0.12 winx64 detailed installation tutorial

This article shares the installation tutorial of ...

WeChat applet implements a simple dice game

This article shares the specific code of the WeCh...

Vue.js performance optimization N tips (worth collecting)

Table of contents Functionalcomponents Childcompo...

What is this in JavaScript point by point series

Understand this Perhaps you have seen this in oth...

CSS example code for implementing sliding doors

The so-called sliding door technology means that ...

SQL implementation of LeetCode (196. Delete duplicate mailboxes)

[LeetCode] 196.Delete Duplicate Emails Write a SQ...

Design of pop-up windows and floating layers in web design

In the trend of gradual transition from tradition...

40 fonts recommended for famous website logos

Do you know what fonts are used in the logo desig...

JavaScript implementation of a simple addition calculator

This article example shares the specific code of ...