How to install Tensorflow under ubuntu 16.04

1、 Check if gcc is installed in the system

sudo gcc --version

If the system does not have gcc installed, it will prompt command not found. Install gcc first at this time.

sudo apt-get build-dep gcc

The command apt-get build-dep (packagename) means to install the relevant compilation environment.

sudo apt-get install build-essential

2、 Verify the System has the Correct Kernel Headers and Development Packages Installed

The kernel headers and development packages for the currently running kernel can be installed with:

( uname -r)

3、 Download cuda tookit 9.0 (version 9.2 cannot be used)

Pay attention to download the deb version, 16.04 local version.

The CUDA Toolkit can be installed using either of two different installation mechanisms: distribution-specific packages (RPM and Deb packages), or a distribution-independent package (runfile packages). The distribution-independent package has the advantage of working across a wider set of Linux distributions, but does not update the distribution's native package management system. The distribution-specific packages interface with the distribution's native package management system. It is recommended to use the distribution-specific packages, where possible.

4、 Turn off nouveau driver###

Create a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents:

blacklist nouveau options nouveau modeset=0

Can be executed on the command line

sudo sh -c 'echo "blacklist nouveau" >> /etc/modprobe.d/blacklist-nouveau.conf'

sudo sh -c 'echo "options nouveau modeset=0" >> /etc/modprobe.d/blacklist-nouveau.conf'

Regenerate the kernel initramfs:

$ sudo update-initramfs -u

$ sudo reboot

Use command

lsmod | grep nouveau

If there is no output, the shutdown is successful

5、 Install repository meta-data

If it is a non-216 machine, remount the shared folder after restarting

sudo mount -t cifs -o username=ai,password=fs95536! //172.19.62.216/download216 /home/ai/download216

$ sudo dpkg -i cuda-repo-.deb

For example, our

$ sudo dpkg -i /home/ai/download216/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb

6、 Installing the CUDA public GPG key

When installing using the local repo:

$ sudo apt-key add /var/cuda-repo-/7fa2af80.pub

For example, here we are

sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub

7、 Update the Apt repository cache

$ sudo apt-get update

8、 Install CUDA

$ sudo apt-get install cuda-libraries-9-0

9、 Install cuda driver###

Dependent packages that may be required to install the driver

sudo apt-get update

sudo apt-get install dkms build-essential linux-headers-generic gcc-multilib

install driver

$sudo chmod u+x /home/ai/download216/NVIDIA-Linux-x86_64-390.87.run

$sudo /home/ai/download216/NVIDIA-Linux-x86_64-390.87.run --dkms -s

The following warning can be ignored

WARNING: nvidia-installer was forced to guess the X library path '/usr/lib' and X module path '/usr/lib/xorg/modules'; these paths were not queryable from the system. If X fails to find the NVIDIA X driver module, please install the pkg-config utility and the X.Org SDK/development package for your distribution and reinstall the driver.

Test the driver after installation

nvidia-smi

If there is information output, the installation is successful

It can be tested without restarting the system

Restart the system#####

If it is a non-216 machine, remount the shared folder after restarting

sudo mount -t cifs -o username=ai,password=fs95536! //172.19.62.216/download216 /home/ai/download216

10、 Environment Setup

The PATH variable needs to include /usr/local/cuda-9.0/bin

To add this path to the PATH variable:

{ PATH:+:${PATH}}

In addition, when using the runfile installation method, the LD_LIBRARY_PATH variable needs to contain /usr/local/cuda-9.0/lib64 on a 64-bit system, or /usr/local/cuda-9.0/lib on a 32-bit system

To change the environment variables for 64-bit operating systems:

export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64

{ LD_LIBRARY_PATH}}

11、 Install cuda patch###

The download in the code below for non-216 machines should be changed to download216

sudo dpkg -i /home/ai/download216/cuda-repo-ubuntu1604-9-0-local-cublas-performance-update_1.0-1_amd64.deb

sudo dpkg -i /home/ai/download216/cuda-repo-ubuntu1604-9-0-local-cublas-performance-update-2_1.0-1_amd64.deb

sudo dpkg -i /home/ai/download216/cuda-repo-ubuntu1604-9-0-local-cublas-performance-update-3_1.0-1_amd64.deb

sudo dpkg -i /home/ai/download216/cuda-repo-ubuntu1604-9-0-176-local-patch-4_1.0-1_amd64.deb

12、 Install cudnn

Unzip the installation package of .solitairetheme8, the package with the suffix is all Linux platforms

The download in the code below for non-216 machines should be changed to download216

cp /home/ai/download216/cudnn-9.0-linux-x64-v7.1.solitairetheme8 cudnn-9.0-linux-x64-v7.1.tgz

tar -xzvf cudnn-9.0-linux-x64-v7.1.tgz

Copy the following files into the CUDA Toolkit directory.

sudo cp cuda/include/cudnn.h /usr/local/cuda-9.0/include

sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h (not needed for this sentence)

》sudo chmod a+r /usr/local/cuda-9.0/lib64/libcudnn

13、 Install libcupti-dev library###

sudo apt-get install cuda-command-line-tools-9-0

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/extras/CUPTI/lib64

14、 Install anacoda

sudo bash /home/ai/download216/Anaconda3-5.2.0-Linux-x86_64.sh

Update source

source ~/.bashrc

Upgrade conda to the latest version

sudo chown -R ai:ai /home/ai/anaconda3

conda update -n base conda

Upgrade the installation package to the latest version

conda update --all

15、 Create a conda environment called tensorflow to run a certain version of Python

conda create -n tensorflow pip python=3.5

16、 Activate the conda environment###

source activate tensorflow

17、 Install TensorFlow

pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.6.0-cp35-cp35m-linux_x86_64.whl (Due to network problems, this method is not recommended)
recommend:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --ignore-installed --upgrade tensorflow-gpu

pip install ipykernel

conda install jupyter notebook

18、 Configure jupyter notebook remote login###

jupyter notebook --generate-config

$ jupyter notebook password Enter password: **** Verify password: **** [NotebookPasswordApp] Wrote hashed password to /home/ai/.jupyter/jupyter_notebook_config.json

Find the following line in jupyter_notebook_config.py, uncomment and modify it.

c.NotebookApp.ip='*' c.NotebookApp.password = u'sha:ce.../home/ai/.jupyter/jupyter_notebook_config.json The content in' c.NotebookApp.open_browser = False c.NotebookApp.port =8888 #You can specify a port by yourself, use the port when accessing

Recommended Posts

How to install Tensorflow under ubuntu 16.04
How to install vim editor under Linux (Ubuntu 18.04)
How to install gcc compiler faster under Ubuntu
How to install Helm in Ubuntu
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install TensorFlow on CentOS 8
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install mysql in Ubuntu 14.04
How to install Memcached on Ubuntu 18.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
How to install two versions of OpenCV under ubuntu?
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install mysql in Ubuntu 14.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install Docker Compose on Ubuntu 18.04
How to install Ubuntu on Raspberry Pi
How to install Bacula Server on Ubuntu 14.04