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

Vue+element ui realizes anchor positioning

This article example shares the specific code of ...

VMware virtual machine to establish HTTP service steps analysis

1. Use xshell to connect to the virtual machine, ...

JavaScript object built-in objects, value types and reference types explained

Table of contents Object Object Definition Iterat...

HTML tag dl dt dd usage instructions

Basic structure: Copy code The code is as follows:...

MySQL query syntax summary

Preface: This article mainly introduces the query...

MySQL 8.0.22 installation and configuration graphic tutorial

MySQL8.0.22 installation and configuration (super...

A time-consuming troubleshooting process record of a docker error

Table of contents origin Environmental Informatio...

Solve MySQL login error: 'Access denied for user 'root'@'localhost'

First of all, I don't know why I can't lo...

Use of Linux file command

1. Command Introduction The file command is used ...

CSS implements the web component function of sliding the message panel

Hello everyone, I wonder if you have the same con...

Implementation of multi-site configuration of Nginx on Mac M1

Note: nginx installed via brew Website root direc...

A little-known JS problem: [] == ![] is true, but {} == !{} is false

console.log( [] == ![] ) // true console.log( {} ...

Explain how to analyze SQL efficiency

The Explain command is the first recommended comm...

Detailed process of NTP server configuration under Linux

Table of contents 1. Environment Configuration 1....