由于tensorflow只能运行在64位机,我还是下决心把我4g内存的老笔记本从centos6换装成了centos7.
下面是安装过程中的note笔记,未经整理,仅作备忘。
2019-9-27
配置epel源
https://www.cnblogs.com/lyz108/p/10293430.html
缺省yum源的服务器通常在国外,安装时速度比较慢。为了提高安装rpm包的速度,可以将yum源配置为国内的阿里repo。2
1、先备份系统原有的repo
[root@192 jello]# cd /etc/yum.repos.d/
[root@192 yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@192 yum.repos.d]# mkdir backup
[root@192 yum.repos.d]# mv *.repo ./backup/
2、获取阿里centos7的base-repo
[root@192 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@192 yum.repos.d]# ls
backup CentOS-Base.repo
3、清除并重新生成yum cache
[root@192 yum.repos.d]# yum clean all
[root@192 yum.repos.d]# yum makecache
4、测试一下新的yum源是否可用
[root@localhost yum.repos.d]# yum install -y screen
5、获取阿里centos7的epel-repo
[root@localhost yum.repos.d]# wget https://mirrors.aliyun.com/repo/epel-7.repo
6、清除并创建cache
[root@localhost yum.repos.d]# ls
backup CentOS-Base.repo epel-7.repo
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache
配置rpmforge源
http://rpmfind.net/linux/rpm2html/search.php?query=rpmforge-release
[root@192 Downloads]# rpm -ivh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
配置rpmfusion源
http://rpmfusion.org/Configuration
yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
安装smplayer
yum install smplayer*
---------------------------------------------------------------------------------------------------
安装opencv3.4.6
安装ffmpeg
yum install ffmpeg ffmpeg-devel
安装依赖项
yum install cmake gcc gcc-c++ gtk+-devel gimp-devel gimp-devel-tools gimp-help-browser zlib-devel libjpeg-devel libpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-devel jasper-devel jasper-utils swig python libtool nasm
yum install python-devel numpy
yum install libdc1394-devel
yum install libv4l-devel
yum install gstreamer-plugins-base-devel
cd /home/jello/Download/opencv-3.4.6
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_FFMPEG=ON -D OPENCV_EXTRA_MODULES_PATH=/home/jello/Download/opencv_contrib-3.4.6/modules ..
make
su
make install
[root@192 ld.so.conf.d]# vi opencv-3.4.6.conf
/usr/local/lib64
[root@192 ld.so.conf.d]# ldconfig
安装qt-opensource-linux-x64-5.9.8.run (补记于2020/4/19,新台式机上装双系统)
http://download.qt.io/official_releases/qt/5.9/5.9.8/
yum -y install mesa-libGL-devel mesa-libGLU-devel freeglut-devel
chmod +x qt-opensource-linux-x64-5.9.5.run
./qt-opensource-linux-x64-5.9.5.run
断网能跳过登录账户页面
安装组件选择,不勾选andriod和最后一个script(已过时),其他的全选
添加动态链接库
cd /etc/ld.so.conf.d/
vi qt5.9.8.conf
/opt/Qt5.9.8/5.9.8/gcc_64/lib
/opt/Qt5.9.8/Tools/QtCreator/lib
ldconfig
添加环境变量
vi ~/.bashrc
export PATH=$PATH:/opt/Qt5.9.8/5.9.8/gcc_64/bin/:/opt/Qt5.9.8/Tools/QtCreator/bin
这样只能在root环境下使用,普通用户jello居然无法使用,而且居然没有桌面快捷方式!
vi /etc/profile
export PATH=$PATH:/opt/Qt5.9.8/5.9.8/gcc_64/bin/:/opt/Qt5.9.8/Tools/QtCreator/bin 后jello下命令行输入qtcreator可用
添加桌面快捷方式
CentOS 7 创建qtcreator快捷方式
在/usr/share/applications/文件夹下,用vim新建一个qtcreator.desktop的文件
[Desktop Entry]
Type=Application
Name=qtcreator
Exec=/opt/Qt5.9.8/Tools/QtCreator/bin/qtcreator
GenericName=qtcreator
Comment=Qt development tools
Icon=/opt/Qt5.9.8/5.9.8/gcc_64/doc/global/template/images/Qt-logo.png
Categories=Application;Development;
Terminal=false
这样菜单中Applications下面才有了Programing->QtCreator !
QT中opencv项目pro文件中添加
INCLUDEPATH += /usr/local/include \
/usr/local/include/opencv \
/usr/local/include/opencv2
LIBS += /usr/local/lib64/libopencv*
-------------------------------------------------------------------------------------------------
anaconda清华镜像
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
Anaconda介绍、安装及使用教程
https://www.jianshu.com/p/62f155eb6ac5
[jello@192 Downloads]$ bash ./Anaconda3-4.1.1-Linux-x86_64.sh
Anaconda3 will now be installed into this location:
/home/jello/anaconda3
安装tensorflow
https://blog.csdn.net/zhaoliang027/article/details/80002647
下载网址为https://pypi.org/project/tensorflow/1.4.0/#files
conda create -n tensorflow python=3.5
The following NEW packages will be INSTALLED:
certifi: 2016.2.28-py35_0
openssl: 1.0.2l-0
pip: 9.0.1-py35_1
python: 3.5.4-0
readline: 6.2-2
setuptools: 36.4.0-py35_1
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py35_0
xz: 5.2.3-0
zlib: 1.2.11-0
然后进入conda环境并安装tensorflow
source activate tensorflow若不能激活,则可能是没有载入anaconda3的安装路径,需要执行$ export PATH=/home/zhaoliang/software/anaconda3/bin:$PATH
cd ~/download #我是将下载好的东西放在了download文件夹里
pip install --ignore-installed --upgradetensorflow-1.4.0-cp35-cp35m-manylinux1_x86_64.whl
3.测试是否安装成功
import tensorflow as tf
————————————————
版权声明:本文为CSDN博主「zhaoliang027」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhaoliang027/article/details/80002647
>>> hello=tf.constant('hello')
>>> sess=tf.Session()
2019-09-25 18:29:49.498754: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
>>> a=tf.constant(111)
>>> b=tf.constant(222)
>>> print(sess.run(a+b))
333
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"]='1' # 这是默认的显示等级,显示所有信息
os.environ["TF_CPP_MIN_LOG_LEVEL"]='2' # 只显示 warning 和 Error
os.environ["TF_CPP_MIN_LOG_LEVEL"]='3' # 只显示 Error
————————————————
版权声明:本文为CSDN博主「一个处女座的程序猿」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_41185868/article/details/79127838
>>> import os
>>> os.environ["TF_CPP_MIN_LOG_LEVEL"]='2'
>>> hello=tf.constant('hello')
>>> sess=tf.Session()
>>> a=tf.constant(111)
>>> b=tf.constant(222)
>>> print(sess.run(a+b))
>>> quit()
(tensorflow) [jello@192 Downloads]$ source deactivate
[jello@192 Downloads]$ conda info --envs
# conda environments:
#
tensorflow /home/jello/anaconda3/envs/tensorflow
root * /home/jello/anaconda3
第一次导入时报错:
>>> import tensorflow as tf
/home/jello/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:469: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/jello/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:470: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/jello/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:471: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/jello/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:472: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/jello/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:473: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/jello/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:476: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
cp /home/jello/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py /home/jello/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py.bak
将上面文件中警告的469等6行的np.dtype([("resource", np.ubyte, 1)])改为提示的np.dtype([("resource", np.ubyte, (1,))])
============================================================================================
[jello@192 ~]$ source activate tensorflow
(tensorflow) [jello@192 ~]$ conda install matplotlib
补记于2019.11.27
前面用anaconda创建了虚拟环境tensorflow如下:
conda create -n tensorflow python=3.5
之后在该环境下安装了tensorflow1.4
今天在该环境安装opencv3.4如下:
conda env list
source activate tensorflow
(tensorflow) [jello@192 tensorflow]$ pip install opencv-python==3.4.6.27
(tensorflow) [jello@192 tensorflow]$ pip install opencv-contrib-python==3.4.27
(tensorflow) [jello@192 tensorflow]$ python
>>> import cv2
>>> cv2.__version__
'3.4.6'
再补记于2020.4.19(新台式机装双系统后配置opencv失败,按如上操作网速太慢安装不了)
照该文章介绍的从清华镜像源安装,没有指定具体版本,pip默认给我安装了最新4.2版本的opencv与opencv contrib.待使用
https://www.cnblogs.com/ws17345067708/p/11043603.html
(tensorflow) [jello@192 ~]$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-python
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/00/aa/5880b514dff3642161bda4af39aa2a544cb5949d9e194d1ef81e06fcc2f2/opencv_python-4.2.0.34-cp35-cp35m-manylinux1_x86_64.whl (28.2 MB)
|████████████████████████████████| 28.2 MB 219 kB/s
Requirement already satisfied: numpy>=1.11.1 in ./anaconda3/envs/tensorflow/lib/python3.5/site-packages (from opencv-python) (1.18.2)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.2.0.34
(tensorflow) [jello@192 ~]$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-contrib-python
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/17/e4/aac4454c7df99b264fc53a12c25a40c76dc5b417f9866f6d6d1554aac80e/opencv_contrib_python-4.2.0.34-cp35-cp35m-manylinux1_x86_64.whl (34.2 MB)
|████████████████████████████████| 34.2 MB 113 kB/s
Requirement already satisfied: numpy>=1.11.1 in ./anaconda3/envs/tensorflow/lib/python3.5/site-packages (from opencv-contrib-python) (1.18.2)
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-4.2.0.34
补记于2019.11.29凌晨00:15
anaconda中tensorflow环境中安装scikit-learn 0.18.1
首先输入命令
conda install scikit-learn==0.18.1 网络太慢失败
CondaError: CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.continuum.io/pkgs/free/linux-64/scikit-learn-0.18.1-np113py35_1.tar.bz2>
Elapsed: -
按上面<>中的地址在浏览器中下载文件mv到anaconda的pkgs中
(之前(tensorflow) [jello@192 ~]$ conda install scikit-learn==0.18.1 --offline以及路径在Download下安装都莫名失败)
(tensorflow) [jello@192 ~]$ conda install /home/jello/anaconda3/pkgs/scikit-learn-0.18.1-np113py35_1.tar.bz2安装成功了
In [2]: import numpy as np
In [3]: from sklearn import datasets
In [4]: import matplotlib.pyplot as plt
In [5]: %matplotlib
运行成功