可能需要设置代理(如果有),否则有点慢,如在〜 /.bashrc 中添加下面的内容:
export https_proxy=http://192.168.1.1:xxxx/
export http_proxy=http://192.168.1.1:xxxx/
export ftp_proxy=http://192.168.1.1:xxxx/
切换到 Python 3.5.5:
$pyenv global 3.5.5
$python --version
创建一个 3.5 的虚拟环境:
$ conda create -n tensorflow-2-snpe-dlc python=3.5.5
PS:
tensorflow-2-snpe-dlc:是给安装 tensorflow 的虚拟环境的命名
python=3.5: 文档上此处写的是 python=3.4 , 但是后面使用 pip 安装其他软件的时候,会提示 python版本必须 >=3.5 ,故此处直接安装 3.5.
tensorflow-2-snpe-dlc:
遇到安装错误:
\-------------------------------------------------------
PackagesNotFoundError: The following packages are not available from
current channels:
\- python=3.4
\----------------------------------------------------
解决方法:
conda config --add channels conda-forge
conda create -n tensorflow-2-snpe-dlc python=3.5
激活虚拟环境:
$ conda activate tensorflow-2-snpe-dlc
安装 TensorFlow :
$ pip install futures
$ pip install enum34
-------------->这个步骤可以不需要,这个在 python3.x 中已经内置,不需要特定安装。 python2.x 才
需要安装。
$ pip uninstall setuptools
$ pip install setuptools
$ pip install tensorflow==1.14.0
-------------->这个步骤可能会因为网络的原因失败,可以使用离线安装。
https://pypi.org/project/tensorflow/1.14.0/#files
$ pip install pillow
验证结果:
( 验证之前,确保当前是在 Python 3.5.5 环境下 )
$ python
Python 3.5.5 | packaged by conda-forge | (default, Jul 23 2018, 23:45:43)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>>
>>> print(tf.__version__)
1.14.0
退出当前环境:
conda deactivate
配置 TensorFlow 环境 :
[1] 查看 $TENSORFLOW_DIR
(anaconda3-2020.02/envs/tensorflow-2-snpe-dlc) user@user-
OptiPlex-3070:~$ python
Python 3.5.5 | packaged by conda-forge | (default, Jul 23 2018, 23:45:43)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> print(tf.__path__)
['/home/uer/.pyenv/versions/anaconda3-2020.02/envs/tensorflow-2-snpe-
dlc/lib/python3.5/site-packages/tensorflow/python/keras/api/_v1',
'/home/user/.pyenv/versions/anaconda3-2020.02/envs/tensorflow-2-snpe-
dlc/lib/python3.5/site-
packages/tensorflow_estimator/python/estimator/api/_v1',
'/home/user/.pyenv/versions/anaconda3-2020.02/envs/tensorflow-2-snpe-
dlc/lib/python3.5/site-packages/tensorflow',
'/home/user/.pyenv/versions/anaconda3-2020.02/envs/tensorflow-2-snpe-
dlc/lib/python3.5/site-packages/tensorflow/_api/v1']
>>>
$TENSORFLOW_DIR就是 ‘/home/user/.pyenv/versions/anaconda3-2020.02/envs/tensorflow-2-snpe-dlc/lib/python3.5/site-packages/tensorflow’。
[2]运行脚本
$ cd $SNPE_ROOT
$ source bin/envsetup.sh -t $TENSORFLOW_DIR
此脚本会更新 PATH, LD_LIBRARY_PATH, and PYTHONPATH。
可能需要设置代理(如果有),否则有点慢,如在〜 /.bashrc 中添加下面的内容:
export https_proxy=http://192.168.1.1:xxxx/
export http_proxy=http://192.168.1.1:xxxx/
export ftp_proxy=http://192.168.1.1:xxxx/
切换到 Python 2.7.17:
$pyenv global 2.7.17
$python --version
创建一个 2.7 的虚拟环境:
$ conda create -n caffe-2-snpe-dlc python=2.7.17
激活虚拟环境:
$ conda activate caffe-2-snpe-dlc
安装 caffe :
$ conda install caffe
验证结果:
$ python
Python 2.7.17 |Anaconda, Inc.| (default, Oct 21 2019, 19:04:46)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe as cf
>>> print(cf.__version__)
配置 Caffe 环境 :
[1] 查看 $CAFFE_DIR
(caffe-2-snpe-dlc) user@user-OptiPlex-3070:~$ python
Python 2.7.17 |Anaconda, Inc.| (default, Oct 21 2019, 19:04:46)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import caffe as cf
>>> print(cf.__path__)
['/home/user/.pyenv/versions/anaconda3-2020.02/envs/caffe-2-snpe-
dlc/lib/python2.7/site-packages/caffe']
>>>
$CAFFE_DIR就是 ‘/home/user/.pyenv/versions/anaconda3-2020.02/envs/caffe-2-
snpe-dlc/lib/python2.7/site-packages/caffe’ 。
[2] 运行脚本
$ cd $SNPE_ROOT
$ source bin/envsetup.sh -t $CAFFE_DIR
此脚本会更新 PATH, LD_LIBRARY_PATH, and PYTHONPATH.