ubuntu16.04+cuda8.0+cudnnv5.1 + tensorflow+ GT 840M Installation Summary

Source: Internet
Author: User
Tags chmod stack trace cuda toolkit

Recently reinstalled the system, installed the TensorFlow configuration environment

Sum up.

Resources
http://blog.csdn.net/ZWX2445205419/article/details/69429518
http://blog.csdn.net/u013294888/article/details/56666023
Http://www.2cto.com/kf/201612/578337.html
http://blog.csdn.net/10km/article/details/61915535

Nvidia driver installation Method
Https://wiki.ubuntu.com.cn/NVIDIA

Query the NVIDIA Driver model
Http://www.nvidia.com/Download/index.aspx?lang=en-us

Query whether the GPU supports Cuda
Https://developer.nvidia.com/cuda-gpus
GeForce 840M 5.0

Nut Cloud Tray
Https://www.jianguoyun.com/s/downloads/linux



First step to install the Nivdia drive

0 switch off secure boot; This step is the most critical, otherwise it will not install!!!!

1 NVIDIA Graphics driver information
(1) View the model number of the video card
Install the video driver first. First look at your video card
Lspci | Grep-i VGA
Lspci | Grep-i nvidia
Then look at the graphics driver
Lsmod | Grep-i nvidia

#查看你的系统信息
Uname-m && Cat/etc/*release
# View Nuclear
Uname-r
# Kernel headers and development packages for the current nuclear installation
sudo apt-get install linux-headers-$ (uname-r)

2, pull Black nouveau
Ubuntu comes with a nouveau drive that affects cuda installation and improper operation can result in black screen and login loops
Running in Terminal:
Lsmod | grep nouveau
If there is an output, it means that Nouveau is loading.

Closing Method 1
2.1
Create/etc/modprobe.d/blacklist-nouveau.conf, write:
Blacklist nouveau
Options Nouveau modeset=0

Closing Method 2
2.2 First, disable open source drivers that can cause problems
Editor/etc/modprobe.d/blacklist.conf;
sudo gedit/etc/modprobe.d/blacklist.conf
Add a little bit of content:
Blacklist VGA16FB
Blacklist nouveau
Blacklist RIVAFB
Blacklist NVIDIAFB
Blacklist RIVATV


3 Installing NVIDIA graphics driver installation prior to uninstalling
sudo apt-get remove–purge nvidia-*

4 Installing the NVIDIA driver
In ubuntu16.04, it is very convenient to replace the drive to
Add driver, software update, system settings, switch to the latest Nvidia drivers. Restart with app change

Nvidia-smi
If a list of your GPUs appears, the driver installation is successful.
Alternatively, you can either pass or enter
Nvidia-settings
Appear
Installation drive Complete


Second installation of Cuda 8.0

1 command line install the. Run file
sudo sh cuda_8.0.61_375.26_linux.run

The following information may be available when you install Cuda

Installing the CUDA Toolkit in/usr/local/cuda-8.0 ...
Missing Recommended library:libGLU.so
Missing Recommended library:libX11.so
Missing Recommended library:libXi.so
Missing Recommended library:libXmu.so

sudo apt-get install Freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev LIBGL1-MESA-GLX Libglu1-mesa Libglu1-mesa-dev

Do you accept the previously read EULA?
Accept/decline/quit:accept

Install NVIDIA accelerated Graphics Driver for linux-x86_64 375.26?
(y) es/(n) o/(q) uit:n

Install the CUDA 8.0 Toolkit?
(y) es/(n) o/(q) uit:y

Enter Toolkit Location
[Default is/usr/local/cuda-8.0]:

Do you want to install a symbolic link At/usr/local/cuda?
(y) es/(n) o/(q) uit:y

Install the CUDA 8.0 Samples?
(y) es/(n) o/(q) uit:y

Enter CUDA Samples Location
[Default Is/home/maddock]:

Installing the CUDA Toolkit in/usr/local/cuda-8.0 ...
Installing the CUDA Samples in/home/maddock ...
Copying Samples To/home/maddock/nvidia_cuda-8.0_samples Now ...
Finished copying samples.

===========
= Summary =
===========

Driver:not Selected
Toolkit:installed in/usr/local/cuda-8.0
Samples:installed In/home/maddock

sure that
-PATH Includes/usr/local/cuda-8.0/bin
-Ld_library_path includes/usr/local/cuda-8.0/lib64, or, add/usr/local/cuda-8.0/lib64 to/etc/ld.so.conf and run Ldcon Fig as Root

To uninstall the CUDA Toolkit, run the uninstall script In/usr/local/cuda-8.0/bin

Please see Cuda_installation_guide_linux.pdf in/usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.

Warning:incomplete installation! This installation does not install the CUDA Driver. A driver of version at least 361.00 are required for CUDA 8.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of th is run File:
sudo <cudainstaller>.run-silent-driver

Logfile Is/tmp/cuda_install_20707.log


2 Setting environment variables

sudo vim ~/.BASHRC

Export Path=/usr/local/cuda-8.0/bin${path:+:${path}}
Export Ld_library_path=/usr/local/cuda8.0/lib64${ld_library_path:+:${ld_library_path}}


....................
Export ld_library_path= "$LD _library_path:/usr/local/cuda/lib64"
Export Cuda_home=/usr/local/cuda
....................
SOURCE ~/.BASHRC

To test Cuda's sammples, run the following command

Cd/usr/local/cuda-8.0/samples
sudo make all
CD./1_utilities/devicequery
sudo make
./devicequery

During the testing process
/USR/BIN/LD:-lnvcuvid not found
Collect2:error:ld returned 1 exit status
Makefile:381:recipe for Target ' Cudadecodegl ' failed

Https://askubuntu.com/questions/891003/failure-in-running-cuda-sample-after-cuda-8-0-installation
http://www.caffecn.cn/?/question/1109

$grep "nvidia-340"-r./
Replace Ubuntu_pkg_name = "nvidia-367" with ubuntu_pkg_name = "nvidia-375"
$sudo sed-i "s/nvidia-367/nvidia-375/g" ' grep nvidia-367-rl. '
Next $sudo make

After all compilation is complete, go to samples/bin/x86_64/linux/release, sudo run devicequery
sudo./devicequery

$sudo sed-i "s/nvidia-367/nvidia-375/g" ' grep nvidia-367-rl. '
Next $sudo make

After all compilation is complete, go to samples/bin/x86_64/linux/release, sudo run devicequery
sudo./devicequery

View Cuda's version
Nvcc-v


3 Installing CUDNN
After downloading it, it was found to be a tgz compressed package, extracted using tar
TAR-XVF cudnn-8.0-linux-x64-v6.0.tgz
Installation CUDNN is relatively simple, after extracting the corresponding files copied to the corresponding Cuda directory can be

sudo cp cuda/include/cudnn.h/usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn*/usr/local/cuda/lib64/
sudo chmod a+r/usr/local/cuda/include/cudnn.h
sudo chmod a+r/usr/local/cuda/lib64/libcudnn*


Upgrade time
Tar zxvf cudnn-8.0-linux-x64-v5.1.tgz #解压
CD Cuda/include #进入include目录
sudo cp cudnn.h/usr/local/cuda/include/#复制头文件
Cd.. /lib64 #进入lib64目录
sudo cp lib*/usr/local/cuda/lib64/#复制动态链接库
cd/usr/local/cuda/lib64/
sudo rm-rf libcudnn.so libcudnn.so.5 #删除原有动态文件

# following two steps to set up a soft connection,
Be sure to pay attention to your computer's/usr/local/cuda/lib64/under the libcudnn.so.5.1.5 name,
Some may be libcudnn.so.5.0.5 and so on, according to the files on their own computer to set

sudo ln-s libcudnn.so.5.1.5 libcudnn.so.5 #生成软链接
sudo ln-s libcudnn.so.5 libcudnn.so #生成软链接


sudo ln-s libcudnn.so.5.1.10 libcudnn.so.5 #生成软链接
sudo ln-s libcudnn.so.5 libcudnn.so #生成软链接


Part III Installation TensorFlow

Geek installation
Http://wiki.jikexueyuan.com/project/tensorflow-zh/get_started/os_setup.html
Https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/1-2-install
http://blog.csdn.net/u014516389/article/details/72818155/


1 Installing PIP

Install TensorFlow directly using PIP or PIP3
Install its dependencies first
$ sudo apt-get install python-pip Python-dev # for Python 2.7
$ sudo apt-get install Python3-pip Python3-dev # for Python 3.N

Check the PIP and Python versions
[Email protected]:~/project/dl/tensorflow/tf_install$ pip-v && python-v
Pip 8.1.1 from/usr/lib/python2.7/dist-packages (Python 2.7)
Python 2.7.12
[Email protected]:~/project/dl/tensorflow/tf_install$


2 Installing the TF

Pip Install Tensorflow-gpu
Downloading TENSORFLOW_GPU-1.2.1-CP27-CP27MU-MANYLINUX1_X86_64.WHL (89.2MB)

Successfully built Markdown Html5lib
Installing collected Packages:six, Funcsigs, PBR, Mock, numpy, Html5lib, Bleach, markdown, Wheel, Setuptools, Protobuf, b Ackports.weakref, Werkzeug, Tensorflow-gpu
Successfully installed Backports.weakref Bleach funcsigs html5lib markdown mock numpy PBR protobuf setuptools-20.7.0 six T Ensorflow-gpu Werkzeug wheel-0.29.0
You are using the PIP version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the ' pip install--upgrade pip ' command.


# Ubuntu/linux 64-bit, CPU only, Python 2.7:
$ sudo pip install--upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_ X86_64.whl

# ubuntu/linux 64-bit, GPU enabled, Python 2.7. Requires CUDA Toolkit 7.5 and CuDNN v4.
# for other versions, see "Install from sources" below.
$ sudo pip install--upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0-cp27-none-linux_ X86_64.whl


Latest version of TF
Https://pypi.python.org/pypi/tensorflow-gpu



TF upgrade S
1. I downloaded the current version of the latest, later if you need a new version

$ pip Install--upgrade TensorFlow

2. You can also log in to https://storage.googleapis.com/tensorflow/, see if there are updates, and then uninstall, and then change the corresponding location can be, but must uninstall the old version

$ pip Uninstall TensorFlow

So the TensorFlow environment is installed.




Q1

>>> Import TensorFlow as TF
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "/home/maddock/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line, in <module>
From Tensorflow.python Import *
File "/home/maddock/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line, in <module>
From Tensorflow.python import Pywrap_tensorflow
File "/home/maddock/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line-in < Module>
Raise Importerror (MSG)
Importerror:traceback (most recent):
File "/home/maddock/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line $, in < Module>
From tensorflow.python.pywrap_tensorflow_internal Import *
File "/home/maddock/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, In <module>
_pywrap_tensorflow_internal = Swig_import_helper ()
File "/home/maddock/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, In Swig_import_helper
_mod = Imp.load_module (' _pywrap_tensorflow_internal ', FP, pathname, description)
Importerror:libcusolver.so.8.0:cannot open Shared object file:no such file or directory


Failed to load the native TensorFlow runtime.

See Https://www.tensorflow.org/install/install_sources#common_installation_problems

For some common reasons and solutions. Include the entire stack trace
Above this error message is asking for help.

Slove


Found the solution:

I reinstalled nvidia-381, CUDA-8.0 (using the Runfile) and CuDNN 6.0. Then I added the following in my. BASHRC:

Export ld_library_path=/usr/local/cuda/lib64/


Q2

Importerror:libcudnn.so.5:cannot open Shared object file:no such file or directory


Slove

cd/usr/local/cuda/lib64/
sudo rm-rf libcudnn.so libcudnn.so.5 #删除原有动态文件

# following two steps to set up a soft connection,
Be sure to pay attention to your computer's/usr/local/cuda/lib64/under the libcudnn.so.5.1.5 name,
Some may be libcudnn.so.5.0.5 and so on, according to the files on their own computer to set

sudo ln-s libcudnn.so.5.1.10 libcudnn.so.5 #生成软链接
sudo ln-s libcudnn.so.5 libcudnn.so #生成软链接



[Email protected]:~$ python tf.py
2017-07-24 21:55:02.591533:w tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn ' t compiled To usage SSE4.1 instructions, but these is available on your machine and could speed up CPU computations.
2017-07-24 21:55:02.591566:w tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn ' t compiled To usage SSE4.2 instructions, but these is available on your machine and could speed up CPU computations.
2017-07-24 21:55:02.591573:w tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn ' t compiled To the use of AVX instructions, but these is available on your machine and could speed up CPU computations.
2017-07-24 21:55:02.591578:w tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn ' t compiled To usage AVX2 instructions, but these is available on your machine and could speed up CPU computations.
2017-07-24 21:55:02.591585:w tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn ' t compiled To use the FMA instructions, but these is available on the your machine and the could speed up CPU computations.
2017-07-24 21:55:02.897205:i tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] Successful NUMA node read from SysFS had negative value ( -1), but there must is at least one NUMA node, so returning NUMA node zero
2017-07-24 21:55:02.897628:i tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties:
Name:geforce 840M
Major:5 minor:0 memoryclockrate (GHz) 1.124
Pcibusid 0000:01:00.0
Total Memory:1.96gib
Free Memory:1.71gib
2017-07-24 21:55:02.897653:i tensorflow/core/common_runtime/gpu/gpu_device.cc:961] dma:0
2017-07-24 21:55:02.897662:i tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0:y
2017-07-24 21:55:02.897680:i tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating tensorflow device (/GPU : 0)--(device:0, Name:geforce 840M, PCI bus id:0000:01:00.0)
Hello, tensorflow!.
[Email protected]:~$












ubuntu16.04+cuda8.0+cudnnv5.1 + tensorflow+ GT 840M Installation Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.