1 安装Anaconda
1.1 下载
地址:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
本例下载Anaconda3-2019.10-Linux-x86_64.sh
上传到服务器上
1.2 执行安装
bash Anaconda3-2019.10-Linux-x86_64.sh
- 按回车
- 输入yes
- 输入安装目录
/home/dhcc/anaconda3
- 输入yes进行
conda init
1.3 查看anaconda支持的软件格式
关闭terminal,重新打开一个
import pip
import pip._internal
print(pip._internal.pep425tags.get_supported())
2 安装 tensorflow
2.1 下载
地址:https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/tensorflow/
本例下载文件 tensorflow-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl
在anaconda目录的envs下创建文件夹tensorflow(即/home/dhcc/anaconda3/envs/
下)
上传文件到该目录
2.2 安装
2.2.1 方式一:依次补充依赖包
pip install tensorflow-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl
提示缺少软件grapcio
在 https://pypi.org/project 网站下载需要的软件
本例下载的是grpcio-1.28.1-cp37-cp37m-manylinux2010_x86_64.whl
pip install grpcio-1.28.1-cp37-cp37m-manylinux2010_x86_64.whl
继续安装tensorflow
依次下载安装缺失的软件
2.2.2 方式二:提前下载依赖包
发现还是很麻烦
所以先在有外网的环境下提前下载好依赖的安装包
再统一安装
(base) [root@localhost dhcc]# pip download -d /home/dhcc/packages/ tensorflow-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl
(base) [root@localhost packages]# ls
absl-py-0.9.0.tar.gz protobuf-3.11.3-cp37-cp37m-manylinux1_x86_64.whl
astor-0.8.1-py2.py3-none-any.whl pyasn1-0.4.8-py2.py3-none-any.whl
cachetools-4.1.0-py3-none-any.whl pyasn1_modules-0.2.8-py2.py3-none-any.whl
certifi-2020.4.5.1-py2.py3-none-any.whl requests-2.23.0-py2.py3-none-any.whl
chardet-3.0.4-py2.py3-none-any.whl requests_oauthlib-1.3.0-py2.py3-none-any.whl
gast-0.2.2.tar.gz rsa-4.0-py2.py3-none-any.whl
google_auth-1.14.3-py2.py3-none-any.whl scipy-1.4.1-cp37-cp37m-manylinux1_x86_64.whl
google_auth_oauthlib-0.4.1-py2.py3-none-any.whl setuptools-46.2.0-py3-none-any.whl
google_pasta-0.2.0-py3-none-any.whl six-1.14.0-py2.py3-none-any.whl
grpcio-1.28.1-cp37-cp37m-manylinux2010_x86_64.whl tensorboard-2.1.1-py3-none-any.whl
h5py-2.10.0-cp37-cp37m-manylinux1_x86_64.whl tensorflow-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl
idna-2.9-py2.py3-none-any.whl tensorflow_estimator-2.1.0-py2.py3-none-any.whl
importlib_metadata-1.6.0-py2.py3-none-any.whl termcolor-1.1.0.tar.gz
Keras_Applications-1.0.8-py3-none-any.whl urllib3-1.25.9-py2.py3-none-any.whl
Keras_Preprocessing-1.1.1-py2.py3-none-any.whl Werkzeug-1.0.1-py2.py3-none-any.whl
Markdown-3.2.2-py3-none-any.whl wheel-0.34.2-py2.py3-none-any.whl
numpy-1.18.4-cp37-cp37m-manylinux1_x86_64.whl wrapt-1.12.1.tar.gz
oauthlib-3.1.0-py2.py3-none-any.whl zipp-3.1.0-py3-none-any.whl
opt_einsum-3.2.1-py3-none-any.whl
单独下载
six-1.12.0-py2.py3-none-any.whl
typed_ast-1.4.1-cp37-cp37m-manylinux1_x86_64.whl
wrapt-1.11.2.tar.gz
上传,并删除不符合要求版本的包
重新执行安装
pip install *
安装成功
验证
(base) [root@localhost ~]# python
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-05-12 10:51:13.298664: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory
2020-05-12 10:51:13.298760: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory
2020-05-12 10:51:13.298776: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
>>>
3. 安装jupyter
也是提前在有网的环境下下载安装包
pip download -d /home/dhcc/packages/jupyter/ jupyter
安装
pip install *
单独下载安装包,并上传到服务器,重新安装
PyQt5_sip-4.19.19-cp37-cp37m-manylinux1_x86_64.whl
PyQt5-5.12.3-5.12.8-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl
PyQtWebEngine-5.12.1-5.12.8-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl
生成jupyter配置文件
(base) [root@localhost dhcc]# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
生成密码
123456
(base) [root@localhost dhcc]# ipython
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:586bffd06bf8:ed3fed1b7deeac6c86aa0b595c7ceb4c9b2c60cf'
In [3]:
修改配置文件
sha1:586bffd06bf8:ed3fed1b7deeac6c86aa0b595c7ceb4c9b2c60cf
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:586bffd06bf8:ed3fed1b7deeac6c86aa0b595c7ceb4c9b2c60cf'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
启动
(base) [root@localhost dhcc]# jupyter notebook --allow-root
[W 14:31:46.032 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 14:31:46.060 NotebookApp] JupyterLab extension loaded from /home/dhcc/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 14:31:46.060 NotebookApp] JupyterLab application directory is /home/dhcc/anaconda3/share/jupyter/lab
[I 14:31:46.062 NotebookApp] Serving notebooks from local directory: /home/dhcc
[I 14:31:46.062 NotebookApp] The Jupyter Notebook is running at:
[I 14:31:46.062 NotebookApp] http://localhost.localdomain:8888/
[I 14:31:46.062 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
连接
http://192.168.58.154:8888/