How to quickly install tensorflow environment in Docker

How to quickly install tensorflow environment in Docker

Quickly install the tensorflow environment in Docker and use TensorFlow.

1. Download the TensorFlow image

docker pull tensorflow/tensorflow

2. Create a TensorFlow container

docker run --name corwien-tensortflow -it -p 8888:8888 -v /Users/kaiyiwang/Code/ai/notebooks:/notebooks/data tensorflow/tensorflow

Command Description

  1. docker run runs the image.
  2. --name creates an alias for the container.
  3. -it keeps the command line running,
  4. -p 8888:8888 maps the local port 8888 to http://localhost:8888/.
  5. -v /Users/kaiyiwang/Code/ai/notebooks:/notebooks/data mounts the local /Users/kaiyiwang/Code/ai/notebooks folder to the /notebooks/data of the newly created container (the files created in this way can be saved to the local /Users/kaiyiwang/Code/ai/notebooks )
  6. tensorflow/tensorflow is the specified image, and the default tag is latest (i.e. tensorflow/tensorflow:latest)

Execute the above command:

We can see that the TensorFlow container is created and a default login page for JupiterNotebook is given.

We can use the following command to view the executing container and the corresponding mapping port of the container in a new command window:

docker ps 

3. Open the TensorFlow container

1. You can right-click to open the connection directly from the command line, or enter http://127.0.0.1:8888 in the browser and paste token from the command line.

4. Start TensorFlow Programming

1. Click to log in and you can see the interface, and you can create a new project

2. Interpretation of tensorflow example source code

from __future__ import print_function
#Import tensorflow
import tensorflow as tf
# Input two arrays, input1 and input2, then add them together and output the result with tf.Session():
  input1 = tf.constant([1.0, 1.0, 1.0, 1.0])
  input2 = tf.constant([2.0, 2.0, 2.0, 2.0])
  output = tf.add(input1, input2)
  result = output.eval()
  print("result: ", result)

3. Run the program, and the output result is (run successfully)

result: [ 3. 3. 3. 3.]

5. Related commands

1. Close or open the TensorFlow environment

#Shut down the tensorflow container docker stop corwien-tensortflow

#Start the TensorFlow container docker start corwien-tensortflow
#Enter http://localhost:8888/ in the browser

2. Modify the read and write permissions of the file

# Check read and write permissions ls -l
#Change tensorflow to belong to corwien (system default) user sudo chown -R corwien tensorflow/
#Change tensorflow to belong to the corwien (system default) user group sudo chgrp -R corwien tensorflow/

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Complete steps to install tensorflow based on docker

<<:  MySQL 5.7.17 latest installation tutorial with pictures and text

>>:  Open the app on the h5 side in vue (determine whether it is Android or Apple)

Recommend

Sample code for installing ElasticSearch and Kibana under Docker

1. Introduction Elasticsearch is very popular now...

Linux Check the installation location of the software simple method

1. Check the software installation path: There is...

Detailed tutorial on installing mysql 8.0.13 (rpm) on Centos7

yum or rpm? The yum installation method is very c...

How to distinguish MySQL's innodb_flush_log_at_trx_commit and sync_binlog

The two parameters innodb_flush_log_at_trx_commit...

Google Translate Tool: Quickly implement multilingual websites

Google China has released a translation tool that ...

Several ways to shut down Hyper-V service under Windows 10

When using VMware Workstation to open a virtual m...

MySQL aggregate function sorting

Table of contents MySQL result sorting - Aggregat...

Packetdrill's concise user guide

1. Packetdrill compilation and installation Sourc...

How to reset the initial value of the auto-increment column in the MySQL table

How to reset the initial value of the auto-increm...

Nginx http health check configuration process analysis

Passive Check With passive health checks, NGINX a...

Mysql: The user specified as a definer ('xxx@'%') does not exist solution

During the project optimization today, MySQL had ...

MySQL 8.0.24 version installation and configuration method graphic tutorial

This article records the installation and configu...