GPU环境配置

  • 安装tensorflow

1.下载Anaconda并安装, https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda2-4.4.0-Linux-x86_64.sh

2.增加清华大学开源软件镜像站Anaconda仓库的镜像,提高package安装效率,运行以下命令:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.4.0 cudatoolkit==8.0

conda install -c https://pypi.tuna.tsinghua.edu.cn/simple tensorflow


conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --add channels http://mirrors.aliyun.com/pypi/simple/
conda config --set show_channel_urls yes

3.创建python2.7+tf_1.2.1版本,执行命令:
conda create --name python2.7_tf_1.2.1 python=2.7
激活环境,source activate python2.7_tf_1.2.1(退出环境,source deactivate python2.7_tf_1.2.1)
conda install tensorflow-gpu=1.2.1(想要其他版本,执行conda search tensorflow,找到对应版本安装即可)

conda install -c https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
安装完,测试一下。
$ python
>>> from tensorflow.python.client import device_lib
>>> print device_lib.list_local_devices()
[name: "/cpu:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 9675741273569321173
, name: "/gpu:0"
device_type: "GPU"
memory_limit: 11332668621
locality {
bus_id: 1
}
incarnation: 7807115828340118187
physical_device_desc: "device: 0, name: Tesla K80, pci bus id: 0000:00:04.0"
]

4.创建python3.6+tf_1.2.1版本,执行类似命令:
conda create --name python3.6_tf_1.2.1 python=3.6
激活环境,source activate python3.6_tf_1.2.1
conda install tensorflow-gpu=1.2.1
安装完,测试一下。

5.参考资料:
(1)https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
(2)http://www.jianshu.com/p/2f3be7781451
(3)https://tensorflow.feisky.xyz/install/gpu.html

Logo

更多推荐