Tensorflow Environment Setup

Tensorflow with cpu is fine if the project does not involve in huge workload of calculation, and the installation for tensorflow-cpu is quite simple (just install it with command like “conda install tensorflow” or “pip install tensorflow”).

If we want to use tensorflow-gpu, we can follow the instructions below.
The order of setting up is:

  1. GPU driver
  2. Cuda
  3. Cudnn
  4. Tensorflow-gpu

The version of the GPU driver to be installed is determined according to what kind of GPU it is in our computer, and the correspondence between them can be found at NVIDIA website (https://www.geforce.com/drivers).

The last three components are relevant and most difficult part to be set. Cuda of a certain version can only link to cudnn of a corresponding version, and they support tensorflow of some certain versions. The correspondence between them can be found at the websites (for windows: https://www.tensorflow.org/install/source_windows; for ubuntu: https://www.tensorflow.org/install/source).

For windows:
在这里插入图片描述

For linux:
在这里插入图片描述

It is suggested to use python 3.5, because python 3.7 does not support tensorflow now and python 3.6 cannot fit several relevant packages. The tools of the old version may be out of fashion but they are stable. Do not get the newest conda, if python 3.5 is going to be installed. Find the one of a proper version, since the newest one only supports python 3.7 (June, 2019).

Before setting up, make a decision:
The first thing needs to be considered is for what purpose it will be used. If we want to run other’s codes using tensorflow, we would better to know when this code is released before setting up an environment for that, because we may need to install tensorflow of an old version which is used in that code. That means we cannot install the latest cuda and cudnn.
Then we have to make a decision:
a. set up the environment with those components of an older version;
b. set up the environment with those components of the newest version and then re-write some parts of the code to fit the environment.

It is up to you. However, this decision is worthy of consideration, and the reason is the methods of package application may be slightly different as before, which means we need to learn how to use these new-version packages if we re-write codes. For instance, a number of functions in keras change after the version 2.1.6.

Here is an example to install tensorflow:

  1. install GPU driver (many computers have it in default)
    在这里插入图片描述

  2. cuda
    在这里插入图片描述
    a. In the installation process, we can choose not to install NVIDIA Accelerated Graphics Driver, because we already have it.

    b. After the installation, we type the command “nvcc --verison” for checking whether it is installed successfully or not.
    在这里插入图片描述

  3. Cudnn
    在这里插入图片描述
    Decompress the cudnn file downloaded, and then move the three sub-files “bin”, “include” and “lib” into the corresponding files (“bin”, “include”, “lib”) in the directory “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0”. Add this directory in system path.

  4. tensorflow
    It is strongly suggested to install tensorflow via conda. The visual C++ build tools 2015 is the pre-requisite of tensorflow, and it can be installed automatically with tensorflow by conda “conda install -c conda-forge tensorflow”.

This is how to set up the environment for tensorflow projects, but it is not exactly all the stuff needed. In practice, there are some other packages that need to be installed. One simple way to deal with it is just to run the project and then solve the instantiated warning or error one by one.

Good luck.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值