Tensorflow learning 1 -- Installation without GPU on ubuntu 16.04

Tensorflow learning 1 – Installation without GPU on ubuntu 16.04


There are two ways of installing tensorflow on ubuntu, one is without GPU and the other is with NVIDIA GPU. Since I don’t have nvidia-gpu on my laptop, this article is about how to installation without GPU on ubuntu 16.04

  1. Installation in python virtual environment

    • set up python virtual environment
      python apt-get install python-dev python-pip python-virtualenv
    • create a virtual environment for tensorflow and choose the version of python you want with the following command:
      virtualenv --system-site-packages ~/tensorflow -p python3
      ps: you also can choose python 2, which depends on which version you perfer
    • activate the virtual environment,
      source ~/tensorflow/bin/activate
      the command should change your prompt to the following:
      (tensorflow)$
    • Issue the following command to install tensorflow in the active virtual environment
      pip3 install --upgrade tensorflow
      since we are using python3 for tensorflow, we have to use pip3.
      Notice: you cannot use sudo with this command since we are in the virtual environment.

    • To exit this environment,
      (tensorflwo)$ deactivate

    PS: For this way, we have to activate the virtual enviroment every single time with source ~/tensorflow/bin/activate to use tensorflow. otherwise, tensorflwo is not available.

  2. Verify if tensorflow is installed properly

    • activate virtual environment for tensorflow
      source ~/tensorflow/bin/activate
    • invoke python from your shell as follows
      python
    • Enter the following short program inside the python interactive shell:

    >>> import tensorflow as tf
    >>> hello = tf.constant(‘Hello, Tensorflow!’)
    >>> sess = tf.Session()
    >>> print(sess.run(hello))

  3. If the system outputs the following, then you are ready to write tensorflow programs:
    Hellow, Tensorflow!

  4. Congrats, you are able to use Tensorflow now! Start learning Tensorflow yourself.

    Sunday, 11. June 2017 04:49PM – Shuen

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值