安裝Anaconda2
到 Anaconda installer archive 下載需要的 Anaconda 版本
Anaconda2 使用的是 python2
Anaconda3 使用的是 python3
後面為作業系統種類,像我的是 linux ubuntu 64位元,就選擇 Linux-x86_64
首先出現以下文字
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
按enter鍵繼續
Do you accept the license terms? [yes|no]
[no] >>> yes
Anaconda2 will now be installed into this location:
/home/jason-lin/anaconda2
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/jason-lin/anaconda2] >>>
PREFIX=/home/jason-lin/anaconda2
安裝後會出現
installation finished.
Do you wish the installer to prepend the Anaconda2 install location
to PATH in your /home/jason-lin/.bashrc ? [yes|no]
[no] >>> yes
Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
>>> no
在終端機輸入
python
出現
Python 2.7.14 |Anaconda, Inc.| (default, Dec 7 2017, 17:05:42)
[GCC 7.2.0] on linux2
安裝成功!!!!
從源碼編譯tensorflow
安裝 Bazel
從 https://github.com/bazelbuild/bazel/releases 下載適當的 Bazel 版本
在終端機輸入
chmod +x bazel-<version>-installer-linux-x86_64.sh
./bazel-<version>-installer-linux-x86_64.sh --user
設定環境變數
在終端機輸入:
sudo gedit ~/.bashrc
在文件最後加上
export PATH="$PATH:$HOME/bin"
在終端機輸入:
source ~/.bashrc
sudo ldconfig -v
下載tensorflow源碼
git clone tensorflow/tensorflow tensorflow-r1.7
git checkout r1.7
./configure
configure設定
You have bazel 0.11.1 installed.
Please specify the location of python. [Default is /home/jason-lin/anaconda2/bin/python]:
Found possible Python library paths:
/home/jason-lin/anaconda2/lib/python2.7/site-packages
Please input the desired Python library path to use. Default is [/home/jason-lin/anaconda2/lib/python2.7/site-packages]
Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: y
jemalloc as malloc support will be enabled for TensorFlow.
Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: y
Google Cloud Platform support will be enabled for TensorFlow.
Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: Y
Hadoop File System support will be enabled for TensorFlow.
Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: Y
Amazon S3 File System support will be enabled for TensorFlow.
Do you wish to build TensorFlow with Apache Kafka Platform support? [y/N]: N
No Apache Kafka Platform support will be enabled for TensorFlow.
Do you wish to build TensorFlow with XLA JIT support? [y/N]: N
No XLA JIT support will be enabled for TensorFlow.
Do you wish to build TensorFlow with GDR support? [y/N]: N
No GDR support will be enabled for TensorFlow.
Do you wish to build TensorFlow with VERBS support? [y/N]: N
No VERBS support will be enabled for TensorFlow.
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: N
No OpenCL SYCL support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: Y
CUDA support will be enabled for TensorFlow.
Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to default to CUDA 9.0]: 9.1
Please specify the location where CUDA 9.1 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7.0]: 7.1.2
Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Do you wish to build TensorFlow with TensorRT support? [y/N]: N
No TensorRT support will be enabled for TensorFlow.
Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: CUDA GPUs.
Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 6.1]6.1
Do you want to use clang as CUDA compiler? [y/N]: N
nvcc will be used as CUDA compiler.
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
Do you wish to build TensorFlow with MPI support? [y/N]: N
No MPI support will be enabled for TensorFlow.
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: -march=native
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: N
Not configuring the WORKSPACE for Android builds.
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details.
--config=mkl # Build with MKL support.
--config=monolithic # Config for mostly static monolithic build.
Configuration finished
在終端機輸入:
sudo ln -s /usr/local/cuda/include/crt/math_functions.hpp /usr/local/cuda/include/math_functions.hpp
bazel build --config=opt --config=mkl --config=cuda --incompatible_load_argument_is_label=false //tensorflow/tools/pip_package:build_pip_package
完成之後,輸入
bazel-bin/tensorflow/tools/pip_package/build_pip_package tensorflow_pkg
cd tensorflow_pkg
~/anaconda2/bin/pip install ./tensorflow-1.7.1-cp27-cp27mu-linux_x86_64.whl
完成!!!!
安裝pycharm
先在pycharm官網下載安裝包
將pycharm-community-2018.1.1.tar.gz解壓
在終端機輸入:
cd ~/pycharm/bin/
sh ./pycharm.sh