上文讲到了成功安装anaconda和pycharm。没有找到合适的支持python3.7的tensorflow,故重新下载python3.6,方法和机器学习入门(1)类似。
主要内容:ubuntu16.04配置anaconda+tensorflow新手教程
前提:机器学习入门(2)已经安装好了anaconda
(1)直接在terminal中输入conda
rookie@ubuntu:~$ conda -V
conda 4.5.11
(2)输入指令conda info --envs
rookie@ubuntu:~$ conda info --envs
# conda environments:
#
base * /home/rookie/anaconda3
(3)创建虚拟环境
rookie@ubuntu:~$ conda create --name tf1 python=3.6
输入Y之后,创建成功输入如下:
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate tf1
#
# To deactivate an active environment, use
#
# $ conda deactivate
再次输入指令conda info --envs
rookie@ubuntu:~$ conda info --envs
# conda environments:
#
base * /home/rookie/anaconda3
tf1 /home/rookie/anaconda3/envs/tf1
(4)激活虚拟环境:(就是进入到这个虚拟环境里面)
rookie@ubuntu:~$ source activate tf1
(tf1) rookie@ubuntu:~$
PS:如果要退出:输入source deactivate tf
(5)在虚拟环境里安装tensorflow(cpu版本)
conda install tensorflow
参考https://blog.csdn.net/m0_37864814/article/details/82112029
The following packages will be downloaded:
package | build
---------------------------|-----------------
mkl-2017.0.3 | 0 129.5 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
The following NEW packages will be INSTALLED:
backports: 1.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
backports.weakref: 1.0rc1-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
blas: 1.0-mkl https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
bleach: 1.5.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
html5lib: 0.9999999-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libprotobuf: 3.4.0-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
markdown: 2.6.9-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
mkl: 2017.0.3-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
numpy: 1.13.1-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
protobuf: 3.4.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
six: 1.10.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow: 1.3.0-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow-base: 1.3.0-py36h5293eaa_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow-tensorboard: 0.1.5-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
werkzeug: 0.12.2-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
Proceed ([y]/n)? y
Downloading and Extracting Packages
mkl-2017.0.3 | 129.5 MB | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(6)测试tensorflow,安装成功
(tf1) rookie@ubuntu:~$ python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linuxType "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>>
(7)conda命令总结
参考https://blog.csdn.net/zongza/article/details/83039210
(8)执行命令conda install theano(theano是一个深度学习框架)
输出如下:
The following NEW packages will be INSTALLED:
libgfortran: 3.0.0-1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libgpuarray: 0.6.9-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
mako: 1.0.6-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
markupsafe: 1.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
mkl-service: 1.1.2-py36_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
nose: 1.3.7-py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pygpu: 0.6.9-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
scipy: 0.19.1-np113py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
theano: 0.9.0-py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
Proceed ([y]/n)? y
Downloading and Extracting Packages
libgfortran-3.0.0 | 281 KB | ################################################################################################################################################################# | 100%
mako-1.0.6 | 115 KB | ################################################################################################################################################################# | 100%
nose-1.3.7 | 201 KB | ################################################################################################################################################################# | 100%
mkl-service-1.1.2 | 15 KB | ################################################################################################################################################################# | 100%
scipy-0.19.1 | 36.3 MB | ################################################################################################################################################################# | 100%
markupsafe-1.0 | 31 KB | ################################################################################################################################################################# | 100%
libgpuarray-0.6.9 | 211 KB | ################################################################################################################################################################# | 100%
pygpu-0.6.9 | 1.3 MB | ################################################################################################################################################################# | 100%
theano-0.9.0 | 4.0 MB | ################################################################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(9)安装keras
参考https://blog.csdn.net/qq_31802027/article/details/73655965
先输入git clone https://github.com/fchollet/keras.git
再cd keras/
其次python setup.py install
git clone https://github.com/fchollet/keras.git输出如下:
Downloading and Extracting Packages
libgfortran-3.0.0 | 281 KB | ################################################################################################################################################################# | 100%
mako-1.0.6 | 115 KB | ################################################################################################################################################################# | 100%
nose-1.3.7 | 201 KB | ################################################################################################################################################################# | 100%
mkl-service-1.1.2 | 15 KB | ################################################################################################################################################################# | 100%
scipy-0.19.1 | 36.3 MB | ################################################################################################################################################################# | 100%
markupsafe-1.0 | 31 KB | ################################################################################################################################################################# | 100%
libgpuarray-0.6.9 | 211 KB | ################################################################################################################################################################# | 100%
pygpu-0.6.9 | 1.3 MB | ################################################################################################################################################################# | 100%
theano-0.9.0 | 4.0 MB | ################################################################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(tf1) rookie@ubuntu:~$ keras
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'
(tf1) rookie@ubuntu:~$ keras -V
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'
(tf1) rookie@ubuntu:~$ git clone https://github.com/fchollet/keras.git
Cloning into 'keras'...
remote: Enumerating objects: 32203, done.
remote: Total 32203 (delta 0), reused 0 (delta 0), pack-reused 32203
Receiving objects: 100% (32203/32203), 12.66 MiB | 8.00 KiB/s, done.
Resolving deltas: 100% (23492/23492), done.
Checking connectivity... done.
python setup.py install
报错:
In file included from /tmp/easy_install-2giks2je/h5py-2.9.0/h5py/defs.c:642:0:
/tmp/easy_install-2giks2je/h5py-2.9.0/h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
明天再来看吧,晚安!
这期间遇到了很多问题,我还有两个问题没有解决,如果有朋友有类似的问题,可以交流;希望有前辈指教。
第一个就是我先安装了python3.7.4,然后再安装python3.6.4的时候,安装失败,报错。说空间不够,然后我百度看怎么解决,有个命令如下,发现有个/dev/sda1把磁盘占满了,然后一直没有解决。现在删掉了一些东西,占比只有80%,然后python3.6.4得以安装成功,但是这个问题花费了不少时间,还没有解决!!!
root@ubuntu:/dev# df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.5G 0 1.5G 0% /dev
tmpfs 298M 4.9M 294M 2% /run
/dev/sda1 19G 18G 1.8M 100% /
tmpfs 1.5G 212K 1.5G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 1.5G 0 1.5G 0% /sys/fs/cgroup
tmpfs 298M 44K 298M 1% /run/user/1000
第二个是我在终端输入python,python3时,它出现的版本为什么总是python3.7.0。
使用的命令如下
rm -rf /usr/bin/python3
sudo ln -s /home/rookie/Desktop/local/python3.6.4/bin/python3.6 /usr/bin/python3
原来我先下载的python3.7.4,链接的是python3.7.0。之后下载了python3.6.4,我想把python和python3改成链接python3.6.4。命令是如上 ,但是在root模式下,是python3.6.4,但是在普通用户模式下,仍然还是python3.7.0。所以这个是为什么,我也是没有解决!!!
本文暂时没有评论,来添加一个吧(●'◡'●)