CS-FreeStyle / 10000-How-To-Do-in-CS

1 stars 0 forks source link

tensorflow install and uninstall on Ubuntu #38

Open liuty10 opened 5 years ago

liuty10 commented 5 years ago

pip3 uninstall tensorflow-gpu pip3 install --upgrade tensorflow-gpu==1.4

liuty10 commented 5 years ago

install CUDA:

Download from : https://developer.nvidia.com/cuda-80-ga2-download-archive

Installation Instructions: sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb sudo apt-get update sudo apt-get install cuda

liuty10 commented 5 years ago

!/bin/bash

install CUDA Toolkit v8.0

instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))

CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb" wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG} sudo dpkg -i ${CUDA_REPO_PKG} sudo apt-get update sudo apt-get -y install cuda

install cuDNN v6.0

CUDNN_TAR_FILE="cudnn-8.0-linux-x64-v6.0.tgz" wget http://developer.download.nvidia.com/compute/redist/cudnn/v6.0/${CUDNN_TAR_FILE} tar -xzvf ${CUDNN_TAR_FILE} sudo cp -P cuda/include/cudnn.h /usr/local/cuda-8.0/include sudo cp -P cuda/lib64/libcudnn /usr/local/cuda-8.0/lib64/ sudo chmod a+r /usr/local/cuda-8.0/lib64/libcudnn

set environment variables

export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

liuty10 commented 5 years ago

https://gist.github.com/mjdietzx/0ff77af5ae60622ce6ed8c4d9b419f45

liuty10 commented 5 years ago

Summary: nvidia driver first, then tensorflow-gpu==1.4 cuda8.0 cudnn6.0 Then, you can use tensorflow:

import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))

liuty10 commented 5 years ago

~/Downloads/bin/protoc ./object_detection/protos/*.proto --python_out=.

From tensorflow/models/research/

export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

liuty10 commented 5 years ago

I have encountered some problems. So, I changed my version to: tensorflow1.13.1, cuda10.0, cuDNN7.4.2

  1. install Nvidia drivers: Driver Version: 410.78 CUDA Version: 10.0 Follow instructions here: https://github.com/CS-FreeStyle/10000-How-To-Do-in-CS/issues/33

  2. tensorflow 1.13 sudo pip3 uninstall tensorflow-gpu sudo pip3 install --upgrade tensorflow-gpu==1.13

  3. cuda 10.0.130 https://developer.nvidia.com/cuda-10.0-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=deblocal Follow the instructions that it gives.

  4. Download cuDNN v7.4.2 (Dec 14, 2018), for CUDA 10.0 https://developer.nvidia.com/rdp/cudnn-archive $ sudo dpkg -i xxx.deb

or, you can, $ tar -xvzf cudnn-xxx-linux-x64-v5.1.tgz $ cd cuda $ sudo cp include/cudnn.h /usr/local/cuda/include $ sudo cp lib64/libcudnn.* /usr/local/cuda/lib64

Now, you can use tensorflow:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

But, if you want to use tensorflow API, you need the following steps:

  1. Download models from git: https://github.com/tensorflow/models

  2. Set PATHONPATH From tensorflow/models/research/ $ export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

  3. Download proc and compile: https://github.com/protocolbuffers/protobuf/releases Download protoc-3.7.0-linux-x86_64.zip $ mkdir protoc-3.7 $ cd protoc-3.7 $ unzip protoc-3.7.0-linux-x86_64.zip

  4. Then, compile with protoc From tensorflow/models/research/ $ protoc object_detection/protos/*.proto --python_out=.

  5. Then, you should be able to use API for training.

  6. But for evaluation, you still need to install COCOAPI.

liuty10 commented 5 years ago

ATTENTION: Follow steps here https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#coco-api-installation

liuty10 commented 5 years ago

If you use tensorboard:

https://www.ctolib.com/topics-125559.html

liuty10 commented 5 years ago

Debian reference: https://blog.csdn.net/star_code/article/details/76616958

liuty10 commented 4 years ago

How to install Nvidia 1080Ti Driver: (Two ways)

  1. Download NVIDIA-Linux-x86_64-390.77.run driver http://www.nvidia.com/Download/index.aspx?lang=en-in Choose the proper driver for you GPU.
  2. ctrl-alt-F1 enter command mode
  3. sudo service lightdm stop
  4. sudo apt-get purge nvidia* Or sudo nvidia-uninstall
  5. sudo vim /etc/modprobe.d/blacklist-nouveau.conf blacklist nouveau options nouveau modeset=0 :wq
  6. sudo update-initramfs –u
  7. lspci | grep nouveau
  8. sudo reboot(after uninstall nvidia drivers, you need reboot ubuntu)
  9. ALT+CTRL+F1
  10. sudo service lightdm stop
  11. sudo ./ NVIDIA-Linux-x86_64-390.77.run In this step you may can not install lib32 even you choose to install it.
  12. sudo service lightdm start
  13. login
  14. nvidia-smi
  15. reboot. You can reboot without login loop. You can also download some CUDA toolchain here: https://developer.nvidia.com/cuda-toolkit-archive if you trap in the login loop, use the following command to get out and reinstall the driver again: sudo NVIDIA-Linux-x86_64-390.77.run --uninstall sudo NVIDIA-Linux-x86_64-390.77.run --no-opengl-files #不安装opengl文件,也就不使用n卡显示。

Another way to install Nvidia driver is to use command: sudo ubuntu-drivers autoinstall In this way, you can install the recommended drivers for this particular system. It may be more stable and reliable.

Install cuda 10.01 https://developer.nvidia.com/cuda-80-ga2-download-archive Installation Instructions: Run sudo sh cuda_8.0.61_375.26_linux.runFollow the command-line prompts

  1. accept
  2. Uncheck Nvidia driver, because you already installed the driver. export PATH=/usr/local/cuda/bin:${PATH} export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64