Complete steps for installing tensorflow-gpu using Anaconda under Ubuntu 18.0.4

Keywords: Anaconda Linux Python OpenCV

Environment: Ubuntu 18.0.4 X86_64

Anaconda X86_64

tensorflow-gpu=1.12.0

 

Step 1: Download Anaconda X86_64 to your specified path

1 | $ wget https://Repo.continuum.io/archive/Anaconda 2-4.2.0-Linux-x86_64.sh# 64-bit system
2 | $ wget https://Repo.continuum.io/archive/Anaconda 2-4.2.0-Linux-x86.sh#32-bit system

Anconda installation using bash instructions:

$ bash Anaconda3-4.2.0-Linux-x86_64.sh

Go straight back to OK.

After installation, use the instructions to view the installation results:

conda info

Step 2: New environment under anaconda

Use instructions to create your own environment and specify the python version

conda create -n your_env_name python=3.6

Use instructions to enter the newly created environment for tensorflow installation:

source activate your_env_name

Step 3: In order to improve the installation speed, the domestic mirror can be added in advance:

# Tsinghua mirror image
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

# Display channel address when setting search
conda config --set show_channel_urls yes


# Mirror image of China Science and Technology University
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

conda config --set show_channel_urls yes

Step 4: Install the corresponding libraries in the existing order

1. Installing numpy

2. Installing tensorflow-gpu

3. Install opencv

conda install numpy=1.15.1
conda install tensorflow-gpu=1.12.0
conda install opencv=4.0.0

Matters needing attention:

1. Ensure that CUDA and CUDN are installed on the server GPU and that the environment needs to be introduced into the environment variables of the new account:

# 1. Editing environment variables
vim ~/.bashrc

# 2. Add the following at the end of the document
# cuda-9.0
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

# 3. Use commands to verify the success of CUDA addition
nvcc -V

 

Posted by Brad on Mon, 30 Sep 2019 17:57:00 -0700