【华为云初体验】--这个故事要从一只蝙蝠说起

购买了华为云服务器学生套餐,包含了如下资源
在这里插入图片描述
按照控制台提示配置端口

登陆root用户,添加普通用户

useradd -m 用户名 -s /bin/bash

给useradd命令添加参数,在用户名之前使用-m,可以为用户添加默认家目录(如果不添加 家目录,这个用户将无法创建文件)。使用-m参数的同时还需要使用-s参数来指定shell的位 置(如果不添加shell的位置,用户的默认shell使用的是sh,它的功能比较弱)

设置普通用户密码

passwd 用户名

将用户添加到sudoers file中

chmod 777 /etc/sudoers     #修改文件权限
vim /etc/sudoers			#修改sudoers file
#在root ALL=(ALL:ALL) ALL 下面添加一行
用户名   ALL=(ALL)ALL    	
#保存退出
chmod 440 /etc/sudoers		#改回文件权限	 

登陆普通用户,下载anaconda

wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh 

安装anaconda(输入yes)

bash Anaconda3-5.0.1-Linux-x86_64.sh

检查是否成功
重新打开终端,检查python版本是否为python3

python --version

创建tenflow的开发环境

conda create -n tensorflow python=3.6

激活环境

source activate tensorflow

安装合适版本的tensorflow
某个教程建议安装最新版本的tensorflow 这样做不安全,
可能导致运行时出现

“Your CPU supports instructions that this TensorFlow binary was not
compiled to use: AVX2 FMA”

警告

法一:
选择合适版本,下载至本地
正确的方法应参照
https://blog.csdn.net/wlwlomo/article/details/82806118

法二:
查询可安装版本

pip install tensorflow==

选择合适版本进行安装

检查是否安装成功

import tensorflow as tf

若出现

Conversion of the second argument of issubdtype from float to
np.floating is deprecated. In future, it will be treated as
np.float64 == np.dtype(float).type.

考虑升级h5py包:

pip install --upgrade h5py

参考:https://blog.csdn.net/selfimpro_001/article/details/90174633

若出现

importerror: Something is wrong with the numpy installation. While importing we detected an older version of numpy in …One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

重复执行

pip uninstall numpy

至所有版本numpy都被卸载完为止

下载numpy

pip install numpy<1.17

注意:这里必须使用<1.17的版本 如

pip install numpy==1.16.4

否则会出现报错(这个错误在本地Win10系统中安装的Anaconda时也出现了,可以在tensorflow2环境下用同样的方法解决)

FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future ver…

参考
https://blog.csdn.net/mao_hui_fei/article/details/89318038
https://www.jianshu.com/p/945290726335

关于虚拟环境的问题:

激活环境和弃置环境:

source activate tensorflow
source deactivate tensorflow

共享环境:将当前使用的环境中所包含的python包的名称进行打包。

conda env export > 文件名.yaml

载入别人共享的环境。

conda env update -f=/path/文件名.yml

matplotlib库

若出现报错:

ImportError: No module named ‘matplotlib’

在tensorflow环境中安装

python -m pip install matplotlib 

参考:https://ask.csdn.net/questions/372790

若在调用其子库matplotlib.pyplot时出现错误:

import matplotlib.pyplot as plt

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

解决方法:
法一:(不建议

import matplotlib
matplotlib.use("Agg")//默认值为Qt5Agg,适用于有安装图形界面的系统
import matplotlib.pyplot as plt

参考
https://www.cnblogs.com/ddhj/p/3665141.html

法二:(推荐

安装图形界面
参考:
https://support.huaweicloud.com/ecs_faq/ecs_faq_0710.html
https://blog.csdn.net/networken/article/details/88938304

发布了43 篇原创文章 · 获赞 4 · 访问量 1198

猜你喜欢

转载自blog.csdn.net/weixin_42176221/article/details/104271134
今日推荐