Ubuntu下TensorFlow GPU版本的运行

运行tensorflow

在CUDA完成安装之后,还需要添加环境变量,打开终端,输入下面的命令:

export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
如果是64位系统,输入:
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
如果是32位系统,输入:
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

如果需要使用其中的内置库
export PYTHONPATH=$PYTHONPATH:/home/time/ImageNet/models-master

运行ResNet

ResNet的程序位于offical/resnet目录下
假设ImageNet存放目录为
/media/time/20162AC5162A9BB2/Thunder/ImageNet_TF

运行
python imagenet_main.py --data_dir='/media/time/20162AC5162A9BB2/Thunder/ImageNet_TF' --batch_size=16 --model_dir='./model_101Res/' --resnet_size=101

可以将上面的文件写成批处理文件

export PYTHONPATH=$PYTHONPATH:/home/time/ImageNet/models-master
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
python imagenet_main.py --data_dir='/media/time/20162AC5162A9BB2/Thunder/ImageNet_TF' --batch_size=256 --model_dir='./modelChkPt2/' --resnet_size=18

注意这里Image_main.py的参数

flags:

imagenet_main.py:
  -bs,--batch_size:
    Batch size for training and evaluation. When using multiple gpus, this is
    the
    global batch size for all devices. For example, if the batch size is 32 and
    there are 4 GPUs, each GPU will get 8 examples on each step.
    (default: '32')
    (an integer)
  --[no]clean:
    If set, model_dir will be removed if it exists.
    (default: 'false')
  -dd,--data_dir:
    The location of the input data.
    (default: '/tmp')
  -df,--data_format: <channels_first|channels_last>:
    A flag to override the data format used in the model. channels_first
    provides a
    performance boost on GPU but is not always compatible with CPU. If left
    unspecified, the data format will be chosen automatically based on whether
    TensorFlow was built for CPU or GPU.
  -ebe,--epochs_between_evals:
    The number of training epochs to run between evaluations.
    (default: '1')
    (an integer)
  -ed,--export_dir:
    If set, a SavedModel serialization of the model will be exported to this
    directory at the end of training. See the README for more details and
    relevant
    links.
  -hk,--hooks:
    A list of (case insensitive) strings to specify the names of training hooks.
      Hook:
        profilerhook
        loggingtensorhook
        examplespersecondhook
        loggingmetrichook
      Example: `--hooks ProfilerHook,ExamplesPerSecondHook`
    See official.utils.logs.hooks_helper for details.
    (default: 'LoggingTensorHook')
    (a comma separated list)
  -md,--model_dir:
    The location of the model checkpoint files.
    (default: '/tmp')
  -rs,--resnet_size: <18|34|50|101|152|200>:
    The size of the ResNet model to use.
    (default: '50')
  -rv,--resnet_version: <1|2>:
    Version of ResNet. (1 or 2) See README.md for details.
    (default: '2')
  -te,--train_epochs:
    The number of epochs used to train.
    (default: '100')
    (an integer)

使用Tensorboard

tensorboard --logdir=/home/time/ImageNet/models-master/official/resnet/model_101Res
可以启动tensorboard观察运行状态

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1说尊重的话 在人际交往中,最重要的是彼此尊重,你的口才可以不够好,但必须要懂得说尊重的话。平时,你要文明用语;开...
    鹿伟伦阅读 128评论 0 0
  • 过去已过去,未来已来; 愿我们在新风口,新态势下, 保持永不止步的学习态度, 将自己打造成最出色的人
    辰寅阅读 106评论 0 0