TensorFlow(7):jupyter notebook docker image 使用root 进行安装软件

本文详细介绍如何在Docker环境中配置并使用TensorFlow,包括解决权限问题、安装依赖及运行物体识别、手写识别等模型。同时介绍了Google的Python代码规范和CycleGAN-TensorFlow项目。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言


本文的原文连接是: https://blog.youkuaiyun.com/freewebsys/article/details/81665552
未经博主允许不得转载。
博主地址是:http://blog.youkuaiyun.com/freewebsys

1,关于


上次在 https://blog.youkuaiyun.com/freewebsys/article/details/84847904
中使用了jupyter的镜像。
可以直接运行python了。
但是这个镜像为了安全,使用的是 jovyan 账户。
要是使用apt-get进行安装的话,没有权限。
通过修改机几个参数就可以了。

https://github.com/jupyter/docker-stacks/issues/408

2,使用


docker run -itd --name tf -v ~/pythonWorkspace:/home/jovyan -p 8888:8888 \
	-e GRANT_SUDO="yes"  --user root \
	jupyter/tensorflow-notebook:latest  start-notebook.sh \
	--NotebookApp.token='' --notebook-dir=/home/jovyan

其中两个参数 -e GRANT_SUDO=“yes” --user root 得加上。
这样就能用 root 了。
同时把 token 去掉。本地使用方便。要是服务器上面可别去掉。
使用的是 jupyter tensorflow的镜像。Python 3.6.6
而TensorFlow 的 python 是 3.5 。

vim /etc/apt/sources.list

ubuntu 18.04(bionic) 配置如下
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

安装pip3

apt-get install python3-pip
pip3 install --user -r official/requirements.txt

3,tensorflow models


可以下载 google 官方的 models 代码。
https://github.com/tensorflow/models

安装依赖文件
pip3 install --user -r official/requirements.txt

对物体识别进行运行:

https://github.com/tensorflow/models/tree/master/research/object_detection

在这里插入图片描述

对手写识别测试:
https://github.com/tensorflow/models/tree/master/official/mnist

resNet 网络:
https://github.com/tensorflow/models/tree/master/official/resnet

文章翻译:
https://github.com/tensorflow/models/tree/master/official/transformer

wide deep:
https://github.com/tensorflow/models/tree/master/official/wide_deep

思路都是先训练模型,然后用 saved_model_cli 把结果跑起来。

3,Google Python Style Guide


https://github.com/google/styleguide/blob/gh-pages/pyguide.md
google 发布的 python 代码规范。

3,CycleGAN-TensorFlow


在这里插入图片描述
cycleGan 还是非常厉害的,让图片进行学习。
合成其他图片。
https://junyanz.github.io/CycleGAN/
说明:
https://github.com/junyanz/CycleGAN
这个是用lua 写的,也懒得看了。还是找个python版本的。

对抗模型的TensorFlow实现版本:

https://github.com/vanhuyz/CycleGAN-TensorFlow

https://github.com/tjwei/GANotebooks

3,总结


docker 镜像还是非常的方便的。
构建起python的程序还是非常的不错。学习TensorFlow 必备的工具呢。对快速学习非常有帮助的。

本文的原文连接是:
https://blog.youkuaiyun.com/freewebsys/article/details/81665552

博主地址是:http://blog.youkuaiyun.com/freewebsys

好的,以下是使用Docker Compose工具来快速构建分布式环境的具体步骤: 1. 首先,你需要安装Docker Compose工具。你可以从Docker官方网站下载适用于你的操作系统的Docker Compose版本,并按照官方文档中的说明进行安装。 2. 接下来,你需要创建一个Docker Compose配置文件。在该文件中,你需要指定需要运行的容器以及它们的配置信息。以下是一个简单的示例: ``` version: '3' services: container1: image: my_ml_image ports: - "8888:8888" command: jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root container2: image: my_ml_image command: python my_script.py container3: image: my_ml_image command: python my_script.py ``` 在该示例中,我们定义了三个容器,分别为container1、container2和container3。其中,container1容器运行Jupyter Notebook服务,并将其映射到主机的8888端口。container2和container3容器运行Python脚本。 3. 然后,你需要在每台Docker主机上启动Docker Compose。你可以使用以下命令启动Docker Compose: ``` docker-compose up -d ``` 该命令将根据你在Docker Compose配置文件中定义的配置信息,在每台Docker主机上启动相应的容器。 4. 现在,你可以使用Jupyter Notebook服务来开发和运行机器学习应用程序。你可以在任何一个容器中打开Web浏览器,并输入你的主机IP地址和8888端口,就可以访问Jupyter Notebook服务了。 需要注意的是,这只是一个基本的示例,你需要根据你的需求进行修改和定制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值