深度学习基本环境搭建(ubutu16+Anaconda+Pycharm+Tensorflow)

(1) 安装ubutu16(在windows基础上安装ubutu16)


(2) 安装Anaconda3(利用科大镜像网站安装)


安装版本为:

(3) 安装tensorflow:

Installing with Anaconda

Take the following steps to install TensorFlow in an Anaconda environment:

  1. Follow the instructions on the Anaconda download site to download and install Anaconda.

  2. Create a conda environment named tensorflow to run a version of Python by invoking the following command:
    conda create -n tensorflow pip python=3.6
  3. Activate the conda environment by issuing the following command:

    source activate tensorflow
     (tensorflow)$  # Your prompt should change 
  4. Issue a command of the following format to install TensorFlow inside your conda environment:



    (tensorflow)$ pip install --ignore-installed --upgrade tfBinaryURL
    where tfBinaryURL is the URL of the TensorFlow Python package. For example, the following command installs the CPU-only version of TensorFlow for Python 3.6:
     (tensorflow)$ pip install --ignore-installed --upgrade \
     https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp34-cp34m-linux_x86_64.whl

退出tensorflow环境使用source deactivate


如何证明安装成功:

Enter the following short program inside the python interactive shell:

# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

If the system outputs the following, then you are ready to begin writing TensorFlow programs:


Hello, TensorFlow!

(4)如何将文件上传到服务器:

1)在本地的终端下,而不是在服务器上。在本地的终端上才能将本地的文件拷入服务器。 

scp -r localfile.txt [email protected]:/home/username/ 
其中, 
1)scp是命令,-r是参数 
2)localfile.txt 是文件的路径和文件名 
3)username是服务器账号 
4)192.168.0.1是要上传的服务器ip地址 
5)/home/username/是要拷入的文件夹路径

eg:   scp -r localfile.txt [email protected]:/home/xuchao/

出现问题1:

QXcbConnection: Could not connect to display  Aborted (core dumped)

解决:

我们一般登录服务器是使用: 

这时,我们要改变的就是,登入服务器时的命令行,如下: 
ssh -X [email protected]   注意:-X选项,要大写 
然后运行上述代码,就可以成功运行了

(5)安装Pycharm :

参考网站

启动pycharm:

cd /pycharm/ pycharm-community-2017.3.3/bin/
./pycharm.sh  可以了

出现问题1:

使用source activate tensorflow进入tensorflow环境之后发现没有pandas ,scipy包

解决: 在此环境下使用:
pip install pandas 而不是conda install pandas(因为这是运行在服务器上的,所有不能翻墙)

出现问题2:

如何在pycharm中运行tensorflow环境
 打开pycharm, 依次点击 file - > Settings(如果以后想所有项目都用anaconda python解释器就点击Default settings) - >Project: xx - >Project Interpreter 
2) 点击小齿轮,点击弹出来的add local
3)弹出的地址中选择:/home/xuchao/anaconda3/envs/tensorfow/bin/python(这个可以在
tensorflow环境中运行which python得到当前使用的环境)这里,然后选择让这个文件当解释器                    

2.基本使用: 

(1) 观察cpu ,gpu使用:

1. cpu、内存

使用top命令

$ top

有一个更直观的监测工具,叫htop

$ sudo apt-get install htop
$ stop

2. 查看gpu

使用 nvidia-smi 命令

$ nvidia-smi

但是这个命令只能显示一次,如果要实时显示,配合watch命令, 让一秒刷新一次

    $ watch -n 1 nvidia-smi

猜你喜欢

转载自blog.csdn.net/alxe_made/article/details/80471487
今日推荐