almost 2 years ago

參考 http://tensorflow.org/get_started/os_setup.md#try_your_first_tensorflow_program

1. 安裝

1.1. python 相關工具

$ sudo apt-get install python-numpy python-scipy python-dev python-pip git

1.2. Ubuntu/Linux - tensorflow CPU 版

# Ubuntu/Linux 64-bit, CPU only:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl

1.2'. Ubuntu/Linux - tensorflow GPU 版

# Ubuntu/Linux 64-bit, GPU enabled:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl

CPU 版本與 GPU 版本擇一安裝,若安裝 CPU 版本可直接執行測試範例,檢視是否安裝成功。

1.3. 執行測試範例

$ python test.python
test.py
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print sess.run(hello)
a = tf.constant(10)
b = tf.constant(32)
print sess.run(a+b)

2. tensorflow GPU 版選項,下載與安裝 Cuda Toolkit 7.0

http://www.tensorflow.org/get_started/os_setup.html#install_cuda

2.1. 下載

https://developer.nvidia.com/cuda-toolkit-70

Linux X86 > Ubuntu 14.10 > RUN

2.2. 安裝

$ sudo sh ./cuda_7.0.28_linux.run

2.2.1. 說明文件

--More--(0%)
  1. Enter 繼續閱讀
  2. ctrl+D 略過

2.2.2. 安裝選項

  1. Do you accept the previously read EULA? (accept/decline/quit): accept
  2. You are attempting to install on an unsupported configuration. Do you wish to continue? ((y)es/(n)o) [ default is no ]: y
  3. Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 346.46? ((y)es/(n)o/(q)uit): y
  4. Do you want to install the OpenGL libraries? ((y)es/(n)o/(q)uit) [ default is yes ]: y
  5. Install the CUDA 7.0 Toolkit? ((y)es/(n)o/(q)uit): y
  6. Enter Toolkit Location [ default is /usr/local/cuda-7.0 ]: [按下Enter]
  7. Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y
  8. Install the CUDA 7.0 Samples? ((y)es/(n)o/(q)uit): y
  9. Enter CUDA Samples Location [ default is /home/user ]: [按下Enter]

開始安裝
Installing the NVIDIA display driver...

直到沒有錯誤,即安裝成功
Driver: Installed
Toolkit: Installed in /usr/local/cuda-7.0
Samples: Installation /home/user

2.2.3. 設定環境變數

  1. 在家目錄新增檔案 .bashrc 加入以下指令,存檔。
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
    export CUDA_HOME=/usr/local/cuda
    
  2. 重新載入
    $ source .bashrc
    

2.3. 常見安裝錯誤&要求

可至 /tmp/cuda_install_*.log 、/var/log/nvidia-installer.log 閱讀錯誤說明。

2.3.1. 要求停用 x server

錯誤訊息:

ERROR: You appear to be running an X server; please exit X before
       installing.  For further details, please see the section INSTALLING
       THE NVIDIA DRIVER in the README available on the Linux driver

解決方案:

$ sudo /etc/init.d/mdm stop

Hint: Cuda Toolkit 整個安裝完記得重新啟動 x server

$ sudo /etc/init.d/mdm start

2.3.3. 要求刪除舊版驅動程式

$ sudo apt-get remove --purge nvidia-352 nvidia-modprobe nvidia-settings

2.4. 執行範例的錯誤

2.4.1. 尚未安裝 cuda

錯誤訊息:

ImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory

解決方案:
2. tensorflow GPU 版選項,下載與安裝 Cuda Toolkit 7.0

2.4.2. 找不到 cuda 裝置

錯誤訊息:

I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 
16 modprobe: ERROR: could not insert 'nvidia': No such device 
E tensorflow/stream_executor/cuda/cuda_driver.cc:466] failed call to cuInit: CUDA_ERROR_NO_DEVICE

解決方案:

刪除所有 nvidia tools

$ sudo rm -R /usr/local/cuda/
$ sudo rm -R /usr/local/cuda-7.0/

重新安裝

$ sudo apt-get install nvidia-current nvidia-settings
$ sudo nvidia-xconfig
$ sudo reboot

2. tensorflow GPU 版選項,下載與安裝 Cuda Toolkit 7.0 重新開始

// http://www.tecmint.com/install-nvidia-drivers-in-linux/

← Java - Spring Boot Starter Web - Model(2) - BaseEntity Eclipse 常用快速鍵 →
 
comments powered by Disqus