Ubuntu16.04 installs the old version tensorflow==1.8.0 environment configuration

        I have to run a framework recently, and the recommended version configuration is tensorflow 1.8.0. Obviously, new versions above 2.0 cannot be used. I encountered many problems when installing the old version. Record the process.

        Only after installing an old version can you understand the role of Anaconda environment control. The old version of tensorflow installed is not only a problem of the old version, but also has its own limitations for each library. For example, python is only compatible with 3.5 and 3.6, and cuda must also be installed with version 9.0.


Table of contents

1. Anaconda installation and environment creation and activation

1.1 Anaconda installation

1.2 Anaconda environment creation and activation

2. Installation of tensorflow1.8.0 and cuda9.0


1. Anaconda installation and environment creation and activation

1.1 Anaconda installation

        For installation, please refer to this blog: Detailed steps for installing Anaconda on Ubuntu (Ubuntu21.10, Anaconda3)_Fengzi's blog in Luobei Village-CSDN blog

        1. Download the .sh file from the official website: Anaconda | The World's Most Popular Data Science Platform Anaconda is the birthplace of Python data science. We are a movement of data scientists, data-driven enterprises, and open source communities. https://www .anaconda.com/         2. Place the installation package in the appropriate location. Generally, just put a folder under /home/user/, then open the terminal in this folder and enter:

bash Anaconda3-2021.11-Linux-x86_64.sh

        Note that the name of the corresponding installation package is correct, this may be different. Generally, a folder installation of Anaconda3 will be created under the /home/user/ folder.

        3. Keep pressing Enter, and sometimes the option to enter yes appears. There is an option in the middle to select the location. Generally, entering yes will create a folder installation of Anaconda3 under the /home/user/ folder.

        Finally, Anaconda is installed and can be used to manage the environment.

1.2 Anaconda environment creation and activation

        After Anaconda is installed, the terminal usually becomes

(base)xxxxxxxxxxxxx $

        The previous base is the codename of the current Anaconda environment. With some simple commands, you can create a separate environment. For example, we want to create an environment to store tensorflow1.8.0 and name it tf18:

conda create -n 环境名称 依赖库

        Actual operation:

conda create -n tf18 python=3.6 pip

        The installation library can be installed later by yourself through the pip install command.

        After that, we need to activate the environment. Generally, when we reopen the terminal, it defaults to the base environment. If necessary, we should use the activation command to switch to the corresponding environment:        

source activate tf18

        In this way we switch to the corresponding environment.

2. Installation of tensorflow1.8.0 and cuda9.0

        Note: To query the python and cuda version restrictions of the old version of tensorflow, you can go to: Build from source code in Windows environment | TensorFlow

For queries, there are also some blogs written about Baidu.

        The tensorflow installation mainly limits the following versions. The command is:

pip install tensorflow==1.8.0
pip install tensorflow-gpu==1.8.0
conda install tensorflow==1.8.0
conda install tensorflow-gpu==1.8.0

        You can use pip or conda. If you need a gpu, use the gpu version.

        If you need numpy, pandas, opencv-python, you can download it yourself. Pay attention to whether the version can be used (usually if it is not suitable, an error will be reported later, when a certain program is running)

        If you choose the gpu version, you need to install cuda and cudnn.

        1. Note: At this time, you need to note that different Anaconda environments need to limit the corresponding cuda version, otherwise the old version of tensorflow cannot configure the higher version of cuda. To specify the cuda version for the environment, you can refer to this article:

Specify cuda for the virtual environment - Zhihu

       Note: The corresponding operation needs to be done in the base environment. You may not have enough permissions to enter the environment you set.

        2. After specifying the version, you can install cuda9.0 and cudnn7.xx by specifically installing tensorflow1.8.0. Reference blog:

ubuntu16.04 creates a virtual environment through anaconda, installs cuda9.0, cudnn7.1.2_QxwOnly's blog-CSDN blog

        After entering the environment, set the source and install the corresponding version.

source activate tf18

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

conda install cudatoolkit=9.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/

conda install cudnn=7.1.2

Guess you like

Origin blog.csdn.net/weixin_43907136/article/details/129346252