备忘随笔——安装centos7之后,装smlayer,带ffmpeg的opencv,anaconda,tensorflow

由于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中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

你可能感兴趣的:(linux)