机器学习入门(3):Ubuntu16.04环境搭建玩TensorFlow | 100%实战
off999 2024-09-27 13:44 26 浏览 0 评论
上文讲到了成功安装anaconda和pycharm。没有找到合适的支持python3.7的tensorflow,故重新下载python3.6,方法和机器学习入门(1)类似。
主要内容:ubuntu16.04配置anaconda+tensorflow新手教程
前提:机器学习入门(2)已经安装好了anaconda
(1)直接在terminal中输入conda
rookie@ubuntu:~$ conda -V
conda 4.5.11
(2)输入指令conda info --envs
rookie@ubuntu:~$ conda info --envs
# conda environments:
#
base * /home/rookie/anaconda3
(3)创建虚拟环境
rookie@ubuntu:~$ conda create --name tf1 python=3.6
输入Y之后,创建成功输入如下:
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate tf1
#
# To deactivate an active environment, use
#
# $ conda deactivate
再次输入指令conda info --envs
rookie@ubuntu:~$ conda info --envs
# conda environments:
#
base * /home/rookie/anaconda3
tf1 /home/rookie/anaconda3/envs/tf1
(4)激活虚拟环境:(就是进入到这个虚拟环境里面)
rookie@ubuntu:~$ source activate tf1
(tf1) rookie@ubuntu:~$
PS:如果要退出:输入source deactivate tf
(5)在虚拟环境里安装tensorflow(cpu版本)
conda install tensorflow
参考https://blog.csdn.net/m0_37864814/article/details/82112029
The following packages will be downloaded:
package | build
---------------------------|-----------------
mkl-2017.0.3 | 0 129.5 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
The following NEW packages will be INSTALLED:
backports: 1.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
backports.weakref: 1.0rc1-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
blas: 1.0-mkl https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
bleach: 1.5.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
html5lib: 0.9999999-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libprotobuf: 3.4.0-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
markdown: 2.6.9-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
mkl: 2017.0.3-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
numpy: 1.13.1-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
protobuf: 3.4.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
six: 1.10.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow: 1.3.0-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow-base: 1.3.0-py36h5293eaa_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow-tensorboard: 0.1.5-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
werkzeug: 0.12.2-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
Proceed ([y]/n)? y
Downloading and Extracting Packages
mkl-2017.0.3 | 129.5 MB | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(6)测试tensorflow,安装成功
(tf1) rookie@ubuntu:~$ python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linuxType "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>>
(7)conda命令总结
参考https://blog.csdn.net/zongza/article/details/83039210
(8)执行命令conda install theano(theano是一个深度学习框架)
输出如下:
The following NEW packages will be INSTALLED:
libgfortran: 3.0.0-1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libgpuarray: 0.6.9-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
mako: 1.0.6-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
markupsafe: 1.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
mkl-service: 1.1.2-py36_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
nose: 1.3.7-py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pygpu: 0.6.9-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
scipy: 0.19.1-np113py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
theano: 0.9.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
Proceed ([y]/n)? y
Downloading and Extracting Packages
libgfortran-3.0.0 | 281 KB | ################################################################################################################################################################# | 100%
mako-1.0.6 | 115 KB | ################################################################################################################################################################# | 100%
nose-1.3.7 | 201 KB | ################################################################################################################################################################# | 100%
mkl-service-1.1.2 | 15 KB | ################################################################################################################################################################# | 100%
scipy-0.19.1 | 36.3 MB | ################################################################################################################################################################# | 100%
markupsafe-1.0 | 31 KB | ################################################################################################################################################################# | 100%
libgpuarray-0.6.9 | 211 KB | ################################################################################################################################################################# | 100%
pygpu-0.6.9 | 1.3 MB | ################################################################################################################################################################# | 100%
theano-0.9.0 | 4.0 MB | ################################################################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(9)安装keras
参考https://blog.csdn.net/qq_31802027/article/details/73655965
先输入git clone https://github.com/fchollet/keras.git
再cd keras/
其次python setup.py install
git clone https://github.com/fchollet/keras.git输出如下:
Downloading and Extracting Packages
libgfortran-3.0.0 | 281 KB | ################################################################################################################################################################# | 100%
mako-1.0.6 | 115 KB | ################################################################################################################################################################# | 100%
nose-1.3.7 | 201 KB | ################################################################################################################################################################# | 100%
mkl-service-1.1.2 | 15 KB | ################################################################################################################################################################# | 100%
scipy-0.19.1 | 36.3 MB | ################################################################################################################################################################# | 100%
markupsafe-1.0 | 31 KB | ################################################################################################################################################################# | 100%
libgpuarray-0.6.9 | 211 KB | ################################################################################################################################################################# | 100%
pygpu-0.6.9 | 1.3 MB | ################################################################################################################################################################# | 100%
theano-0.9.0 | 4.0 MB | ################################################################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(tf1) rookie@ubuntu:~$ keras
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'
(tf1) rookie@ubuntu:~$ keras -V
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'
(tf1) rookie@ubuntu:~$ git clone https://github.com/fchollet/keras.git
Cloning into 'keras'...
remote: Enumerating objects: 32203, done.
remote: Total 32203 (delta 0), reused 0 (delta 0), pack-reused 32203
Receiving objects: 100% (32203/32203), 12.66 MiB | 8.00 KiB/s, done.
Resolving deltas: 100% (23492/23492), done.
Checking connectivity... done.
python setup.py install
报错:
In file included from /tmp/easy_install-2giks2je/h5py-2.9.0/h5py/defs.c:642:0:
/tmp/easy_install-2giks2je/h5py-2.9.0/h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
明天再来看吧,晚安!
这期间遇到了很多问题,我还有两个问题没有解决,如果有朋友有类似的问题,可以交流;希望有前辈指教。
第一个就是我先安装了python3.7.4,然后再安装python3.6.4的时候,安装失败,报错。说空间不够,然后我百度看怎么解决,有个命令如下,发现有个/dev/sda1把磁盘占满了,然后一直没有解决。现在删掉了一些东西,占比只有80%,然后python3.6.4得以安装成功,但是这个问题花费了不少时间,还没有解决!!!
root@ubuntu:/dev# df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.5G 0 1.5G 0% /dev
tmpfs 298M 4.9M 294M 2% /run
/dev/sda1 19G 18G 1.8M 100% /
tmpfs 1.5G 212K 1.5G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 1.5G 0 1.5G 0% /sys/fs/cgroup
tmpfs 298M 44K 298M 1% /run/user/1000
第二个是我在终端输入python,python3时,它出现的版本为什么总是python3.7.0。
使用的命令如下
rm -rf /usr/bin/python3
sudo ln -s /home/rookie/Desktop/local/python3.6.4/bin/python3.6 /usr/bin/python3
原来我先下载的python3.7.4,链接的是python3.7.0。之后下载了python3.6.4,我想把python和python3改成链接python3.6.4。命令是如上 ,但是在root模式下,是python3.6.4,但是在普通用户模式下,仍然还是python3.7.0。所以这个是为什么,我也是没有解决!!!
相关推荐
- Linux 网络协议栈_linux网络协议栈
-
前言;更多学习资料(包含视频、技术学习路线图谱、文档等)后台私信《资料》免费领取技术点包含了C/C++,Linux,Nginx,ZeroMQ,MySQL,Redis,fastdfs,MongoDB,Z...
- 揭秘 BPF map 前生今世_bpfdm
-
1.前言众所周知,map可用于内核BPF程序和用户应用程序之间实现双向的数据交换,为BPF技术中的重要基础数据结构。在BPF程序中可以通过声明structbpf_map_def...
- 教你简单 提取fmpeg 视频,音频,字幕 方法
-
ffmpeg提取视频,音频,字幕方法(HowtoExtractVideo,Audio,SubtitlefromOriginalVideo?)1.提取视频(ExtractVi...
- Linux内核原理到代码详解《内核视频教程》
-
Linux内核原理-进程入门进程进程不仅仅是一段可执行程序的代码,通常进程还包括其他资源,比如打开的文件,挂起的信号,内核内部的数据结构,处理器状态,内存地址空间,或多个执行线程,存放全局变量的数据段...
- Linux C Socket UDP编程详解及实例分享
-
1、UDP网络编程主要流程UDP协议的程序设计框架,客户端和服务器之间的差别在于服务器必须使用bind()函数来绑定侦听的本地UDP端口,而客户端则可以不进行绑定,直接发送到服务器地址的某个端口地址。...
- libevent源码分析之bufferevent使用详解
-
libevent的bufferevent在event的基础上自己维护了一个buffer,这样的话,就不需要再自己管理一个buffer了。先看看structbufferevent这个结构体struct...
- 一次解决Linux内核内存泄漏实战全过程
-
什么是内存泄漏:程序向系统申请内存,使用完不需要之后,不释放内存还给系统回收,造成申请的内存被浪费.发现系统中内存使用量随着时间的流逝,消耗的越来越多,例如下图所示:接下来的排查思路是:1.监控系统中...
- 彻底搞清楚内存泄漏的原因,如何避免内存泄漏,如何定位内存泄漏
-
作为C/C++开发人员,内存泄漏是最容易遇到的问题之一,这是由C/C++语言的特性引起的。C/C++语言与其他语言不同,需要开发者去申请和释放内存,即需要开发者去管理内存,如果内存使用不当,就容易造成...
- linux网络编程常见API详解_linux网络编程视频教程
-
Linux网络编程API函数初步剖析今天我们来分析一下前几篇博文中提到的网络编程中几个核心的API,探究一下当我们调用每个API时,内核中具体做了哪些准备和初始化工作。1、socket(family...
- Linux下C++访问web—使用libcurl库调用http接口发送解析json数据
-
一、背景这两天由于一些原因研究了研究如何在客户端C++代码中调用web服务端接口,需要访问url,并传入json数据,拿到返回值,并解析。 现在的情形是远程服务端的接口参数和返回类型都是json的字符...
- 平衡感知调节:“系统如人” 视角下的架构设计与业务稳定之道
-
在今天这个到处都是数字化的时代,系统可不是一堆冷冰冰的代码。它就像一个活生生的“数字人”,没了它,业务根本转不起来。总说“技术要为业务服务”,但实际操作起来问题不少:系统怎么才能快速响应业务需求?...
- 谈谈分布式文件系统下的本地缓存_什么是分布式文件存储
-
在分布式文件系统中,为了提高系统的性能,常常会引入不同类型的缓存存储系统(算法优化所带来的的效果可能远远不如缓存带来的优化效果)。在软件中缓存存储系统一般可分为了两类:一、分布式缓存,例如:Memca...
- 进程间通信之信号量semaphore--linux内核剖析
-
什么是信号量信号量的使用主要是用来保护共享资源,使得资源在一个时刻只有一个进程(线程)所拥有。信号量的值为正的时候,说明它空闲。所测试的线程可以锁定而使用它。若为0,说明它被占用,测试的线程要进入睡眠...
- Qt编写推流程序/支持webrtc265/从此不用再转码/打开新世界的大门
-
一、前言在推流领域,尤其是监控行业,现在主流设备基本上都是265格式的视频流,想要在网页上直接显示监控流,之前的方案是,要么转成hls,要么魔改支持265格式的flv,要么265转成264,如果要追求...
- 30 分钟搞定 SpringBoot 视频推拉流!实战避坑指南
-
30分钟搞定SpringBoot视频推拉流!实战避坑指南在音视频开发领域,SpringBoot凭借其快速开发特性,成为很多开发者实现视频推拉流功能的首选框架。但实际开发中,从环境搭建到流处理优...
你 发表评论:
欢迎- 一周热门
- 最近发表
- 标签列表
-
- python计时 (73)
- python安装路径 (56)
- python类型转换 (93)
- python进度条 (67)
- python吧 (67)
- python的for循环 (65)
- python格式化字符串 (61)
- python静态方法 (57)
- python列表切片 (59)
- python面向对象编程 (60)
- python 代码加密 (65)
- python串口编程 (77)
- python封装 (57)
- python写入txt (66)
- python读取文件夹下所有文件 (59)
- python操作mysql数据库 (66)
- python获取列表的长度 (64)
- python接口 (63)
- python调用函数 (57)
- python多态 (60)
- python匿名函数 (59)
- python打印九九乘法表 (65)
- python赋值 (62)
- python异常 (69)
- python元祖 (57)