一、pip 安装
1、使用pip3安装Tensorflow、jupyter lab
#更新pip源
pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com --upgrade pip
#安装TensorFlow2.2.0
pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com tensorflow==2.2.0
#安装jupyter lab作为交互式开发环境
pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com jupyter lab
2、jupyter lab 配置json文件---config.json
{
"NotebookApp": {
"ip":"*",
"port":8888,
"password":"",
"open_browser":false,
"token":"",
"allow_root":true
}
}
其中,密码的生成方法如下
$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
'sha1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
生成后将该字符串填到上面的password中即可。
3、jupyter lab启动命令
jupyter lab --config config.json
二、Docker安装
1、拉取镜像并运行容器
docker run -itd \
-p 8888:8888 \
-v /opts/python-project:/python-project \
tensorflow/tensorflow:2.2.0-jupyter \
bash
2、进入容器
docker exec -it <你的容器ID> bash
3、安装jupyter lab
pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com jupyterlab
4、进入容器,启动jupyter lab
jupyter lab --config config.json