安装参考: https://blog.csdn.net/gangeqian2/article/details/79358543
假定anaconda cuda cudnn均已经安装
命令行安装anaconda:https://blog.csdn.net/lwgkzl/article/details/89329383
1.创建tensorflow环境
ningan@ningan-QiTianM610-D529:~/anaconda3$ conda create -n tensorflow-gpu python=3.6
如果出现安装不成功,则需要把已存在的tensorflow清除
cd /home/clover/anaconda3/envs
rm -r tensorflow
2.激活tensorflow环境
ningan@ningan-QiTianM610-D529:~/anaconda3$ conda activate tensorflow-gpu
3.安装tensorflow
(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3$ pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.4.0-cp36-cp36m-linux_x86_64.whl
4.验证是否安装成功
(1)(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3$ python
import tensorflow as tf
出现一堆警告
ctrl +D退出python
(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3$ pip uninstall numpy
(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3$
(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3$ pip install numpy==1.16.4
(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3$ python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
[GCC 7.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
import tensorflow as tf
/home/ningan/anaconda3/envs/tensorflow-gpu/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module ‘tensorflow.python.framework.fast_tensor_util’ does not match runtime version 3.6
return f(*args, **kwds)
这个错误就不管了
是版本问题 https://zhuanlan.zhihu.com/p/43278569
(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3$ conda deactivate
ningan@ningan-QiTianM610-D529:~/anaconda3$
(2)source activate tensorflow-gpu bash: activate: 没有那个文件或目录
ningan@ningan-QiTianM610-D529:~/anaconda3/envs$ source activate tensorflow-gpu
bash: activate: 没有那个文件或目录
#出现这一问题的主要原因在于bash在环境变量中找不到activate这个命令了
#所以需要将环境变量写入
#环境变量一般在两个位置~/.bashrc和/etc/bash.bashrc bash的设置
#~/.profile /etc/profile 系统设置
#最方便的做法是export export PATH="~/anaconda3/bin:$PATH" #将PATH添加即可 source activate YourEnvs
ningan@ningan-QiTianM610-D529:~/anaconda3/envs$ export PATH="~/anaconda3/bin:$PATH"
ningan@ningan-QiTianM610-D529:~/anaconda3/envs$ source activate tensorflow-gpu
(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3/envs$
(tensorflow-gpu) ningan@ningan-QiTianM610-D529:~/anaconda3/envs$ anaconda-navigator
pip show tensorflow
pip show numpy
参考:https://github.com/tensorflow/tensorflow/issues/31249
解决方法:
pip uninstall numpy
pip install numpy==1.16.4
方法一:
退出base环境回到系统自带的环境
conda deactivate
方法二
1,通过将auto_activate_base参数设置为false实现:
conda config --set auto_activate_base false
2,那要进入的话通过conda activate base
3,如果反悔了还是希望base一直留着的话通过
conda config --set auto_activate_base true
来恢复
在Python操作的时候,没有输入Python命令进入到Python命令操作界面
而是直接在Terminal下面直接输入import导致鼠标被锁死变成十字
可以使用ps -e |grep import找到import进程的id
再执行命令kill -9 id 杀死进程即可!