AI学习一:环境安装
2018-01-09 23:58
411 查看
对于Python开发用户来讲,PIP安装软件包是家常便饭。但国外的源下载速度实在太慢,浪费时间。而且经常出现下载后安装出错问题。所以把PIP安装源替换成国内镜像,可以大幅提升下载速度,还可以提高安装成功率。
国内源:
新版ubuntu要求使用https源,要注意。
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple 例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。
永久修改,一劳永逸:
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install]
trusted-host=mirrors.aliyun.com
windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。
部分安装示例:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scipy
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -U scikit-learn
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
测试代码:
运行结果:
[[12]]
国内源:
新版ubuntu要求使用https源,要注意。
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple 例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。
永久修改,一劳永逸:
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install]
trusted-host=mirrors.aliyun.com
windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。
部分安装示例:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scipy
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -U scikit-learn
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
测试代码:
from tensorflow import Session, device, constant, matmul '''构建一个只有两个constant做输入, 然后进行矩阵乘的简单图:''' # 如果不使用with session()语句, 需要手动执行session.close(). # with device设备指定了执行计算的设备: # "/cpu:0": 机器的 CPU. # "/gpu:0": 机器的第一个 GPU, 如果有的话. # "/gpu:1": 机器的第二个 GPU, 以此类推. with Session() as session: # 创建执行图的上下文 with device('/cpu:0'): # 指定运算设备 mat1 = constant([[3, 3]]) # 创建源节点 mat2 = constant([[2], [2]]) product = matmul(mat1, mat2) # 指定节点的前置节点, 创建图 result = session.run(product) # 执行计算 print(result)
运行结果:
[[12]]
相关文章推荐
- Win10环境下使用WSL安装OpenAI/gym +TensorFlow用强化学习DQN打砖块(Breakout Game)
- ROS学习(基于Ubuntu 15.04 和ROS Jade)第三章 ROS核心教程 之 1 安装和配置你的ROS环境
- 深度学习框架-caffe安装-环境[Mac OSX 10.12]
- 步步学习python之环境安装:Vagrant+Ubuntu+Emacs+Virtualenv+Python3开发环境的搭建(Mac电脑下)4
- MongoDB学习(二)Windows环境安装MongoDB
- 【opencv学习笔记一】opencv下载安装与VS2017开发环境配置
- Hibernate入门学习(2)----Hibernate Tools的安装及环境的搭建
- Cocos2d-x学习之windows 7的visual studo 2010开发环境安装
- Docker学习:Centos7的环境安装
- 【Andriod 学习笔记1】--环境安装与配置
- PHP学习总结(8)——PHP入门篇之WAMPServer集成环境安装和配置
- 【修正版】Python基础学习(一)——安装与配置python2.7.x环境(linux)
- 搭建Oracle RAC 学习环境之---数据库集群软件安装
- 学习笔记:window7环境下的nodejs与npm安装。
- Neural Style学习2——环境安装
- 在Linux下JAVA环境的安装 JDK6.0(Linux 学习)
- go学习(一)--Go语言环境的安装
- ES6 学习笔记 (2)-- Liunx环境安装Node.js 与 搭建 Node.js 开发环境
- 深度学习(1)LINUX下深度学习环境安装
- JNI学习及jdk安装环境变量配置