百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术资源 > 正文

机器学习入门(3):Ubuntu16.04环境搭建玩TensorFlow | 100%实战

off999 2024-09-27 13:44 36 浏览 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。所以这个是为什么,我也是没有解决!!!

相关推荐

戴尔官网官方网站(戴尔产品官网)

查询步骤如下:1.在戴尔电脑的后盖上找到服务编号,并记录下来。2.之后搜索戴尔官网,在打开的官网界面中点击上方的支持选项,并点击产品支持。3.在打开的产品支持界面中,输入电脑后盖上的服务编号。4.如果...

黑鲨u盘重装系统教程(黑鲨u盘重装系统步骤8)

U盘重装WIn10系统:1、用【u深度u盘启动盘制作工具】制作u盘启动盘,插入电脑usb接口,设置好开机启动项进入u深度主菜单界面,选择“【02】u深度win8pe标准版(新机器)”并回车,2、在u深...

电子邮件免费注册入口(电子邮件在线注册)

1.在网页上搜索maiI163邮箱登录,如果有邮箱账号密码的话就直接输入并点击“登录”,没有的话就点击“立即注册”。2.点击“立即注册”后进入页面,输入信息点击“注册”。3.注册成功后就直接搜索登录。...

win7如何快速启动(windows7如何快速启动)
win7如何快速启动(windows7如何快速启动)

打开操作系统运行:输入"cmd"并点击回车:系统命令提示符自动打开:使用方法直接运行start打开一个新的命令提示符窗口:运行start+文件的绝对存储路径打开对应的文件:运行start+文件夹路径打开对应...

2025-12-29 13:03 off999

怎么升级到win11(怎么升级到win11专业版)

Windows11可以在「开始菜单-设置-Windows更新」中进行手动更新。如果您想主动更新,需先确保您的电脑符合Windows11的最低系统要求。接着,打开「Windows更...

微信好友误删了怎么加回来(微信好友误删了怎么加回来免费)

看到他的评论的话,你可以去你发过的内容里去看看。<br/><br/>好友验证的消息、语音)或者朋友圈内容:<br/>如果你这个朋友喜欢和你在朋友圈聊天的话,你他的手机号也有的话方法添加里输入就可...

access安装包(access安装包怎么安装)
access安装包(access安装包怎么安装)

要下载并安装MicrosoftAccess,可以按照以下步骤进行操作:1.打开您的电脑的浏览器(如谷歌浏览器、火狐浏览器等)。2.在浏览器的搜索栏中输入"下载MicrosoftAccess"。3.从搜索结果中选择适...

2025-12-29 11:51 off999

云骑士装机大师官方网站(云骑士装机大师软件下载)

就是感觉正规吧,还有就是小白那种的比较多,专业店一忽悠就掏钱做系统了。懂装机的哪有花钱去装系统的不靠谱,因为会造成个人信息的泄露。云骑士装机大师是网络装机系统,在网络上能够实现一键装机,非常的简洁方便...

万能钥匙下载免费(安心上网万能钥匙下载免费)

行1.使用手机功能表中自带的浏览器上网,直接搜索需要的软件进行下载安装(下载安卓版本格式为apk)。2.使用电脑下载APK格式的安装包,连接数据线传输至手机,操作手机在应用程序-我的文件中找到安装包,...

500兆宽带用什么路由器(家用路由器什么牌子好 信号强)

1、飞鱼星千兆无线路由器家用2600M双频企业级高速穿墙500M光纤游戏加速VW1900/千兆双频/1900M/大型企业路由器无线500m推荐理由:可以提供企业级别的性能,空旷环境覆盖更广大,...

xp系统怎么卸载软件(xp怎么卸载程序)

1、选中此电脑,点击鼠标右键。2、选择属性点击一下。3、在打开的界面选择控制面板。4、点击程序选项下方的卸载。5、选择要卸载的程序软件,点击鼠标右键。6、点击弹出的选项卸载/更改。7、也可以使用电脑管...

笔记本电脑系统修复软件(笔记本电脑程序修复)

1、超级兔子2013系统修复软件超级兔子是一款完整的系统维护工具。拥有电脑系统评测、垃圾清理和注册表清理、可疑文件和插件检测、网页防护等功能,同时自带一些实用的系统工具,可清理你大多数的文件、注册表里...

联想保修服务包括哪些(联想保修都保修什么)

1、保修36个月的硬件包括:CPU、内存。2、保修24个月的硬件包括:主板、显卡、LCD屏、硬盘、电源适配器、键盘、鼠标模块。3、保修12个月的硬件包括:LCD之附件、光驱、DVD、CDR/W、软驱...

系统科学大会(中国系统科学学会)

2021年各种科学大会的召开时间取决于疫情的发展和国家政策的调整。一些大型的国际科学会议可能会推迟或者采用线上形式进行,以保障参会人员的安全和健康。同时,一些国内的学术会议也会受到疫情的影响,需要推迟...

win10系统下载的内容在哪(win10下载的软件在哪个文件夹)

进入C:\Windows\SoftwareDistribution\Download目录下,通过win10应用商店中下载的安装包都放在此目录下。进入C:\Windows\SoftwareDistrib...

取消回复欢迎 发表评论: